-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzshrc.sh
executable file
·122 lines (100 loc) · 3.34 KB
/
zshrc.sh
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
# zsh
# import profile.d
if [[ -d /etc/profile.d ]]; then
for i in /etc/profile.d/*.sh; do
if [[ -r ${i} ]]; then
. ${i}
fi
done
unset i
fi
if type brew &>/dev/null; then
fpath=("$(brew --prefix)/share/zsh/site-functions" ${fpath})
fi
if [[ -d /usr/local/share/zsh-completions ]]; then
fpath=(/usr/local/share/zsh-completions ${fpath})
fi
zstyle ':completion:*' completer _expand _complete _ignored
zstyle ':completion:*' max-errors 2
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}'
zstyle :compinstall filename "${HOME}/.zshrc"
autoload -Uz +X compinit && compinit -u
autoload -U promptinit && promptinit
autoload -U colors && colors
autoload -U +X bashcompinit && bashcompinit
for compfile in ${SCRIPT_BASE_DIR}/bash-completion/*.sh; do
. ${compfile}
done
[[ -f ~/.fzf.zsh ]] && . ~/.fzf.zsh
HISTFILE=~/.histfile
HISTSIZE=10000000
SAVEHIST=10000000
setopt appendhistory autocd extendedglob hist_ignore_dups completealiases
unsetopt beep nomatch notify
bindkey -e
bindkey "\e[1~" beginning-of-line # Home
bindkey "\e[4~" end-of-line # End
bindkey "\e[5~" beginning-of-history # PageUp
bindkey "\e[6~" end-of-history # PageDown
bindkey "\e[2~" quoted-insert # Ins
bindkey "\e[3~" delete-char # Del
bindkey "\e[5C" forward-word
bindkey "\eOc" emacs-forward-word
bindkey "\e[5D" backward-word
bindkey "\eOd" emacs-backward-word
bindkey "\e\e[C" forward-word
bindkey "\e\e[D" backward-word
# for rxvt
bindkey "\e[7~" beginning-of-line # Home
bindkey "\e[8~" end-of-line # End
# # for non RH/Debian xterm, can't hurt for RH/Debian xterm
bindkey "\eOH" beginning-of-line
bindkey "\eOF" end-of-line
# # for freebsd console
bindkey "\e[H" beginning-of-line
bindkey "\e[F" end-of-line
bindkey "^[[A" history-search-backward
bindkey "^[[B" history-search-forward
zle -N bash-backward-kill-word
bash-backward-kill-word() {
local WORDCHARS="${WORDCHARS:s#/#}"
zle backward-delete-word
}
bindkey '^e' bash-backward-kill-word
type -p dircolors >/dev/null 2>&1
[[ $? -eq 0 ]] && eval $(dircolors -b)
# prompt
setopt PROMPT_SUBST
[[ -z "$PROMPT_DIRECTORY" ]] && PROMPT_DIRECTORY='~'
if [[ "$USER" == "root" ]]; then
PS1="$(print "[%{\e[0;31m%}%?%{\e[0m%}:%{\e[1;31m%}%m%{\e[0m%}] %{\e[1;36m%}%\$PROMPT_DIRECTORY%{\e[0m%} %{\e[0;32m%}\$%{\e[0m%}") "
else
PS1="$(print "[%{\e[0;31m%}%?%{\e[0m%}:%{\e[1;32m%}%n%{\e[0m%}@%{\e[1;33m%}%m%{\e[0m%}] \$(getProjectNameInDir .)%{\e[1;36m%}%\$PROMPT_DIRECTORY%{\e[0m%}%{\e[0;35m%}\$(_git_ps1)%{\e[0m%} %{\e[0;32m%}\$%{\e[0m%}") "
fi
precmd() {
if [[ ! -z "$SESSION_TITLE" ]]; then
print -Pn "\e]0;${SESSION_TITLE} - %n@%m: %~\a"
else
print -Pn "\e]0;%n@%m: %~\a"
fi
}
[[ -z $MC_SID ]] && RPROMPT="$(print '%{\e[2;38m%}%y | %T%{\e[0m%}')"
shortPrompt() {
PROMPT_DIRECTORY='1~'
}
longPrompt() {
PROMPT_DIRECTORY='~'
}
if [[ ! -d "$SCRIPT_BASE_DIR/utils/z" ]]; then
if type -p git > /dev/null; then
git clone --quiet https://github.com/rupa/z.git "$SCRIPT_BASE_DIR/utils/z"
fi
fi
if [[ ! -d "$SCRIPT_BASE_DIR/utils/zsh-syntax-highlighting" ]]; then
if type -p git > /dev/null; then
git clone --quiet https://github.com/zsh-users/zsh-syntax-highlighting.git "$SCRIPT_BASE_DIR/utils/zsh-syntax-highlighting"
fi
fi
if [[ -e "$SCRIPT_BASE_DIR/utils/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" ]]; then
. "$SCRIPT_BASE_DIR/utils/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
fi