-
Notifications
You must be signed in to change notification settings - Fork 1
/
zshrc
170 lines (144 loc) · 4.66 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
# -*- mode: shell-script; coding:utf-8 -*-
#-----------------------------------------------
# load dev env config
#-----------------------------------------------
# share screen session with users in .dev_users
# if we load this config
[ -e ~/.devenvrc ] && source ~/.devenvrc
#-----------------------------------------------
# load user config
#-----------------------------------------------
[ -e ~/.zshrc-before ] && source ~/.zshrc-before
#-----------------------------------------------
# Set shell options
#-----------------------------------------------
autoload -U compinit
compinit -u
setopt auto_menu auto_cd correct auto_name_dirs auto_remove_slash
setopt extended_history hist_ignore_dups hist_ignore_space prompt_subst
setopt pushd_ignore_dups rm_star_silent sun_keyboard_hack
setopt extended_glob list_types no_beep always_last_prompt
setopt cdable_vars sh_word_split auto_param_keys
setopt promptcr print_eight_bit share_history
#-----------------------------------------------
# history
#-----------------------------------------------
HISTFILE="$HOME/.zhistory"
HISTSIZE=100000
SAVEHIST=100000
function history-all { history -E 1 }
#-----------------------------------------------
# emacs key bind
#-----------------------------------------------
bindkey -e
#-----------------------------------------------
# emacs key bind
#-----------------------------------------------
stty stop undef
#-----------------------------------------------
# ENV
#-----------------------------------------------
PATH=/usr/local/sbin:/usr/sbin:/sbin:$PATH:$HOME/bin
export EDITOR=vim
export AUTHOR="lazy people C<< <info __at__ lazy-people.org> >>"
export LANG="ja_JP.UTF-8"
export LC_CTYPE="ja_JP.UTF-8"
export LC_COLORS='di=01;37;40;'
export PERL_AUTOINSTALL="--defaultdeps"
export LESSCHARSET=utf-8
export GTAGSLABEL=pygments
#-----------------------------------------------
# ブランチ情報表示
#-----------------------------------------------
# VCSの情報を取得するzshの便利関数 vcs_infoを使う
autoload -Uz vcs_info
# 表示フォーマットの指定
# %b ブランチ情報
# %a アクション名(mergeなど)
zstyle ':vcs_info:*' formats '[%b]'
zstyle ':vcs_info:*' actionformats '[%b|%a]'
precmd () {
psvar=()
LANG=en_US.UTF-8 vcs_info
[[ -n "$vcs_info_msg_0_" ]] && psvar[1]="$vcs_info_msg_0_"
}
#-----------------------------------------------
# PROMPT
#-----------------------------------------------
HOSTNAME=`hostname`
PROMPT="[%{[01;32m%}${USER}@$HOSTNAME%{[m%}] %(!.#.$) "
RPROMPT="%1(v|%F{green}%1v%f|) [%{[01;32m%}%~%{[m%}]"
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
#-----------------------------------------------
# alias
#-----------------------------------------------
case "${OSTYPE}" in
freebsd*|darwin*)
alias ls="ls -vG"
;;
linux*)
alias ls="ls --color"
;;
esac
alias screen="screen -O -U"
alias cattest="CATALYST_DEBUG=0 prove --lib lib t"
alias cattestpod="CATALYST_DEBUG=0 TEST_POD=1 prove --lib lib t"
alias svndiff="svn diff | vless"
alias ducks='du -cks * |sort -rn |head -11'
alias ducms='du -cms * |sort -rn |head -11'
alias ducgs='du -cgs * |sort -rn |head -11'
alias egrep='egrep --color'
#-----------------------------------------------
# ファイル検索
# http://d.hatena.ne.jp/hirose31/20090422/1240377735
#-----------------------------------------------
iname() {
find . -type d -name .svn -prune -o \( -iname "*$1*" -print \)
}
#-----------------------------------------------
# screen の下のラインに打ったコマンドを表示
#-----------------------------------------------
if [ "$TERM" = "screen" ]; then
# chpwd () { echo -n "_`dirs`\\" && ls -l }
chpwd () { echo -n "_`dirs`\\" }
preexec() {
# see [zsh-workers:13180]
# http://www.zsh.org/mla/workers/2000/msg03993.html
emulate -L zsh
local -a cmd; cmd=(${(z)2})
case $cmd[1] in
fg)
if (( $#cmd == 1 )); then
cmd=(builtin jobs -l %+)
else
cmd=(builtin jobs -l $cmd[2])
fi
;;
%*)
cmd=(builtin jobs -l $cmd[1])
;;
cd)
if (( $#cmd == 2)); then
cmd[1]=$cmd[2]
fi
;&
*)
echo -n "k$cmd[1]:t\\"
return
;;
esac
local -A jt; jt=(${(kv)jobtexts})
$cmd >>(read num rest
cmd=(${(z)${(e):-\$jt$num}})
echo -n "k$cmd[1]:t\\") 2>/dev/null
}
chpwd
fi
#-----------------------------------------------
# load zsh scripts
#-----------------------------------------------
[ -e ~/.zsh.d ] && source ~/.zsh.d/*
#-----------------------------------------------
# load user config
#-----------------------------------------------
[ -e ~/.zshrc-after ] && source ~/.zshrc-after