-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzshrc
197 lines (159 loc) · 6.32 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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# Antigen: https://github.com/zsh-users/antigen
ANTIGEN="$HOME/.shell/antigen.zsh"
# Install antigen.zsh if not exist
if [ ! -f "$ANTIGEN" ]; then
echo "Installing antigen ..."
[ ! -f "$HOME/.z" ] && touch "$HOME/.z"
URL="http://git.io/antigen"
TMPFILE="/tmp/antigen.zsh"
if [ -x "$(which curl)" ]; then
curl -L "$URL" -o "$TMPFILE"
elif [ -x "$(which wget)" ]; then
wget "$URL" -O "$TMPFILE"
else
echo "ERROR: please install curl or wget before installation !!"
exit
fi
if [ ! $? -eq 0 ]; then
echo ""
echo "ERROR: downloading antigen.zsh ($URL) failed !!"
exit
fi;
echo "move $TMPFILE to $ANTIGEN"
mv "$TMPFILE" "$ANTIGEN"
fi
# Enable 256 color to make auto-suggestions look nice
#export TERM="xterm-256color"
# Load local bash/zsh compatible settings
_INIT_SH_NOFUN=1
[ -f "$HOME/.local/etc/init.sh" ] && source "$HOME/.local/etc/init.sh"
# exit for non-interactive shell
[[ $- != *i* ]] && return
# WSL (aka Bash for Windows) doesn't work well with BG_NICE
[ -d "/mnt/c" ] && [[ "$(uname -a)" == *Microsoft* ]] && unsetopt BG_NICE
# Initialize antigen
source "$ANTIGEN"
# Initialize oh-my-zsh
antigen use oh-my-zsh
# default bundles
# visit https://github.com/unixorn/awesome-zsh-plugins
# antigen bundle git
# antigen bundle heroku
#antigen bundle pip
#antigen bundle svn-fast-info
# antigen bundle command-not-find
#antigen bundle colorize
#antigen bundle github
#antigen bundle python
#antigen bundle rupa/z z.sh
# antigen bundle z
antigen bundle zsh-users/zsh-autosuggestions
antigen bundle zsh-users/zsh-completions
# antigen bundle supercrabtree/k
#antigen bundle Vifon/deer
# uncomment the line below to enable theme
# antigen theme fishy
# check login shell
if [[ -o login ]]; then
[ -f "$HOME/.local/etc/login.sh" ] && source "$HOME/.local/etc/login.sh"
[ -f "$HOME/.local/etc/login.zsh" ] && source "$HOME/.local/etc/login.zsh"
fi
# load local config
[ -f "$HOME/.local/etc/config.zsh" ] && source "$HOME/.local/etc/config.zsh"
[ -f "$HOME/.local/etc/local.zsh" ] && source "$HOME/.local/etc/local.zsh"
# enable syntax highlighting
antigen bundle zsh-users/zsh-syntax-highlighting
antigen apply
# VI key bindings, first things first :^)
bindkey -v
# create a zkbd compatible hash;
# to add other keys to this hash, see: man 5 terminfo
typeset -A key
key[Home]=${terminfo[khome]}
key[End]=${terminfo[kend]}
key[Insert]=${terminfo[kich1]}
key[Delete]=${terminfo[kdch1]}
key[Up]=${terminfo[kcuu1]}
key[Down]=${terminfo[kcud1]}
key[Left]=${terminfo[kcub1]}
key[Right]=${terminfo[kcuf1]}
key[PageUp]=${terminfo[kpp]}
key[PageDown]=${terminfo[knp]}
# setup key accordingly
[[ -n "${key[Home]}" ]] && bindkey "${key[Home]}" beginning-of-line
[[ -n "${key[End]}" ]] && bindkey "${key[End]}" end-of-line
[[ -n "${key[Insert]}" ]] && bindkey "${key[Insert]}" overwrite-mode
[[ -n "${key[Delete]}" ]] && bindkey "${key[Delete]}" delete-char
[[ -n "${key[Up]}" ]] && bindkey "${key[Up]}" up-line-or-history
[[ -n "${key[Down]}" ]] && bindkey "${key[Down]}" down-line-or-history
[[ -n "${key[Left]}" ]] && bindkey "${key[Left]}" backward-char
[[ -n "${key[Right]}" ]] && bindkey "${key[Right]}" forward-char
# Finally, make sure the terminal is in application mode, when zle is
# active. Only then are the values from $terminfo valid.
function zle-line-init () {
echoti smkx
}
function zle-line-finish () {
echoti rmkx
}
zle -N zle-line-init
zle -N zle-line-finish
# CTRL-T pushes the current line to a temp buffer
bindkey "^T" push-line-or-edit
# CTRL-K kill the current buffer
bindkey "^K" kill-buffer
# CTRL-X loads man-page of current command
bindkey '^X' run-help
# CTRL-/ will undo TAB expansion
bindkey '^_' undo
# CTRL-P will search the history for completions
bindkey '^P' history-search-backward
# CTRL-N will search the history for completions
bindkey '^N' history-search-forward
# CTRL-H will delete backward one word
bindkey '^H' backward-delete-word
# CTRL-L will delete current word
bindkey '^L' delete-word
# CTRL-F will move to the end of the line
bindkey '^F' vi-end-of-line
# CTRL-B will move to the begin of the line
bindkey '^B' vi-beginning-of-line
alias ll='ls -l'
# options
unsetopt correct_all
setopt BANG_HIST # Treat the '!' character specially during expansion.
setopt INC_APPEND_HISTORY # Write to the history file immediately, not when the shell exits.
setopt SHARE_HISTORY # Share history between all sessions.
setopt HIST_EXPIRE_DUPS_FIRST # Expire duplicate entries first when trimming history.
setopt HIST_IGNORE_DUPS # Don't record an entry that was just recorded again.
setopt HIST_IGNORE_ALL_DUPS # Delete old recorded entry if new entry is a duplicate.
setopt HIST_FIND_NO_DUPS # Do not display a line previously found.
setopt HIST_IGNORE_SPACE # Don't record an entry starting with a space.
setopt HIST_SAVE_NO_DUPS # Don't write duplicate entries in the history file.
setopt HIST_REDUCE_BLANKS # Remove superfluous blanks before recording entry.
setopt HIST_VERIFY # Don't execute immediately upon history expansion.
# source function.sh if it exists
[ -f "$HOME/.local/etc/function.sh" ] && . "$HOME/.local/etc/function.sh"
# ignore complition
zstyle ':completion:*:complete:-command-:*:*' ignored-patterns '*.pdf|*.exe|*.dll'
export LS_COLORS='no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.cmd=01;32:*.exe=01;32:*.com=01;32:*.btm=01;32:*.bat=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.bz2=01;31:*.rpm=01;31:*.deb=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.jpg=01;35:*.gif=01;35:*.bmp=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.mpg=01;37:*.avi=01;37:*.mov=01;37:*.tbz=01;31:*.zip=01;31:*.mp3=00;34:*.png=01;35:*.89t=00;33';
#; Are we using GNU ls? If so, set the colors.
if (dircolors &>/dev/null); then
if (ls --color=yes &>/dev/null); then
if [ "$?" = "0" ]; then
if [ -f ~/.shell/dircolors ]; then
eval `dircolors ${HOME}/.shell/dircolors`
else
eval `dircolors`
fi
fi
fi
alias ls='ls -hF --color=auto --show-control-chars'
else
alias ls='ls -l'
fi
[ -f ~/.shell/aliases ] && . ~/.shell/aliases
[ -f ~/.shell/local_aliases ] && . ~/.shell/local_aliases
# Initialize command prompt
export PS1='%{[22;31m%}<%{[22;32m%}%n@%m%{[01;37m%}:%{[22;33m%}%~%{[22;31m%}>
%{[00m%}$ '