-
Notifications
You must be signed in to change notification settings - Fork 1
/
zshrc
166 lines (136 loc) · 5.64 KB
/
zshrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# Customize to your needs...
if [[ -s ~/z.sh ]]; then
source ~/z.sh
fi
for file in ~/.dotfiles/*-regular.sh
do
source $file
done
SSH_ENV="$HOME/.ssh/environment"
function start_agent {
echo "Initialising new SSH agent..."
/usr/bin/ssh-agent | sed 's/^echo/#echo/' >| "${SSH_ENV}"
echo succeeded
chmod 600 "${SSH_ENV}"
. "${SSH_ENV}" > /dev/null
/usr/bin/ssh-add;
}
# Source SSH settings, if applicable
if [ -f "${SSH_ENV}" ]; then
. "${SSH_ENV}" > /dev/null
#ps ${SSH_AGENT_PID} doesn't work under cywgin
ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || {
start_agent;
}
else
start_agent;
fi
POWERLEVEL9K_MODE="awesome-fontconfig"
# zsh-syntax-highlighting
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern)
ZSH_HIGHLIGHT_PATTERNS+=("rm -rf *" "fg=white,bold,bg=red")
typeset -A ZSH_HIGHLIGHT_STYLES
ZSH_HIGHLIGHT_STYLES[path]="fg=white"
ZSH_HIGHLIGHT_STYLES[path_pathseparator]="fg=grey"
ZSH_HIGHLIGHT_STYLES[alias]="fg=cyan"
ZSH_HIGHLIGHT_STYLES[builtin]="fg=cyan"
ZSH_HIGHLIGHT_STYLES[function]="fg=cyan"
ZSH_HIGHLIGHT_STYLES[command]='fg=green'
ZSH_HIGHLIGHT_STYLES[precommand]='fg=green'
ZSH_HIGHLIGHT_STYLES[hashed-command]='fg=green'
ZSH_HIGHLIGHT_STYLES[commandseparator]="fg=yellow"
ZSH_HIGHLIGHT_STYLES[redirection]="fg=magenta"
ZSH_HIGHLIGHT_STYLES[bracket-level-1]="fg=cyan,bold"
ZSH_HIGHLIGHT_STYLES[bracket-level-2]="fg=green,bold"
ZSH_HIGHLIGHT_STYLES[bracket-level-3]="fg=magenta,bold"
ZSH_HIGHLIGHT_STYLES[bracket-level-4]="fg=yellow,bold"
# =============================================================================
# Options
# =============================================================================
# improved less option
export LESS="--tabs=4 --no-init --LONG-PROMPT --ignore-case --quit-if-one-screen --RAW-CONTROL-CHARS"
# Watching other users
WATCHFMT="%n %a %l from %m at %t."
#watch=(notme) # Report login/logout events for everybody except ourself.
LOGCHECK=60 # Time (seconds) between checks for login/logout activity.
REPORTTIME=5 # Display usage statistics for commands running > 5 sec.
#WORDCHARS="\"*?_-.[]~=/&;!#$%^(){}<>\""
WORDCHARS="\"*?_-[]~&;!#$%^(){}<>\""
# History
HISTFILE=~/.zsh_history
HISTSIZE=100000
SAVEHIST=100000
setopt autocd # Allow changing directories without `cd`
setopt append_history # Don;t overwrite history
setopt extended_history # Also record time and duration of commands.
setopt share_history # Share history between multiple shells
setopt hist_expire_dups_first # Clear duplicates when trimming internal hist.
setopt hist_find_no_dups # Don"t display duplicates during searches.
setopt hist_ignore_dups # Ignore consecutive duplicates.
setopt hist_ignore_all_dups # Remember only one unique copy of the command.
setopt hist_reduce_blanks # Remove superfluous blanks.
setopt hist_save_no_dups # Omit older commands in favor of newer ones.
# Changing directories
setopt pushd_ignore_dups # Don"t push copies of the same dir on stack.
setopt pushd_minus # Reference stack entries with "-".
setopt extended_glob
# =============================================================================
# Aliases
# =============================================================================
# In the definitions below, you will see use of function definitions instead of
# aliases for some cases. We use this method to avoid expansion of the alias in
# combination with the globalias plugin.
# Common CTRL bindings.
bindkey "^a" beginning-of-line
bindkey "^e" end-of-line
bindkey "^f" forward-word
bindkey "^b" backward-word
bindkey "^k" kill-line
bindkey "^d" delete-char
bindkey "^y" accept-and-hold
bindkey "^w" backward-kill-word
bindkey "^u" backward-kill-line
bindkey "^R" history-incremental-pattern-search-backward
bindkey "^F" history-incremental-pattern-search-forward
# Do not require a space when attempting to tab-complete.
bindkey "^i" expand-or-complete-prefix
# =============================================================================
# Completions
# =============================================================================
# case-insensitive (all), partial-word and then substring completion
zstyle ":completion:*" matcher-list \
"m:{a-zA-Z}={A-Za-z}" \
"r:|[._-]=* r:|=*" \
"l:|=* r:|=*"
zstyle ":completion:*:default" list-colors ${(s.:.)LS_COLORS}
# =============================================================================
# Other
# =============================================================================
# Overwrite oh-my-zsh"s version of `globalias", which makes globbing and
# on-the-fly shell programming painful. The only difference to the original
# function definition is that we do not use the `expand-word" widget.
# See https://github.com/robbyrussell/oh-my-zsh/issues/6123 for discussion.
globalias() {
zle _expand_alias
#zle expand-word
zle self-insert
}
zle -N globalias
# Utility that prints out lines that are common among $# files.
intersect() {
local sort="sort -S 1G"
case $# in
(0) true;;
(2) $sort -u "$1"; $sort -u "$2";;
(*) $sort -u "$1"; shift; intersection "$@";;
esac | $sort | uniq -d
}
# Changes an iTerm profile by sending a proprietary escape code that iTerm
# intercepts. This function additionally updates ITERM_PROFILE environment
# variable.
iterm-profile() {
echo -ne "\033]50;SetProfile=$1\a"
export ITERM_PROFILE="$1"
}
test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh"
source ~/.antigenrc