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