######################################################################## # file: $HOME/.zshrc.forall # available: http://www.guckes.net/setup/zshrc.forall # written by: Sven Guckes setup-zshrc.forall(at)guckes.net # purpose: setup file for the shell "zsh" # adapted for hostsharing.net # Latest change: Tue Oct 04 18:42:23 CEST 2016 ######################################################################## # # View this file in color! Open this file in the editor "vim" # and enter the command ":source $VIM/syntax/zsh.vim". # More info about Vim is available at http://www.vim.org/ # identify Sven's home directory: # antilope - until 2007-05-09: # HOMEGUCKES=/home/www/guckes # kudu - since 2007-05-09: HOMEGUCKES=/home/user/guckes # Installation: # Create the file $HOME/.zshrc and add this line: # source $HOMEGUCKES/.zshrc.forall # To use Sven's setup just copy his .zshrc file to your $HOME: # # cp $HOMEGUCKES/.zshrc ~ # That's all. STATUS=start # This very setup file: SETUPFILE="$HOMEGUCKES/.zshrc.forall" # set autocd export COLORTERM=yes export LINKS_XTERM=screen CC=gcc # setting some values - for later use # OS=${OSTYPE%%[0-9.]*} # OSVERSION=${OSTYPE#$OS} # OSMAJOR=${OSVERSION%%.*} # export OS OSVERSION OSMAJOR HOST # ==================================================================== # The "prompt" of the shell. # See "man zsh" -> " # %B Bold ON # %n $USERNAME. # %b Bold OFF # @ literal '@' # %m machine name. # : literal ':' # %Nc "relative path", ie last N components of $PWD. # > literal '>' # alias ____='echo "X[mX(BX)0OX[?5lX7X[rX8" | tr 'XO' '\033\017'' # PS1string='%B%n%b@%m:%4c>' # alias _prompt='PS1=$PS1string' # _prompt # alias _PS1="PS1='%B%n%b@%m:%4c>'" # _PS1 # PS1="%B%n%b@%m:%4c>" # without bold on/off: PS1="%n@%m:%4c> " # ==================================================================== # # Adjustments for Linux hosts: # if [[ `uname -s` == "Linux" ]] # then # echo "LINUX detected - may the penguin be with you" # # else # # echo "WARNING: probably not a linux machine" # # exec bash # fi # # if [[ `uname -s` == "SunOS" ]] # then # echo "SunOS - beware\!" # fi # SCREENDIR - screws up "screen" on Linux # unset SCREENDIR # Email, Mailers, Mail User Agents # Mail stuff: # MAILDIR=/var/mail # MAIL=$MAILDIR/$USER # # this system uses "home spool", # ie the mailbox is placed into # the $HOME directory as # $HOME/Maildir/ # MAIL=$HOME/Maildir/ # 2007-06-27 in-berlin has switched to homespool MAIL=$HOME/Mail.IN/INBOX # News/Usenet setup for newsreaders. # 2003-01-03,2003-06-16: # export NNTPSERVER=news.fu-berlin.de # 2003-11-01: # export NNTPSERVER=News.CIS.DFN.DE # 2004-02-16: name changed! # export NNTPSERVER=news.individual.net # 2006-07-31 export NNTPSERVER=news.vr.in-berlin.de # 2003-08-28: # For the text editor "elvis" (a vi clone): # export ELVISPATH=$HOMEGUCKES/.elvislib # ============================================================== # The PATH - list of directories to search for executable files. # ============================================================== # 2003-10-27: # $ echo $PATH # /usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games # prepend personal "bin" dir and "scripts": # PATH=$HOMEGUCKES/bin:$HOMEGUCKES/scripts:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games # alias def_path='/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games' # 2020-03-06: PATHDEFAULTMYUSER=$HOMEGUCKES/bin:$HOMEGUCKES/scripts:$HOMEGUCKES/.local/bin/ PATHDEFAULTSYSTEM=/bin:/usr/local/bin:/usr/bin:/usr/games # /usr/bin/X11 removed. seems redundant. PATHDEFAULT=$PATHDEFAULTMYUSER:$PATHDEFAULTSYSTEM PATH=$PATHDEFAULT alias pathreset="PATH=$PATHDEFAULT" # for the "man" command: # 2003-10-27: manual directories # found on this system: # /usr/share/man # /usr/share/man/de/ # 2017-01-23 adding ".:./doc:./man:" export MANPATH=.:./doc:./man:$HOMEGUCKES/man:/usr/share/man:/usr/share/man/de/:/usr/X11R6/man/ unset TERMCAP # export TERMINFO=/import/mlocal/share/terminfo export TERMINFO=$HOMEGUCKES/.terminfo # some setup file explicitly sets the value of TERM. # and this just cannot work when you "dial in" from # different kinds of terminals. anyway, usually # "TERM=xterm" works quite well. # TERM=xterm ########### # OPTIONS # ########### # 980622 setopt completeinword # 980622 # The http_proxy does not always seem to work. :-( unset http_proxy # Define the http proxy for web browsers: # export http_proxy=http://http-proxy.fu-berlin.de:80/ # export http_proxy=http://proxy.prz.tu-berlin.de:3128/ # "less" - see http://www.guckes.net/less/ export LESS=aCeiMs # export LESSCHARSET=latin1 export LESSCHARSET=utf-8 # 2016-10-04 # exclude the following file patterns from globbing: fignore=(% .BAK .sw) # "screen": Use subdir of homedir to put screen session # so you can see running screen session on other hosts, too. # export SCREENDIR=~/.Screens # Color for 'gls' (GNU ls): export LS_COLORS='no=0:fi=0:di=32:ln=36:or=1;40:mi=1;40:pi=31:so=33:bd=44;37:cd=44;37:ex=35:*.jpg=1;32:*.jpeg=1;32:*.JPG=1;32:*.gif=1;32:*.png=1;32:*.jpeg=1;32:*.ppm=1;32:*.pgm=1;32:*.pbm=1;32:*.c=1;33:*.C=1;33:*.h=1;33:*.cc=1;33:*.awk=1;33:*.pl=1;33:*.bz2=1;35:*.gz=1;31:*.tar=1;31:*.zip=1;31:*.lha=1;31:*.lzh=1;31:*.arj=1;31:*.tgz=1;31:*.taz=1;31:*.html=1;34:*.htm=1;34:*.doc=1;34:*.txt=1;34:*.o=1;36:*.a=1;36:*.php3=1;31' # COLORS: (see output of "dircolors -p") # Attributes: 00=none 01=bold # 04=underscore 05=blink # 07=reverse 08=concealed # Foreground: 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white # Background: 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white # Set the erase character to "backspace" (control-h): # stty erase  # Prevent creation of core" file by limiting their size to zero: # limit coredumpsize 0 # Set the "umask" (see "man umask"): # Should create files with permissions "rw-------", # ie read and write for the owner only. umask 066 ########### # ALIASES # ########### alias ..='cd ..' alias ...='cd ../..' # Quick access to Sven's setup file: # _ssetup: "souce setup" - read in Sven's setup file: alias _ssetup="source $SETUPFILE" # _vsetup: "view setup" - look at Sven's setup file: alias _vsetup="$PAGER $SETUPFILE" # Quick access to editing your own setup file: alias __='$EDITOR ~/.zshrc' # Quick update of complete setup: alias ___='TEST=foo;source ~/.zshrc;TEST=' alias a=alias alias ua=unalias alias dirs='dirs -v' # history # alias h='fc -ldD -1024 | less +G' # no argument: show full history. # one argument: show lines which contain argument h() { if [ -z "$*" ]; then history 1; else history 1 | egrep "$@"; fi; } # l: "look at (file)" alias l='$PAGER' alias wh='whence -a' # LaTeX etc alias sho='xdvi -s 2 -expert -geometry 1010x900+30+1030' alias _dvishow='xdvi -s 3 -expert -geometry 990x990' # UNIX: ls # del - "delete" (loeschen) alias del=rm # dir - "directory" (Verzeichnis ansehen) alias dir='/bin/ls -l' # la - "list all (ie dot files)" - # zeigt auch Dateien mit Punkt am Anfang an alias la='/bin/ls -a' # lg - "list (with) group" - zeigt auch Information # ueber die Gruppenzugehoerigkeit der Dateien alias lg='/bin/ls -lag' # ll - "List long" - zeigt Datein im "langen" Format alias ll='/bin/ls -l' # alias ls='gls -CFG' # lsd - "list directories" - shows subdirectories # alias lsd='ls -adCG *(/)' # alias lsd='gls --color -adCF *(/)' alias lsd='/bin/ls -adCF *(/)' # alias lld='/bin/ls -adCFl *(/)' function lld () { /bin/ls -adCFl ${1:=*(/)} } # lsdir - same as "lsd" alias lsdir=lsd alias lsdnew='/bin/ls -adCFrt *(/) | tail' alias lldnew='/bin/ls -adCFrtl *(/) | tail' alias lsdold='/bin/ls -adCFt *(/) | tail' alias lldold='/bin/ls -adCFtl *(/) | tail' # lsf - "list files" - shows files *only* alias lsf='/bin/ls --color -adCF *(.)' alias llf='/bin/ls --color -adCFl *(.)' alias llh='/bin/ls --color -lh' # list *the* newest file/directory: alias llfn='/bin/ls -l *(.om[1])' alias lldn='/bin/ls -ld *(/om[1])' alias cdn='cd *(/om[1])' # alias lsnew='ls -tl | head' alias lsfnew='/bin/ls -rt *(.) | tail ' alias llfnew='/bin/ls -rtl *(.) | tail ' alias lsfold='/bin/ls -t *(.) | tail ' alias llfold='/bin/ls -tl *(.) | tail ' # lsdots - "list dot files" - zeigt nur Dateien, # die mit einem Punkt beginnen alias lsdots='/bin/ls -adCG .*(.)' alias lldots='/bin/ls -adCGl .*(.)' # lsbig - "list big files" - zeigt die zehn groessten Dateien an # "lsbig -20" - zeigt die 20 groessten Dateien an # alias lsbig='ls -S *(.) | head' # alias lsfbig='ls -S *(.) | head' # alias llbig='ls -lS *(.) | head' # alias llfbig='ls -lS *(.) | head' # 2009-08-24, 2014-06-10 # changed to functions - with "$*" # to add possible parameters, eg "-h": function lsbig { ls -S *(.) | head $* } function lsfbig { ls -S *(.) | head $* } function llbig { ls -lS *(.) | head $* } function llfbig { ls -lS *(.) | head $* } function llhbig { ls -lhS *(.) | head $* } # # 2014-06-10 # lssmall - "list small files" # example: "lssmall -23" - shows the 23 smallest files # alias lssmall='ls -S | tail' # alias llsmall='ls -Sl | tail' function lssmall { ls -S *(.) | tail $* } function llsmall { ls -lS *(.) | tail $* } # function lsnew {ls -tl $* | head } # alias lsold='ls -tl | tail' alias md='mkdir' # alias mv='gmv -i' alias p='pushd' # path: show the value of PATH alias path='echo $PATH' alias pd='popd' alias rd='rmdir' alias rm='rm -i' ############################################ # SPECIAL PROGRAMS ############################################ # 2004-06-28, 2004-07-06 # alias c='screen centericq -a' # alias c='screen -t ICQ 9 centericq -a' # _revtime = reverse time (from number to "date") function _revtime { perl -e "print scalar localtime $1" } # _V : show current version numbers function _V { lynx -dump ~/.P/faq/program.versions.html | grep $1 } # man: Use the GNU man as it understands "man -w foo" # alias man='/import/pub/bin/man' # Tell "lpq" to work as if on a vt100 terminal. # Silly workaround as lpq segfaults on "TERM=screen". :-( # alias lpq='TERM=vt100 lpq' # FIGLET: http://st-www.cs.uiuc.edu/~chai/figlet.html # alias figlet='figlet -d $HOMEGUCKES/lib/fonts' # _w: present a sorted view of 'who' is logged in # and catches the output with the pager. # alias _w='w | sort | $PAGER' alias _w='w | sort | less -S' # List the twenty entries of the local lastlog file: # alias _L='last -20' function _L { last -20 ${1:=$USER} } # Fast access to the manual of "mutt" and "slrn". # alias _lmutt='$PAGER $HOMEGUCKES/.P/mutt/doc/manual.txt' # alias _lslrn='$PAGER $HOMEGUCKES/.P/slrn/doc/manual.txt' # alias _lslrn='$PAGER $HOMEGUCKES/share/SLRN/doc/manual.txt' # alias _lslrn='$PAGER $HOMEGUCKES/share/slrn/doc/manual.txt' # mo = mutt option -- search for the description # of some mutt option in the doc/manual.txt: function mo { $PAGER "+/6.* $1" ~/.P/mutt/doc/manual.txt } # switch to another display: function _D { export DISPLAY=$1 } # 2000-01-26 # alias locate='glocate -d /import/locate/GLOBAL.pub' # Start slrn with these parameters: # -n no_new_newsgroups no search for new newsgroups" # -C color colorize text # -k0 killzero scoring without expensive scores alias _slrn='slrn -n -C -k0' # alias _term='echo TERM=$TERM;echo TERMINFO=$TERMINFO' alias _termupdate='eval `resize`' alias _termfix='stty rows 24 columns 80' alias _termfix2='stty rows 30 columns 80' # http://www.uni-ulm.de/~s_smasch/various/alternate_charset/ alias vtn='echo "X[mX(BX)0OX[?5lX7X[rX8" | tr "XO" "\033\017"' ####################### # SERVICES # ####################### # http://www.domaininformation.de/whois-server_liste.html alias _whois='whois -h whois.nic.de' # get the current time from the timeserver at FU Berlin. alias _timecheck='telnet time.fu-berlin.de 13; date' # Allow starting of X with 'X': # alias X="exec xinit" ####################### # MISC ALIASES # ####################### # print specific values alias __D='echo $DISPLAY' alias __P='echo $PRINTER' alias __T='echo $TERM' # _version: show the version number of the current zsh: alias _version='echo VERSION=$VERSION; echo ZSH_VERSION=$ZSH_VERSION' # alias _xlock='xlock -mode blank -remote &' # /usr/local/bin/resize /usr/openwin/bin/resize /vol/X11R6/bin/resize ####################### # HARMLESS FUN # ####################### # hilfe: let German users give a feeling of help # which can expect with the local "experts": alias hilfe='echo Hilfe\! HILFE\!' # ok: tell users that everything is OK (ha!) alias OK\?='echo OK\!' # n: tell user that he can quit giving "no" responses. ;-) # alias n='echo No, definitely NO\!' # y: tell user that he can quit giving "yes" responses. ;-) alias y='echo Yes, Sir\?' # "screen": # Give fast access to some commands that # you are likely to use often with screen: alias GO='screen -O -R' alias GOD='screen -D -O -r' alias GOls='screen -ls' # 2004-07-17, 2007-10-17 # these aliases were alias much too long.. # gotta have something *shorter* now! alias \?='screen -ls' # alias \!='screen -r' alias \!='screen -d -RR' alias x='screen -x' ####################### # FUNCTIONS Functions # ####################### ####################### # SERVICES # ####################### # give a long listing for all occurrences of # a "program" name in the current $PATH. function _listall { if [[ $# = 0 ]] then echo "Usage: $0 program" echo "Example: $0 zsh" echo "Lists all occurrences of program in the current PATH." else for program in `whence -ap $1`; do ls -lL $program done fi } # 2003-02-25 function _dict { if [[ $# = 0 ]] then echo "Usage: $0 word" echo "Example: $0 ubiquitous" echo "Start the text browser on www.m-w.com to look the definition for word" else noglob links http://www.m-w.com/cgi-bin/dictionary?$1 fi } ## Contact an online dictionary engine to find the definition of a word: function _webster { lynx http://work.ucsd.edu:5141/cgi-bin/http_webster?isindex=$* } # _word "find words" - finds words in the (English) dictionary # function _word { grep "$1" /usr/dict/words } # function _word { grep $1 /import/ftp/misc/dictionaries/book.vok } # function _word { grep $1 /usr/share/dict/american-english | $PAGER } function _word { grep $1 ~guckes/.P/dict/american-english | $PAGER +/"$1" } # _wort "find words" - finds words in the (German) dictionary # function _wort { grep "$1" /usr/local/public/bin/german-words } # function _wort { grep "$1" /local/lib/german.words } # function _wort { gunzip -c $HOMEGUCKES/.P/dict/words.german.gz | grep "$1" } # function _wort { grep "$1" /usr/share/dict/german | $PAGER } # function _wort { grep "$1" /usr/share/dict/ngerman | $PAGER +/"$1" } function _wort { grep "$1" ~guckes/.P/dict/ngerman | $PAGER +/"$1" } # Search all mail folders below $maxsize for a word. function _fm { if [[ $# = 0 ]] then echo "find mail" echo "Usage: $0 searchword maxsize" echo "example: _fm documents 70" echo "the searchword must not contain spaces!" echo "maxsize will be applied in kilobytes (default: 50)" else #if [[ $2 = "" ]] then $2=50; fi grep -i $1 ~/Mail/*(.Lk-${2:=50}) fi } # Print the directory name of a binary function _dir { dirname =$1 } # Change to the directory of a binary function _cdp { cd `dirname =$1` } # Grep through the list of top level domains: # function _tld { gunzip -c /import/ftp/doc/iso/iso3166-countrycodes.gz | grep $1 } # text was updated on 2002-04-05 and # file was updated on 2002-04-16 # updated on 2003-11-17 for local file function _iso { if [[ $# = 0 ]] then echo "Show ISO3166 codes." echo "Usage: $0 countryname" else # grep -i $1 /import/ftp/doc/iso/iso3166-countrycodes.txt | $PAGER grep -i $1 ~/.P/txt/iso3166-countrycodes.txt | $PAGER fi } # Grep through the list of RFCs: # function _rfc { less /vol/ftp/doc/rfc/rfc$1.gz } # function _rfc { gunzip -c /import/ftp/doc/rfc/rfc$1.gz | $PAGER } # function _rfc { cd /import/ftp/doc/rfc; gunzip -c rfc$1.gz | $PAGER } function _rfc { cd /import/ftp/doc/rfc; $PAGER rfc$1.txt } # Print a cookie from the quote collection: # function _cookie { # cd /Vol/oldweb/users/guckes/ # agrep -d %% $1 quotes.collection | $PAGER } # function _cookie { agrep -d '%%' $1 ~/.P/SMARTBEE/fort | less -S -p $1 } function _cookie { grep $1 ~/.P/SMARTBEE/fort | sed -e 's/%%/ /g' | less -S -p $1 } # Print ASCII texts: # Use "ascii2postscript" filter to prepare text for printing # and send it with "lpr" to the printer: # function _print { a2ps -nn -nH -ns $* | lpr } # _printbig : print with "bold" and "font size 10": # alias _printbig='_print -B -F10' # 2006-11-17 function _print { a2ps --no-header --portrait --columns=1 $1 -o $1.ps } # function _getid { ypcat passwd | grep -i $1 | cut -d: -f1,3,4 } # function _NM { XXX=$MAIL; MAIL=${1:-/var/spool/mail/guckes}; frm -n -s new; MAIL=$XXX } # _last host : print last twenty entries from login file of host "host" # function _last { rsh "$1" last | head -20 } # usage: "_un hosts" # function _un { rsh $1 uname -a } # function L { ls -Flag $* | $PAGER } # function llwh { ls -la $(which $1) } function llwh { ls -l =$* } # function whll { llwh $1 } alias whll llwh # function lwh { $PAGER $(which $1) } function lwh { $PAGER =$* } # Changing permissions of "webpages": # _P = make items "public" function _P { ( for i in $*; do if [[ -f $i ]] then; chmod 644 $i; fi if [[ -d $i ]] then; chmod 755 $i; fi done; ) } # _p = make items "private" function _p { ( for i in $*; do if [[ -f $i ]] then; chmod 600 $i; fi if [[ -d $i ]] then; chmod 700 $i; fi done; ) } # query the newsserver for current groups: # function xgtitle () { # if [[ $# = 0 ]] # then # echo "Usage: $0 newsgroup1 [newsgroup2 ..]" # echo "Example: $0 math". # else # ( for i in $*; do # # echo xgtitle "$i\*" # echo xgtitle "*$i*" # done; # echo QUIT ) | nc $NNTPSERVER 119 | egrep "^[a-z]" # fi # } # alias xgtitle="noglob xgtitle" # alias groups="noglob xgtitle" # function _whoisde () { # if [[ $# = 0 ]] # then # echo "Usage: $0 domain" # else # echo $* | nc whois.nic.de whois 2> /dev/null # fi # } ######################### # COLORTESTS ######################### # rxvt # function _rxvt_black_on_white { # echo "^[]39;white^G^[]49;black^G" | _meta_filter } # function _rxvt_white_on_black { # echo "^[]49;black^G^[]39;white^G" | _meta_filter } # function _meta_filter { # sed -e "s/\^\[//g" -e "s/\^G//g" } # COLOR stuff # function _colortest { # echo -n TEST1: # for i in 30 31 32 33 34 35 36 37; do # echo -en "\033[${i}mColor ${i}\033[39;49m " # done # echo # echo -n TEST2: # for i in 90 91 92 93 94 95 96 97; do # echo -en "\033[${i}mColor ${i}\033[39;49m " # done # echo # } # 2005-03-07 update # COLOR stuff function _colortest { echo -n TEST1: for i in {30..37}; do echo -en "\e[${i}mColor ${i}\e[39;49m " done echo echo -n TEST2: for i in {90..97}; do echo -en "\e[${i}mColor ${i}\e[39;49m " done echo } # 2010-03-16 # findprog looks through all directories in the $PATH # for a program *containing* the first parameter # example : findprog vim findprog () { find $path -name "*$1*" } ########### # BINDKEY # ########### # Enable Emacs key binding: bindkey -e # Use "'ESC' '-'" to copy the previous word (useful for renaming files): bindkey "-" copy-prev-word ########### # COMPCTL # ########### # compctl -g '*(-/)' + -g '.*(-/)' -v cd pushd rmdir # compctl -k hosts -x 'p[2,-1]' -l '' -- rsh ssh # completion for "man" by Gossamer 980827 # compctl -f -x 'S[1][2][3][4][5][6][7][8][9]' -k '(1 2 3 4 5 6 7 8 9)' \ # - 'R[[1-9nlo]|[1-9](|[a-z]),^*]' -K 'match-man' \ # - 's[-M],c[-1,-M]' -g '*(-/)' \ # - 's[-P],c[-1,-P]' -c \ # - 's[-S],s[-1,-S]' -k '( )' \ # - 's[-]' -k '(a d f h k t M P)' \ # - 'p[1,-1]' -c + -K 'match-man' \ # -- man # completion rules for the "finger" command: # compctl -x 'N[-1,@]' -k hosts - 's[]' -u -qS '@' -- finger GUCKES=FORALL unset STATUS # vim: set et ft=sh: THPXRF EOF