a8f080a7d7c073cd6c5fd42631cb316169a8bb4e
[stack/conf/zsh.git] / zshrc.local
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 ## Settings for umask
34 #if (( EUID == 0 )); then
35 #    umask 002
36 #else
37 #    umask 022
38 #fi
39
40 ## Now, we'll give a few examples of what you might want to use in your
41 ## .zshrc.local file (just copy'n'paste and uncomment it there):
42
43 ## ZLE tweaks ##
44
45 ## use the vi navigation keys (hjkl) besides cursor keys in menu completion
46 #bindkey -M menuselect 'h' vi-backward-char        # left
47 #bindkey -M menuselect 'k' vi-up-line-or-history   # up
48 #bindkey -M menuselect 'l' vi-forward-char         # right
49 #bindkey -M menuselect 'j' vi-down-line-or-history # bottom
50
51 ## set command prediction from history, see 'man 1 zshcontrib'
52 #is4 && zrcautoload predict-on && \
53 #zle -N predict-on         && \
54 #zle -N predict-off        && \
55 #bindkey "^X^Z" predict-on && \
56 #bindkey "^Z" predict-off
57
58 ## press ctrl-q to quote line:
59 #mquote () {
60 #      zle beginning-of-line
61 #      zle forward-word
62 #      # RBUFFER="'$RBUFFER'"
63 #      RBUFFER=${(q)RBUFFER}
64 #      zle end-of-line
65 #}
66 #zle -N mquote && bindkey '^q' mquote
67
68 ## define word separators (for stuff like backward-word, forward-word, backward-kill-word,..)
69 #WORDCHARS='*?_-.[]~=/&;!#$%^(){}<>' # the default
70 #WORDCHARS=.
71 #WORDCHARS='*?_[]~=&;!#$%^(){}'
72 #WORDCHARS='${WORDCHARS:s@/@}'
73
74 # just type '...' to get '../..'
75 #rationalise-dot() {
76 #local MATCH
77 #if [[ $LBUFFER =~ '(^|/| |     |'$'\n''|\||;|&)\.\.$' ]]; then
78 #  LBUFFER+=/
79 #  zle self-insert
80 #  zle self-insert
81 #else
82 #  zle self-insert
83 #fi
84 #}
85 #zle -N rationalise-dot
86 #bindkey . rationalise-dot
87 ## without this, typing a . aborts incremental history search
88 #bindkey -M isearch . self-insert
89
90 #bindkey '\eq' push-line-or-edit
91
92 ## some popular options ##
93
94 ## add `|' to output redirections in the history
95 #setopt histallowclobber
96
97 ## warning if file exists ('cat /dev/null > ~/.zshrc')
98 #setopt NO_clobber
99
100 ## don't warn me about bg processes when exiting
101 #setopt nocheckjobs
102
103 ## alert me if something failed
104 #setopt printexitvalue
105
106 ## with spelling correction, assume dvorak kb
107 #setopt dvorak
108
109 ## Allow comments even in interactive shells
110 #setopt interactivecomments
111
112
113 ## compsys related snippets ##
114
115 ## changed completer settings
116 #zstyle ':completion:*' completer _complete _correct _approximate
117 #zstyle ':completion:*' expand prefix suffix
118
119 ## another different completer setting: expand shell aliases
120 #zstyle ':completion:*' completer _expand_alias _complete _approximate
121
122 ## to have more convenient account completion, specify your logins:
123 #my_accounts=(
124 # {grml,grml1}@foo.invalid
125 # grml-devel@bar.invalid
126 #)
127 #other_accounts=(
128 # {fred,root}@foo.invalid
129 # vera@bar.invalid
130 #)
131 #zstyle ':completion:*:my-accounts' users-hosts $my_accounts
132 #zstyle ':completion:*:other-accounts' users-hosts $other_accounts
133
134 ## telnet on non-default ports? ...well:
135 ## specify specific port/service settings:
136 #telnet_users_hosts_ports=(
137 #  user1@host1:
138 #  user2@host2:
139 #  @mail-server:{smtp,pop3}
140 #  @news-server:nntp
141 #  @proxy-server:8000
142 #)
143 #zstyle ':completion:*:*:telnet:*' users-hosts-ports $telnet_users_hosts_ports
144
145 ## the default grml setup provides '..' as a completion. it does not provide
146 ## '.' though. If you want that too, use the following line:
147 zstyle ':completion:*' special-dirs true
148 zstyle -e ':completion:*' special-dirs '[[ $PREFIX = (../)#(|.|..) ]] && reply=(..)'
149
150 ## aliases ##
151
152 ## translate
153 #alias u='translate -i'
154
155 ## ignore ~/.ssh/known_hosts entries
156 #alias insecssh='ssh -o "StrictHostKeyChecking=no" -o "UserKnownHostsFile=/dev/null" -o "PreferredAuthentications=keyboard-interactive"'
157
158
159 ## global aliases (for those who like them) ##
160
161 #alias -g '...'='../..'
162 #alias -g '....'='../../..'
163 #alias -g BG='& exit'
164 #alias -g C='|wc -l'
165 #alias -g G='|grep'
166 #alias -g H='|head'
167 #alias -g Hl=' --help |& less -r'
168 #alias -g K='|keep'
169 #alias -g L='|less'
170 #alias -g LL='|& less -r'
171 #alias -g M='|most'
172 #alias -g N='&>/dev/null'
173 #alias -g R='| tr A-z N-za-m'
174 #alias -g SL='| sort | less'
175 #alias -g S='| sort'
176 #alias -g T='|tail'
177 #alias -g V='| vim -'
178 alias -g emc='emacsclient -c'
179
180 ## instead of global aliase it might be better to use grmls $abk assoc array, whose contents are expanded after pressing ,.
181 #$abk[SnL]="| sort -n | less"
182
183 ## get top 10 shell commands:
184 #alias top10='print -l ${(o)history%% *} | uniq -c | sort -nr | head -n 10'
185
186 ## Execute \kbd{./configure}
187 #alias CO="./configure"
188
189 ## Execute \kbd{./configure --help}
190 #alias CH="./configure --help"
191
192 ## miscellaneous code ##
193
194 ## Use a default width of 80 for manpages for more convenient reading
195 export MANWIDTH=${MANWIDTH:-80}
196
197 ## Set a search path for the cd builtin
198 #cdpath=(.. ~)
199
200 ## variation of our manzsh() function; pick you poison:
201 #manzsh()  { /usr/bin/man zshall |  most +/"$1" ; }
202
203 ## Switching shell safely and efficiently? http://www.zsh.org/mla/workers/2001/msg02410.html
204 #bash() {
205 #    NO_SWITCH="yes" command bash "$@"
206 #}
207 #restart () {
208 #    exec $SHELL $SHELL_ARGS "$@"
209 #}
210
211 ## Handy functions for use with the (e::) globbing qualifier (like nt)
212 #contains() { grep -q "$*" $REPLY }
213 #sameas() { diff -q "$*" $REPLY &>/dev/null }
214 #ot () { [[ $REPLY -ot ${~1} ]] }
215
216 ## get_ic() - queries imap servers for capabilities; real simple. no imaps
217 #ic_get() {
218 #    emulate -L zsh
219 #    local port
220 #    if [[ ! -z $1 ]] ; then
221 #        port=${2:-143}
222 #        print "querying imap server on $1:${port}...\n";
223 #        print "a1 capability\na2 logout\n" | nc $1 ${port}
224 #    else
225 #        print "usage:\n  $0 <imap-server> [port]"
226 #    fi
227 #}
228
229 ## List all occurrences of programm in current PATH
230 #plap() {
231 #    emulate -L zsh
232 #    if [[ $# = 0 ]] ; then
233 #        echo "Usage:    $0 program"
234 #        echo "Example:  $0 zsh"
235 #        echo "Lists all occurrences of program in the current PATH."
236 #    else
237 #        ls -l ${^path}/*$1*(*N)
238 #    fi
239 #}
240
241 ## Find out which libs define a symbol
242 #lcheck() {
243 #    if [[ -n "$1" ]] ; then
244 #        nm -go /usr/lib/lib*.a 2>/dev/null | grep ":[[:xdigit:]]\{8\} . .*$1"
245 #    else
246 #        echo "Usage: lcheck <function>" >&2
247 #    fi
248 #}
249
250 ## Download a file and display it locally
251 #uopen() {
252 #    emulate -L zsh
253 #    if ! [[ -n "$1" ]] ; then
254 #        print "Usage: uopen \$URL/\$file">&2
255 #        return 1
256 #    else
257 #        FILE=$1
258 #        MIME=$(curl --head $FILE | \
259 #               grep Content-Type | \
260 #               cut -d ' ' -f 2 | \
261 #               cut -d\; -f 1)
262 #        MIME=${MIME%$'\r'}
263 #        curl $FILE | see ${MIME}:-
264 #    fi
265 #}
266
267 ## Memory overview
268 #memusage() {
269 #    ps aux | awk '{if (NR > 1) print $5;
270 #                   if (NR > 2) print "+"}
271 #                   END { print "p" }' | dc
272 #}
273
274 ## print hex value of a number
275 #hex() {
276 #    emulate -L zsh
277 #    if [[ -n "$1" ]]; then
278 #        printf "%x\n" $1
279 #    else
280 #        print 'Usage: hex <number-to-convert>'
281 #        return 1
282 #    fi
283 #}
284
285 ## log out? set timeout in seconds...
286 ## ...and do not log out in some specific terminals:
287 #if [[ "${TERM}" == ([Exa]term*|rxvt|dtterm|screen*) ]] ; then
288 #    unset TMOUT
289 #else
290 #    TMOUT=1800
291 #fi
292
293 ## associate types and extensions (be aware with perl scripts and anwanted behaviour!)
294 #check_com zsh-mime-setup || { autoload zsh-mime-setup && zsh-mime-setup }
295 #alias -s pl='perl -S'
296
297 ## ctrl-s will no longer freeze the terminal.
298 #stty erase "^?"
299
300 ## you want to automatically use a bigger font on big terminals?
301 #if [[ "$TERM" == "xterm" ]] && [[ "$LINES" -ge 50 ]] && [[ "$COLUMNS" -ge 100 ]] && [[ -z "$SSH_CONNECTION" ]] ; then
302 #    large
303 #fi
304
305 if [ -e /usr/share/terminfo/x/xterm-256color ]; then
306     export TERM='xterm-256color'
307 else
308     export TERM='xterm-color'
309 fi
310 ## Some quick Perl-hacks aka /useful/ oneliner
311 #bew() { perl -le 'print unpack "B*","'$1'"' }
312 #web() { perl -le 'print pack "B*","'$1'"' }
313 #hew() { perl -le 'print unpack "H*","'$1'"' }
314 #weh() { perl -le 'print pack "H*","'$1'"' }
315 #pversion()    { perl -M$1 -le "print $1->VERSION" } # i. e."pversion LWP -> 5.79"
316 #getlinks ()   { perl -ne 'while ( m/"((www|ftp|http):\/\/.*?)"/gc ) { print $1, "\n"; }' $* }
317 #gethrefs ()   { perl -ne 'while ( m/href="([^"]*)"/gc ) { print $1, "\n"; }' $* }
318 #getanames ()  { perl -ne 'while ( m/a name="([^"]*)"/gc ) { print $1, "\n"; }' $* }
319 #getforms ()   { perl -ne 'while ( m:(\</?(input|form|select|option).*?\>):gic ) { print $1, "\n"; }' $* }
320 #getstrings () { perl -ne 'while ( m/"(.*?)"/gc ) { print $1, "\n"; }' $*}
321 #getanchors () { perl -ne 'while ( m/«([^«»\n]+)»/gc ) { print $1, "\n"; }' $* }
322 #showINC ()    { perl -e 'for (@INC) { printf "%d %s\n", $i++, $_ }' }
323 #vimpm ()      { vim `perldoc -l $1 | sed -e 's/pod$/pm/'` }
324 #vimhelp ()    { vim -c "help $1" -c on -c "au! VimEnter *" }
325
326 ## END OF FILE #################################################################
327
328 export pd() { egrep -i "[aeiou]to\$" /usr/share/dict/italian | shuf ${${1/-1/}:+-n $1} | while read W; do curl -A Mozilla "$@" "translate.google.com/translate_tts" -d "tl=it&q=dio $W" | mpg123 -; done }
329 source `dirname $(readlink $0)`/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
330