This repository has been archived by the owner on Jan 17, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdot.zshrc
180 lines (145 loc) · 4.26 KB
/
dot.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
bindkey -e
### history
setopt extended_history
setopt hist_expand
setopt hist_ignore_dups
setopt hist_ignore_all_dups
setopt hist_reduce_blanks
setopt hist_no_store
setopt hist_ignore_space
setopt share_history
setopt inc_append_history
HISTFILE="$HOME/.zhistory"
HISTSIZE=100000
SAVEHIST=100000
### prompt
unsetopt promptcr
setopt prompt_subst
autoload -U colors; colors
autoload -Uz vcs_info
local HOSTNAME_COLOR=$'%{\e[38;5;190m%}'
local USERNAME_COLOR=$'%{\e[38;5;199m%}'
local PATH_COLOR=$'%{\e[38;5;61m%}'
local RUBY_COLOR=$'%{\e[38;5;31m%}'
local VCS_COLOR=$'%{\e[38;5;248m%}'
zstyle ':vcs_info:*' formats '[%b]'
zstyle ':vcs_info:*' actionformats '[%b] (%a)'
zstyle ':vcs_info:git:*' check-for-changes true
zstyle ':vcs_info:git:*' unstagedstr '¹' # display ¹ if there are unstaged changes
zstyle ':vcs_info:git:*' stagedstr '²' # display ² if there are staged changes
zstyle ':vcs_info:git:*' formats '[%b]%c%u'
zstyle ':vcs_info:git:*' actionformats '[%b|%a]%c%u'
# ruby version
function ruby_prompt {
result=`rbenv version | sed -e 's/ .*//'`
if [ "$result" ] ; then
echo "[$result]"
fi
}
precmd () {
psvar=()
vcs_info
[[ -n "$vcs_info_msg_0_" ]] && psvar[1]="$vcs_info_msg_0_"
echo -ne "\033]0;${USER}@${HOSTNAME%%.*}\007"
}
RUBY_INFO=$'%{$RUBY_COLOR%}$(ruby_prompt)%{${reset_color}%}'
RPROMPT="${RUBY_INFO}%{${reset_color}%}"
PROMPT=$'%{$fg[yellow]%}%n%{$fg[red]%}@$fg[green]%}%m %{$fg[cyan]%}%~ %1(v|%F{green}%1v%f|)\n%{$fg[green]%}%#%{$reset_color%} '
### completion
autoload -Uz compinit; compinit -u
setopt auto_list
setopt auto_menu
setopt list_packed
setopt list_types
setopt print_eight_bit
setopt complete_in_word
setopt mark_dirs
setopt auto_param_slash
setopt auto_param_keys
setopt magic_equal_subst
_cache_hosts=(`perl -ne 'if (/^([a-zA-Z0-9.-]+)/) { print "$1\n";}' ~/.ssh/known_hosts`)
zstyle ':completion:*' use-cache yes
zstyle ':completion:*' verbose yes
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([%0-9]#)*=0=01;31'
zstyle ':completion:*' list-colors $LS_COLORS
### etc
export WORDCHARS='*?_-.[]~=&;!#$%^(){}<>'
#setopt no_unset
unsetopt no_unset
setopt auto_cd
setopt no_beep
setopt extended_glob
setopt numeric_glob_sort
setopt glob_complete
setopt glob_dots
setopt brace_ccl
setopt ignore_eof
setopt pushd_ignore_dups
setopt interactive_comments
setopt auto_pushd
setopt long_list_jobs
setopt short_loops
setopt transient_rprompt
setopt no_hup
setopt correct
# bindkey
bindkey '^P' history-beginning-search-backward
bindkey '^N' history-beginning-search-forward
bindkey '^X^F' forward-word
bindkey '^X^B' backward-word
bindkey '^R' history-incremental-pattern-search-backward
bindkey '^S' history-incremental-pattern-search-forward
autoload zmv
alias zmv='noglob zmv -W'
# replace
autoload -U replace-string
zle -N replace-string
# insert previous command last word
autoload smart-insert-last-word
zle -N insert-last-word smart-insert-last-word
zstyle :insert-last-word match \
'*([^[:space:]][[:alpha:]/\\]|[[:alpha:]/\\][^[:space:]])*'
bindkey '^]' insert-last-word
# quote previous word in single or double quote
autoload -U modify-current-argument
_quote-previous-word-in-single() {
modify-current-argument '${(qq)${(Q)ARG}}'
zle vi-forward-blank-word
}
zle -N _quote-previous-word-in-single
bindkey '^[s' _quote-previous-word-in-single
_quote-previous-word-in-double() {
modify-current-argument '${(qqq)${(Q)ARG}}'
zle vi-forward-blank-word
}
zle -N _quote-previous-word-in-double
bindkey '^[d' _quote-previous-word-in-double
## git completion
#autoload -U bashcompinit
#bashcompinit
#source /usr/local/etc/bash_completion.d/git-completion.bash
source ~/.aliases
# init rbenv
eval "$(rbenv init - zsh)"
if [[ -f ~/.rbenv/completions/rbenv.zsh ]]; then
source ~/.rbenv/completions/rbenv.zsh
fi
. `brew --prefix`/etc/profile.d/z.sh
autoload -Uz add-zsh-hook
function _precmd () {
_z --add "$(pwd -P)"
}
add-zsh-hook preexec _precmd
# function precmd () {
# _z --add "$(pwd -P)"
# }
# init zaw
source ~/.functions/zaw/zaw.zsh
### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"
# added by travis gem
[ -f ~/.travis/travis.sh ] && source ~/.travis/travis.sh
if [ ~/.zshrc -nt ~/.zshrc.zwc ]; then
zcompile ~/.zshrc
fi