-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.zshrc
237 lines (203 loc) · 5.23 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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
if [[ -s "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" ]]; then
source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh"
fi
export PATH="/opt/local/bin:/usr/local/bin:/opt/local/sbin:/usr/local/lib:/opt/local/include:$PATH"
if [ -d "$ZDOTDIR/.func" ]; then
fpath=($ZDOTDIR/.func $fpath)
autoload ${fpath[1]}/*(:t)
fi
if [ -d "/opt/local/share/zsh/${ZSH_VERSION}/functions" ]; then
fpath=(/opt/local/share/zsh/${ZSH_VERSION}/functions/ $fpath)
fi
if [ -d "$ZDOTDIR/dash" ]; then
fpath=($ZDOTDIR/dash $fpath)
autoload ${fpath[1]}/*(:t)
fi
# User configuration
#export MANPATH="/usr/local/man:$MANPATH"
# You may need to manually set your language environment
# export LANG=en_US.UTF-8
# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
# export EDITOR='vim'
# else
# export EDITOR='mvim'
# fi
# Compilation flags
# export ARCHFLAGS="-arch x86_64"
# ssh
# export SSH_KEY_PATH="~/.ssh/dsa_id"
#alias
source $ZDOTDIR/.zshaliases
#USER zshrc
SAVEHIST=100000
HISTFILE=$ZDOTDIR/.zhistory
HISTSIZE=100000
#####prompt edit
if [ "$USER" = "root" ]
then
pc=$RED
else
pc=cyan
fi
#zsh-completions
if [ -e /opt/local/var/macports/software/zsh-completions ]; then
fpath=(/opt/local/var/macports/software/zsh-completions $fpath)
fi
if [ -e /opt/local/share/zsh/${ZSH_VERSION}/functions ]; then
fpath=(/opt/local/share/zsh/${ZSH_VERSION}/functions $fpath)
fi
#autoload functions
zle -N peco-tree-vim
bindkey "^t" peco-tree-vim
##case insensitive autocomplete
autoload -U compinit && compinit
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
zstyle ':completion:*:default' menu select=2
##zmv
autoload -U zmv
#ignore logout when C-d
setopt IGNORE_EOF
#neglect same command fromm saving history
setopt HIST_IGNORE_DUPS
#share history
setopt SHARE_HISTORY
#reduce blank from history
setopt HIST_REDUCE_BLANKS
#exclude history from saving in zhistory
setopt HIST_NO_STORE
#exclude command starts from blank space from saving in zhistory
setopt HIST_IGNORE_SPACE
#notify background jobs
setopt NOTIFY
#auto-cd
setopt AUTOCD
#add / to directory
setopt auto_param_slash
setopt EXTENDED_GLOB
setopt HIST_IGNORE_ALL_DUPS
setopt HIST_FIND_NO_DUPS
#C-w
export WORDCHARS="*?_-.[]~=&;\!#$%^(){}<>"
#DIESTACKSIZE
DIRSTACKSIZE=10
#fignore
fignore=(.o \~)
#LISTMAX
LISTMAX=0
#READNULLCMD
READNULLCMD='less'
#keybind
autoload -U history-search-end
zle -N history-beginning-search-backward-end history-search-end
zle -N history-beginning-search-forward-end history-search-end
bindkey "^P" history-beginning-search-backward-end
bindkey "^N" history-beginning-search-forward-end
if [ -f $ZDOTDIR/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ]; then
source $ZDOTDIR/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
fi
export LESS='-i -N -R -g'
export LESSOPEN="export LESSOPEN='|lessfilter.sh %s'"
export FPATH="/opt/local/share/zsh/site-functions/:$FPATH "
if [ -f /opt/local/share/autojump/autojump.zsh ]; then
. /opt/local/share/autojump/autojump.zsh
fi
function man() {
env \
LESS_TERMCAP_mb=$(printf "\e[1;31m") \
LESS_TERMCAP_md=$(printf "\e[1;36m") \
LESS_TERMCAP_me=$(printf "\e[0m") \
LESS_TERMCAP_se=$(printf "\e[0m") \
LESS_TERMCAP_so=$(printf "\e[1;44;33m") \
LESS_TERMCAP_ue=$(printf "\e[0m") \
LESS_TERMCAP_us=$(printf "\e[1;32m") \
man "$@"
}
function peco-select-history() {
local tac
if which tac > /dev/null; then
tac="tac"
else
tac="tail -r"
fi
BUFFER=$(\history -n 1 | \
eval $tac | \
peco --query "$LBUFFER")
CURSOR=$#BUFFER
zle clear-screen
}
zle -N peco-select-history
bindkey '^r' peco-select-history
#zshrc zcompile
if [ $ZDOTDIR/.zshrc -nt $ZDOTDIR/.zshrc.zwc ]; then
zcompile $ZDOTDIR/.zshrc
fi
watch=(not me)\
# tmux auto start
is_screen_running() {
# tscreen also uses this varariable.
[ ! -z "$WINDOW" ]
}
is_tmux_runnning() {
[ ! -z "$TMUX" ]
}
is_screen_or_tmux_running() {
is_screen_running || is_tmux_runnning
}
shell_has_started_interactively() {
[ ! -z "$PS1" ]
}
resolve_alias() {
cmd="$1"
while \
whence "$cmd" >/dev/null 2>/dev/null \
&& [ "$(whence "$cmd")" != "$cmd" ]
do
cmd=$(whence "$cmd")
done
echo "$cmd"
}
if ! is_screen_or_tmux_running && shell_has_started_interactively; then
for cmd in tmux tscreen screen; do
if whence $cmd >/dev/null 2>/dev/null; then
$(resolve_alias "$cmd")
break
fi
done
fi
# go Path
export GOPATH="${HOME}/tests/go"
#export PATH=$PATH:$GOPATH/bin
# auto-fu
#source $ZDOTDIR/auto-fu.zsh/auto-fu.zsh
#function zle-line-init(){
# auto-fu-init
#}
zle -N zle-line-init
# 「-azfu-」を表示させないための記述
#zstyle ':auto-fu:var' postdisplay $''
#
bindkey '^D' delete-char-or-list
bindkey -r '^[^D'
unsetopt correct_all
unsetopt correct
setopt noclobber
function ssh() {
if [ "$(ps -p $(ps -p $$ -o ppid=) -o comm=)" = "tmux" ]; then
tmux rename-window ${@: -1} # <---- ここ
command ssh "$@"
tmux set-window-option automatic-rename "on" 1>/dev/null
else
command ssh "$@"
fi
}
if [ -e /usr/bin/xsel ]; then
alias pbcopy='xsel --clipboard --input'
alias pbpaste='xsel --clipboard --output'
alias tmux-copy='tmux save-buffer - | pbcopy'
fi
# virtualenv
export WORKON_HOME=$HOME/.virtualenvs
if [ -e /opt/local/bin/virtualenvwrapper.sh-2.7 ]; then
source /opt/local/bin/virtualenvwrapper.sh-2.7
fi