7 zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z} r:|[/]=* r:|=*'
8 zstyle ':completion:*' use-cache true
10 if [ -d "$HOME/.zfunc" ]; then
11 fpath=($HOME/.zfunc $fpath)
12 autoload -U ~/.zfunc/*(:t)
16 unfunction $f:t 2> /dev/null
21 if [ -f "$HOME/.ssh/known_hosts" ]; then
22 _cache_hosts=(`perl -ne 'if (/^([a-zA-Z0-9.-]+)/) { print "$1\n";}' ~/.ssh/known_hosts`)
33 setopt auto_param_keys
34 setopt auto_param_slash
35 setopt auto_remove_slash
38 setopt complete_aliases
45 setopt pushd_ignore_dups
47 setopt sh_file_expansion
48 setopt always_last_prompt
50 setopt hist_ignore_all_dups
51 setopt hist_ignore_space
52 setopt inc_append_history
55 function _we_are_in_gnu_screen () {
59 function _we_are_in_ssh_session () {
60 [[ -n "$SSH_CONNECTION" ]]
63 _prompt_base='%B[%n@%m] %{%(?.$fg[green].$fg[red])%}%#%{$reset_color%}%b '
64 if ( _we_are_in_gnu_screen ); then
65 # GNU Screen has a capability to set its window title by "ESC k
66 # {string} ESC \". We want to reset the title to `_' to show we
67 # aren't running any command now.
68 PROMPT=$'%{\ek_\e\\%}'$_prompt_base
73 function preexec() { # Hook
74 if { _we_are_in_gnu_screen } then
75 # Set the window title of GNU Screen.
76 local cmd=${1[(wr)^(*=*|sudo|nice|env|time|ssh|-*|[0-9]*)]}
81 function precmd() { # Hook
82 local dirinfo="$(print_directory_info $(pwd))"
88 RPROMPT="%U%~%u %U($dirinfo)%u";;
92 function print_directory_info() {
95 if [[ -r $absdir/.git ]] then
97 git branch --no-color 2>/dev/null \
98 | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'
100 elif [[ -r $absdir/.hg/branch ]] then
102 local hgbranch=`cat $absdir/.hg/branch`
103 if [[ -e $absdir/.hg/unpushed ]] then
109 elif [[ -d $absdir/_darcs ]] then
113 elif [[ -r $absdir/CVS/Repository ]] then
115 cat $absdir/CVS/Repository \
116 | sed -e 's!\([^/]*\).*!\1!'
120 if [[ $absdir = "/" ]] then
121 # This is the root directory so exit from the recursion.
124 # Recurse to the parent dir.
125 print_directory_info $(dirname $absdir)
133 if [[ $# -gt 0 ]]; then
134 percol_opts=("--query" "$1")
137 ps aux | percol "${percol_opts[@]}" | awk '{ print $2 }'
143 if [[ $1 =~ "^[^-]" ]]; then
148 ppgrep "${ppgrep_opts[@]}" | xargs kill "$@"
151 function percol_select_history() {
154 if which gtac >&/dev/null; then
156 elif which tac >&/dev/null; then
163 selected=$("${tac_cmd[@]}" "$HISTFILE" | \
164 sed 's/^: [0-9]*:[0-9]*;//' | \
165 awk 'seen[$0] {next} {seen[$0]++; print}' | \
166 percol --match-method regex --query "$LBUFFER")
167 if [[ $? -eq 0 ]]; then
169 CURSOR="$#BUFFER" # move cursor to the end of line
171 #zle accept-line # uncomment this to execute the selected one immediately.
176 if which percol >&/dev/null; then
177 zle -N percol_select_history
178 bindkey '^R' percol_select_history
181 HISTFILE="$HOME/.zhistory"
185 alias -g L="| $PAGER"
189 alias -g X="| hexdump -C"
197 alias ed='ed -p "ed> "'
200 alias mwget="wget --user-agent='Mozilla/1.4b'"
201 alias pstow="pushd /usr/local/stow"
202 alias w3m="w3m -O UTF-8"
203 alias w3mb="w3m -O UTF-8 -B"
204 alias pkgsrc="pushd /usr/pkgsrc"
205 alias man="LANG=C man"
207 alias aria-emacs="ssh -f -X admin@aria.cielonegro.org emacsclient -c"
208 alias pho-dev-boinc="ssh -f -X pho@pho.dev.office.ymir.co.jp env LANG=C /home/pho/var/BOINC/run_manager"
210 if [ $(hostname) = "aria.cielonegro.org" ]; then
211 alias safari="open -a Safari"
212 alias unstuff='open -a StuffIt\ Expander.app'
213 alias pa='open -a NiseRingo.app'
214 alias heboris='open /Applications/HeborisUEMac/exe/Heboris\ OpenGL.app'
215 alias hengband='open ~/Applications/hengband*/Hengband*'
216 alias syssleep='sudo shutdown -s now'
219 if [[ $(uname) = "Darwin" ]]; then
227 alias top='/usr/bin/top -X -o cpu'
237 "Darwin" | "FreeBSD" | "NetBSD")
240 if [[ -f "/etc/redhat-release" ]]; then
241 cat "/etc/redhat-release"
242 elif [[ -f "/etc/SuSE-release" ]]; then
243 cat "/etc/SuSE-release"
245 echo -n "$0: I know this is "$(uname -o)" but " >&2
246 echo "have no idea about its distribution." >&2
250 echo "$0: Failed to detect the OS name." >&2
255 # The following lines were added by compinstall
257 zstyle :compinstall filename "$HOME/.zshrc"
261 # End of lines added by compinstall
263 if ( _we_are_in_gnu_screen ); then
264 # When we are in a GNU Screen session...
266 if ( _we_are_in_ssh_session ); then
267 # Propagate remote session's bells to the local one.
271 if [ -e ".motd" ]; then
275 # Run "fortune" if we aren't in a GNU Screen session.
276 if which fortune 2>&1 >/dev/null; then
281 if which ssh-agent-manager 2>&1 >/dev/null; then
282 eval `ssh-agent-manager -s`