initial checkin
[zsh-lovers.git] / zsh_people / zyrnix / zshrc
1 #!/usr/bin/zsh
2 # -*- mode: shell-script -*-
3
4 # In Emacs, use M-x folding.  Quick reference:
5 #
6 # Show all sections' text 'C-c @ C-o'
7 # Hide all sections' text 'C-c @ C-w'
8 # Show a section's text   'C-c @ C-s'
9 # Hide a section's text   'C-c @ C-x'
10
11 # {{{ zstyle completions
12
13 ## These next 2 lines are from compinstall.
14 zstyle ':completion:*' completer _expand _complete _correct _approximate
15 zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
16
17 zstyle ':completion:*:options' description 'yes'
18 zstyle ':completion:*:options' auto-description '%d'
19
20 ## All of the following zstyles are from:
21 ## (http://www.zshwiki.org/cgi-bin/wiki.pl?ZshCompletionTips)
22
23 ### Use cache
24 ## Some functions, like _apt and _dpkg, are very slow. You can use a cache in
25 ## order to proxy the list of results (like the list of available debian
26 ## packages)
27 zstyle ':completion:*' use-cache on
28 zstyle ':completion:*' cache-path ~/.zsh/cache
29
30 ## Prevent CVS files/directories from being completed
31 zstyle ':completion:*:(all-|)files' ignored-patterns '(|*/)CVS'
32 zstyle ':completion:*:cd:*' ignored-patterns '(*/)#CVS'
33
34 # Allow zsh to complete on hostnames found in common config files.
35 local _myhosts;
36 _myhosts=( ${${=${${(f)"$(cat {/etc/ssh_,~/.ssh/known_}hosts(|2)(N) /dev/null)"}%%[# ]*}//,/ }:#\!*}
37            ${=${(f)"$(cat /etc/hosts(|)(N) <<(ypcat hosts 2>/dev/null))"}%%\#*}
38          );
39 zstyle ':completion:*' hosts $_myhosts;
40
41 ## With commands like `rm' it's annoying if one gets offered the same filename
42 ## again even if it is already on the command line. To avoid that:
43 #
44 zstyle ':completion:*:rm:*' ignore-line yes
45
46 ## Load the completion module.
47 zstyle :compinstall filename '/home/zyrnix/.zshrc'
48 autoload -U compinit
49 compinit
50
51 # }}}
52 # {{{ PS1 prompt
53
54 # Enable this for a nice interactive way to get a decent prompt.
55 # autoload -U promptinit
56 # promptinit
57 # prompt adam1
58 ## At the command line, you can do this to see the various prompts:
59 # prompt -l # display all
60 # prompt -h # help
61
62 # This is based on adam1 from promptinit.  I altered it so it includes a
63 # history number and return code.  It does not truncate the path.
64 #
65 # It looks like this (with colors):
66 # 384 zyrnix@server ~/tmp %
67 #
68 PS1=$'%h %{\e[22;44m%}%n@%m%{\e[00m%} %{\e[01;36m%}%0~%{\e[01;37m%} %# %{\e[00m%}'
69
70 # }}}
71 # {{{ xterm tweaks
72
73 ## FAQ 3.5 How do I get the meta key to work on my xterm?
74 ## http://zsh.sourceforge.net/FAQ/zshfaq03.html#l21
75 [[ $TERM = "xterm" ]] && stty pass8 && bindkey -me
76
77 ## FAQ 3.6 How do I automatically display the directory in my xterm title bar?
78 ## http://zsh.sourceforge.net/FAQ/zshfaq03.html#l22
79 ##
80 ## I modified the xterm version because it was too plain.
81 chpwd() {
82   [[ -t 1 ]] || return
83   case $TERM in
84     sun-cmd) print -Pn "\e]l%~\e\\"
85       ;;
86     *xterm*|rxvt|(dt|k|E)term) print -Pn "\e]2;% [zsh $ZSH_VERSION] %n@%m: %~\a"
87       ;;
88   esac
89 }
90
91 # }}}
92 # {{{ Zsh FAQ entries
93
94 ## FAQ 3.18: Why does zsh kill off all my background jobs when I logout?
95 ## http://zsh.sourceforge.net/FAQ/zshfaq03.html#l34
96 # setopt nohup
97 #
98 ## Or start jobs with &! instead of & to disown them
99 ## (disown = don't kill at logout)
100
101 ## FAQ 3.21: Why is my history not being saved?
102 ## http://zsh.sourceforge.net/FAQ/zshfaq03.html#l37
103 ##
104 ## I modified this to allow for 2,000 entries instead of 200.
105 HISTSIZE=2000
106 HISTFILE=~/.zsh_history
107 SAVEHIST=2000
108
109 ## FAQ 3.23: How do I prevent the prompt overwriting output when there is no
110 ##           newline?
111 ## http://zsh.sourceforge.net/FAQ/zshfaq03.html#l39
112 ##
113 ## According to the manual, this prevents multi-line editing because the editor
114 ## does not know where the start of the line appears.
115 ##
116 # unsetopt prompt_cr
117
118 # }}}
119 # {{{ General setopts
120
121 ## Don't clobber files by default.  Force myself to use >! or >| and >>! or >>|
122 ## to clobber the file
123 unsetopt clobber
124
125 ## I use dvorak, so correct spelling mistakes that a dvorak user would make
126 setopt dvorak
127
128 ## Extended history.
129 ## Instead of just a list of commands, append it with this:
130 ## `:<beginning time since epoch>:<elapsed seconds>:<command>'.
131 setopt extended_history
132
133 ## Automatically append directories to the push/pop list
134 setopt auto_pushd
135
136 ## Maximum size of the directory stack
137 DIRSTACKSIZE=50
138
139 ## Allow for 10MB max coredumps
140 limit coredumpsize 10m
141
142 # }}}
143 # {{{ Emacs compatibility
144
145 ## FAQ 3.10: Why does zsh not work in an Emacs shell mode any more?
146 ## http://zsh.sourceforge.net/FAQ/zshfaq03.html#l26
147 [[ $EMACS = t ]] && unsetopt zle
148
149 # Enable emacs keymap
150 bindkey -e
151
152 # From resolve (http://repose.cx/conf/.zshrc)
153 WORDCHARS=''                    # Emacs compatible M-b and M-f
154 bindkey "\C-w" kill-region      # Emacs C-w command support
155
156 # }}}
157 # {{{ Watch logins
158
159 ## Watch for logins and logouts from all accounts including mine.
160 watch=all
161
162 ## Watch every 30 seconds
163 logcheck=30
164
165 ## Change the watch format to something more informative
166 # %n = username, %M = hostname, %a = action, %l = tty, %T = time,
167 # %W = date
168 WATCHFMT="%n from %M has %a tty%l at %T %W"
169
170 # }}}
171 # {{{ Aliases
172
173 ## Aliases
174 alias ls="ls --color=auto"
175 alias targx="tar -zxvf"
176 alias targc="tar -cxvf"
177 alias tarbx="tar --bzip2 -xvf"
178 alias tarbc="tar --bzip2 -cvf"
179
180 # }}}
181 # {{{ Setopts from Resolve
182
183 ## From resolve's config (http://repose.cx/conf/.zshrc)
184 setopt extended_glob            # Weird & wacky pattern matching - yay zsh!
185 setopt complete_in_word         # Not just at the end
186 setopt always_to_end            # When complete from middle, move cursor
187 setopt correct                  # Spelling correction
188 setopt hist_verify              # When using ! cmds, confirm first
189 setopt interactive_comments     # Escape commands so I can use them later
190 setopt print_exit_value         # Alert me if something's failed
191
192 ## Anti-aliasing in the two toolkits
193 ## Use this type of assignment to set the variable if not already set
194 (( ${+QT_XFT} )) || export QT_XFT=1
195 (( ${+GDK_USE_XFT} )) || export GDK_USE_XFT=1
196
197 # }}}
198 # {{{ GNU Arch tagline - Do not edit this section
199
200 # To insert a uuid with Linux kernel 2.3.16 or newer, do:
201 # echo -e "\n# arch-tag: `cat /proc/sys/kernel/random/uuid`\n" >> file
202 #
203 # arch-tag: 223a17f5-7c19-4f32-8fa7-0c14054128be
204
205 # }}}