zshrc: provide upgrade path via /etc/skel/.zshrc
[grml-etc-core.git] / etc / skel / .zshrc
1 # Filename:      /etc/skel/.zshrc
2 # Purpose:       config file for zsh (z shell)
3 # Authors:       (c) grml-team (grml.org)
4 # Bug-Reports:   see http://grml.org/bugs/
5 # License:       This file is licensed under the GPL v2 or any later version.
6 ################################################################################
7 # Nowadays, grml's zsh setup lives in only *one* zshrc file.
8 # That is the global one: /etc/zsh/zshrc (from grml-etc-core).
9 # It is best to leave this file untouched and do personal changes to
10 # the setup via ${HOME}/.zshrc.local which is loaded at the end of the
11 # global zshrc.
12 #
13 # That way, we enable people on other operating systems to use our
14 # setup, too, just by copying our global zshrc to their ${HOME}/.zshrc.
15 # Adjustments would still go to the .zshrc.local file.
16 ################################################################################
17
18 ## Upgrade path for old zshrc layout, assuming
19 ## /etc/skel/.zshrc installed as .zshrc and
20 ## /etc/zsh/zshrc installed as .zshrc.global
21 ## and no ~/.zshrc.local exists yet.
22 if [ -r ~/.zshrc -a -r ~/.zshrc.global -a ! -r ~/.zshrc.local ] ; then
23     printf '-!-\n'
24     printf '-!- Looks like you are using the old zshrc layout of grml.\n'
25     printf '-!- Please read the notes in ~/.zshrc and ~/.zshrc.global\n'
26     printf '-!- and/or check out grml-zsh-refcard at http://grml.org/zsh/\n'
27     printf '-!-\n'
28 fi
29
30 ## Now, we'll give a few examples of what you might want to use in your
31 ## .zshrc.local file (just copy'n'paste and uncomment it there):
32
33 ## ZLE tweaks ##
34
35 ## use the vi navigation keys (hjkl) besides cursor keys in menu completion
36 #bindkey -M menuselect 'h' vi-backward-char        # left
37 #bindkey -M menuselect 'k' vi-up-line-or-history   # up
38 #bindkey -M menuselect 'l' vi-forward-char         # right
39 #bindkey -M menuselect 'j' vi-down-line-or-history # bottom
40
41 ## set command prediction from history, see 'man 1 zshcontrib'
42 #is4 && zrcautoload predict-on && \
43 #zle -N predict-on         && \
44 #zle -N predict-off        && \
45 #bindkey "^X^Z" predict-on && \
46 #bindkey "^Z" predict-off
47
48 ## press ctrl-q to quote line:
49 #mquote () {
50 #      zle beginning-of-line
51 #      zle forward-word
52 #      # RBUFFER="'$RBUFFER'"
53 #      RBUFFER=${(q)RBUFFER}
54 #      zle end-of-line
55 #}
56 #zle -N mquote && bindkey '^q' mquote
57
58 ## define word separators (for stuff like backward-word, forward-word, backward-kill-word,..)
59 #WORDCHARS='*?_-.[]~=/&;!#$%^(){}<>' # the default
60 #WORDCHARS=.
61 #WORDCHARS='*?_[]~=&;!#$%^(){}'
62 #WORDCHARS='${WORDCHARS:s@/@}'
63
64
65 ## some popular options ##
66
67 ## add `|' to output redirections in the history
68 #setopt histallowclobber
69
70 ## warning if file exists ('cat /dev/null > ~/.zshrc')
71 #setopt NO_clobber
72
73 ## don't warn me about bg processes when exiting
74 #setopt nocheckjobs
75
76 ## alert me if something failed
77 #setopt printexitvalue
78
79 ## with spelling correction, assume dvorak kb
80 #setopt dvorak
81
82 ## Allow comments even in interactive shells
83 #setopt interactivecomments
84
85
86 ## compsys related snippets ##
87
88 ## changed completer settings
89 #zstyle ':completion:*' completer _complete _correct _approximate
90 #zstyle ':completion:*' expand prefix suffix
91
92 ## another different completer setting: expand shell aliases
93 #zstyle ':completion:*' completer _expand_alias _complete _approximate
94
95 ## to have more convenient account completion, specify your logins:
96 #my_accounts=(
97 # {grml,grml1}@foo.invalid
98 # grml-devel@bar.invalid
99 #)
100 #other_accounts=(
101 # {fred,root}@foo.invalid
102 # vera@bar.invalid
103 #)
104 #zstyle ':completion:*:my-accounts' users-hosts $my_accounts
105 #zstyle ':completion:*:other-accounts' users-hosts $other_accounts
106
107 ## telnet on non-default ports? ...well:
108 ## specify specific port/service settings:
109 #telnet_users_hosts_ports=(
110 #  user1@host1:
111 #  user2@host2:
112 #  @mail-server:{smtp,pop3}
113 #  @news-server:nntp
114 #  @proxy-server:8000
115 #)
116 #zstyle ':completion:*:*:telnet:*' users-hosts-ports $telnet_users_hosts_ports
117
118 ## the default grml setup provides '..' as a completion. it does not provide
119 ## '.' though. If you want that too, use the following line:
120 #zstyle ':completion:*' special-dirs true
121
122 ## aliases ##
123
124 ## translate
125 #alias u='translate -i'
126
127 ## ignore ~/.ssh/known_hosts entries
128 #alias insecssh='ssh -o "StrictHostKeyChecking=no" -o "UserKnownHostsFile=/dev/null" -o "PreferredAuthentications=keyboard-interactive"'
129
130 ## a variation of our man2 alias
131 #alias man2='MANPAGER="sed -e G |less" TERMINFO=~/.terminfo TERM=mostlike /usr/bin/man'
132
133
134 ## global aliases (for those who like them) ##
135
136 #alias -g '...'='../..'
137 #alias -g '....'='../../..'
138 #alias -g BG='& exit'
139 #alias -g C='|wc -l'
140 #alias -g G='|grep'
141 #alias -g H='|head'
142 #alias -g Hl=' --help |& less -r'
143 #alias -g K='|keep'
144 #alias -g L='|less'
145 #alias -g LL='|& less -r'
146 #alias -g M='|most'
147 #alias -g N='&>/dev/null'
148 #alias -g R='| tr A-z N-za-m'
149 #alias -g SL='| sort | less'
150 #alias -g S='| sort'
151 #alias -g T='|tail'
152 #alias -g V='| vim -'
153
154 ## miscellaneous code ##
155
156 ## Use a default width of 80 for manpages for more convenient reading
157 #export MANWIDTH=${MANWIDTH:-80}
158
159 ## Set a search path for the cd builtin
160 #cdpath=(.. ~)
161
162 ## variations of our manzsh() function; pick you poison:
163 #manzsh()  { /usr/bin/man zshall |  most +/"$1" ; }
164 #[[ -f ~/.terminfo/m/mostlike ]] && MYLESS='LESS=C TERMINFO=~/.terminfo TERM=mostlike less' || MYLESS='less'
165 #manzsh()  { man zshall | $MYLESS -p $1 ; }
166
167 ## Switching shell safely and efficiently? http://www.zsh.org/mla/workers/2001/msg02410.html
168 #bash() {
169 #    NO_SWITCH="yes" command bash "$@"
170 #}
171 #restart () {
172 #    exec $SHELL $SHELL_ARGS "$@"
173 #}
174
175 ## log out? set timeout in seconds...
176 ## ...and do not log out in some specific terminals:
177 #if [[ "${TERM}" == ([Exa]term*|rxvt|dtterm|screen*) ]] ; then
178 #    unset TMOUT
179 #else
180 #    TMOUT=1800
181 #fi
182
183 ## associate types and extensions (be aware with perl scripts and anwanted behaviour!)
184 #check_com zsh-mime-setup || { autoload zsh-mime-setup && zsh-mime-setup }
185 #alias -s pl='perl -S'
186
187 ## ctrl-s will no longer freeze the terminal.
188 #stty erase "^?"
189
190 ## you want to automatically use a bigger font on big terminals?
191 #if [[ "$TERM" == "xterm" ]] && [[ "$LINES" -ge 50 ]] && [[ "$COLUMNS" -ge 100 ]] && [[ -z "$SSH_CONNECTION" ]] ; then
192 #    large
193 #fi
194
195 ## Some quick Perl-hacks aka /useful/ oneliner
196 #bew() { perl -le 'print unpack "B*","'$1'"' }
197 #web() { perl -le 'print pack "B*","'$1'"' }
198 #hew() { perl -le 'print unpack "H*","'$1'"' }
199 #weh() { perl -le 'print pack "H*","'$1'"' }
200 #pversion()    { perl -M$1 -le "print $1->VERSION" } # i. e."pversion LWP -> 5.79"
201 #getlinks ()   { perl -ne 'while ( m/"((www|ftp|http):\/\/.*?)"/gc ) { print $1, "\n"; }' $* }
202 #gethrefs ()   { perl -ne 'while ( m/href="([^"]*)"/gc ) { print $1, "\n"; }' $* }
203 #getanames ()  { perl -ne 'while ( m/a name="([^"]*)"/gc ) { print $1, "\n"; }' $* }
204 #getforms ()   { perl -ne 'while ( m:(\</?(input|form|select|option).*?\>):gic ) { print $1, "\n"; }' $* }
205 #getstrings () { perl -ne 'while ( m/"(.*?)"/gc ) { print $1, "\n"; }' $*}
206 #getanchors () { perl -ne 'while ( m/«([^«»\n]+)»/gc ) { print $1, "\n"; }' $* }
207 #showINC ()    { perl -e 'for (@INC) { printf "%d %s\n", $i++, $_ }' }
208 #vimpm ()      { vim `perldoc -l $1 | sed -e 's/pod$/pm/'` }
209 #vimhelp ()    { vim -c "help $1" -c on -c "au! VimEnter *" }