######################################################################## # file: $HOME/.zshrc # available: http://www.guckes.net/setup/zshrc # written by: Sven Guckes guckes-setup-zshrc(at)guckes.net # purpose: setup file for the shell "zsh" # Latest change: Sun Nov 29 00:08:07 CET 2009 ######################################################################## # tools: # a2ps agrep apt-cache bc boxes bzip2 chmod convert cp cut cvs # date df dirname du echo egrep figlet file grep gzip gunzip # head identify jpegtran(libjpeg-progs) last less locate ln ls # man mkdir mmv mv nc ps pstree rm rmdir seq sort ssh stty svn # tail tar telnet touch uniq uptime w watch wc whois # # complex/interactive programs: # centericq elinks fetchmail gpg irssi mtr mutt ncftp # newsbeuter perl screen sed slrn ssh uudeview vim wget zsh # builtins: alias function; # cd eval export for if popdir pushdir time whence # bindkey, compctl # echo personal begin # NEW # 2009-11-29 alias tp=tracepath # 2009-10-27 myfinger () { getent passwd | grep $1 } # 2009-10-15 # show my IP address when i am logged in elsewhere: alias myip="host $(last -1 -a $USER | head -1 | sed 's/^.* //')" # 2009-07-22 # how many colors does the current terminal show? alias colors='tput colors' # 2009-07-17, 2009-07-20 # show the last ten logins of myself: alias LA='last $USER | head' # 2009-07-08 alias LW='links http://www.linuxwiki.de/linuxworks' # http://www.commandlinefu.com/commands/view/2012/graph-of-connections-for-each-hosts. # Graph number of connections for each hosts: # function graph { # netstat -an | \ # grep ESTABLISHED | \ # awk '{print $5}' | \ # awk -F: '{print $1}' | \ # sort | uniq -c | \ # awk '{ printf("%s\t%s\t",$2,$1) ; \ # for (i = 0; i < $1; i++) \ # {printf("*")}; print "" }' # } function graph { netstat -4tn | awk -F'[\t :]+' \ '/ESTABLISHED/{hosts[$6]++} END\ {for(h in hosts)\ {printf("%s\t%s\t",h,hosts[h]);\ for(i=0;i PS1='C:${PWD//\//\\\}>' alias 800='xrandr -s 800x600' alias 1024='xrandr -s 1024x768' # 2008-05-15 alias xyzzy='echo you feel like something has changed...' # 2008-04-01 # some command names are so weird # that you simply have to look them up. # but rather than doing the lookup with "man", # the command "wtf" seems more appropriate. alias wtf=man # 2008-03-09 alias traceroute=tracepath # 2008-02-11 # lookup for versions in debian packages Version () { apt-cache show $1 | grep Version } # 2007-11-10 Pizza! eieruhr () { echo beep -l 2345 | at now+$1min } # 2007-11-08 alias -- \-='cd -' alias .=source enum () { NUMBER=`echo ${(L)1}| tr abcdefghijklmnopqrstuvwxyz 22233344455566677778889999` finger +43780$NUMBER@finger.enum.at } average () { echo $(( $1./ ( ($4-$2)*60-$3+$5) )) } foo () { echo "why do you want to know this?" } dect () { grep -i $1 ~/.P/froscon/phone*txt } # 2007-07-29, 2008-06-05, 2009-08-19 # show a URL for some file on my own website # so i can simply click on it (eek!) # url () { echo http://www.guckes.net/"$PWD:t"/$1 } # url () { # HOMEURL=http://www.guckes.net/"${PWD/$HOME\//}"/$1 # HOMEURL=${HOMEURL/.P\//} # LOCALURL=file://${PWD}/$1 # echo " local url:" $LOCALURL # echo "homepage url:" $HOMEURL # } url () { for file in $*; do HOMEURL=http://www.guckes.net/"${PWD/$HOME\//}"/$file HOMEURL=${HOMEURL/.P\//} LOCALURL=$file://${PWD}/$file # echo " local url:" $LOCALURL echo $HOMEURL done } # 2007-07-17, 2009-07-08 # changing the background color of xterms: # alias x_color='xtermset -bg color' alias x_black='xtermset -bg black' alias x_blue='xtermset -bg blue' alias x_green='xtermset -bg green' alias x_red='xtermset -bg red' alias x_yellow='xtermset -bg yellow' alias x_cyan='xtermset -bg cyan' alias x_white='xtermset -bg white' alias x_magenta='xtermset -bg magenta' # changing the background color: # echo -e '\033]11;green\a' # set the title of the current xterm xsettitle () { printf "\033]0;$1\007" } # problem: "screen" seems to eat this. # auffinden aller dateien, die zwischen # M und N tagen geaendert wurden (mtime). # TODO: make it a function # $ myfind YYYY-MM-DD # # find . -maxdepth 1 -type f \ # \( -daystart -mtime -42 \) \ # -a \! \( -daystart -mtime -23 \) alias ic='less ~/.irssi/config' # 2007-04-25 # just enter TAB to get a directory listing # this is for really really lazy people! ;) # bindkey -s "^I" "ls\n" # http://list.bralug.de/pipermail/bralug/2007-March.txt.gz function mailarchiveget { BASEURL=http://list.bralug.de/pipermail/bralug/ YEAR=2005 for MONTH in \ January February March April May June Juli \ August September October November December; do wget $BASEURL/$YEAR-$MONTH.txt.gz done } # 2007-02-28 show all options # alias showalloptions='print -l ${(k)options} | sort | less' alias manaw='man -a -w' # request *all* *whereabouts* of manuals # all moved to script "countdown": # alias fosdem='days "24 feb 2007"' # alias chemnitz='days " 3 mar 2007"' # alias augsburg='days "24 mar 2007"' # alias easterhegg='days " 6 apr 2007"' # alias wien='days "31 may 2007"' # alias symposium='days "27 jun 2007"' # function countdown { # echo -n fosdem:; fosdem # echo -n chemnitz:; chemnitz # echo -n augsburg:; augsburg # echo -n easterhegg:; easterhegg # echo -n wien:; wien # echo -n symposium:; symposium # } # export LANG=en_EN alias carpool="links http://www.linuxwiki.de/ChemnitzerLinuxTag2004/MitFahrGelegenheit" alias mfg='links http://www.linuxwiki.de/ChemnitzerLinuxTage2007/MitFahrGelegenheit' alias bus='links http://www.efho.de/fh/linux/linuxbus.html' alias pirate='links http://piratecinema.org/screenings/20061210' alias ffg='links http://www.guug.de/adm/ffg-pk/abstracts.html' alias store='links http://store.newthinking.de/' alias fahrplan='exec links http://events.ccc.de/congress/2006/Fahrplan/' alias light='exec links http://events.ccc.de/congress/2006/Lightning_Talks' alias party='exec links http://events.ccc.de/congress/2006/Parties' elinkscolors () { grep color ~/.elinks/elinks.conf | grep -v '#' | sed -e 's/^ *//' | sort | $PAGER } # mutt config search _muco () { grep "$1" .muttrc .mutt/* } # CALENDAR stuff # 2006-12-16 alias ARR='grep ARR ~/.cal.dat' # arrivals alias DEP='grep DEP ~/.cal.dat' # departures # 2006-09-29, 2007-05-07, 2008-02-04, # 2008-10-17, 2009-01-12, 2009-10-08, 2010-01-24 alias 1='CAL 1 2010' alias 2='CAL 2 2010' alias 3='CAL 3 2010' alias 4='CAL 4 2010' alias 5='CAL 5 2010' alias 6='CAL 6 2010' alias 7='CAL 7 2010' alias 8='CAL 8 2010' alias 9='CAL 9 2010' alias 10='CAL 10 2010' alias 11='CAL 11 2010' alias 12='CAL 12 2010' # 2008-12-09 calendar lookups c () { FILE=~/.cal.dat; grep -i $1 $FILE | less +/$1 } geb () { FILE=~/.cal.dat; grep -i $1 $FILE | grep 999 } # FILE=~/.cal.dat; grep -i $1 $FILE | grep Geburtstag mycal () { FILE=~/.cal.dat; grep -i $1 $FILE | grep -i $2 | grep -i $3 } # example for "colors": # autoload colors ; colors # print "$bg[cyan]$fg[blue]Welcome to man zsh-lovers" _spam () { grep guckes.net ~/.LOG/maillog \ | grep -v vim.org \ | grep -v sentto \ | grep -v maillist \ | sed 's/ .*//' \ | sort \ | uniq -c \ | sort -n \ | $PAGER } jpsms () { echo $* | mutt plenz.sms } alias SPAM='screen -t SPAM mutt -f ~/Mail.SPAM/SPAM' # 2006-09-01, 2007-04-13 function book { grep -i $1 ~/.elinks/bookmarks } function kal { grep -i $1 ~/.P/cal/calendar.200[678].txt } function TALK { grep -i $1 ~/.P/cal/talks.html } alias wm='telnet ascii-wm.net 2006' alias dusch='du -sch' alias MMV="mmv 'img_????.jpg' 'img_2#1#2#3#4.jpg'" alias MMV2="mmv 'IMG_????.JPG' 'img_2#1#2#3#4.jpg'" # function lower { zmv '(*)' '${(C)1}' } # function upper { zmv '(*)' '${(U)1}' } # mal bei newthining reinschauen... alias NT='links store.newthinking.de' # 2006-03-08, 2006-04-05 # gotta test shared histories.. export HISTFILE=~/.zsh_history export HISTSIZE=8192 export SAVEHIST=8192 setopt APPEND_HISTORY setopt HIST_EXPIRE_DUPS_FIRST setopt HIST_FIND_NO_DUPS setopt SHARE_HISTORY # 2007-07-17 alias he='history -E' # 2007-10-03: complete word from history # completes the current prefix # to a word from the history: # _hist_complete() { # _main_complete _history # } # zle -C hist-complete menu-select _hist_complete # bindkey '^H' hist-complete # # bindkey "[5~" history-beginning-search-backward bindkey "[6~" history-beginning-search-forward bindkey "A" up-line-or-history bindkey "B" down-line-or-history bindkey "A" up-line-or-history bindkey "A" up-line-or-history # 2006-02-28 # i know this key id by heart - # but i hate typing it still. ;) export MYKEY=0x57F77F09 # 2006-02-22 function _my_fingerprint { MYKEYID=${1:="0x57F77F09"} FINGERPRINT=`gpg --fingerprint $MYKEYID` ( for count in `seq 7` ; do echo ' DATE: ________-____-____ PLACE:___________________________________' echo 'CHECK: [__] Identity [__] Fingerprint Secret:___________________' echo 'PREFS: please upload your signature directly to a server' echo 'and please notify me about the upload by email - thankyou!' echo ------------------------------------------------------------------------ echo $FINGERPRINT echo ------------------------------------------------------------------------ echo done ) > $MYKEYID.fingerprint.`date +'%Y-%m-%d'`.txt } # function _my_fingerprint { # MYKEYID=${1:="0x57F77F09"} # FINGERPRINT=`gpg --fingerprint $MYKEYID` # ( for count in `seq 7` ; do # echo '[__] Identity [__] Fingerprint' # echo $FINGERPRINT # echo please upload your signature directly to server and # echo please notify me about the upload by email - thanks! # echo ------------------------------------------------------------------------ # echo # done ) > $MYKEYID.fingerprint.`date +'%Y-%m-%d'`.txt # } # 2006-02-12: add up the sizes of all parameters (files) function sum { du -sch $* | tail -1 } # 2006-01-01 zstyle ':completion:*' menu yes=long-list zstyle ':completion:*' menu select=2 alias bashem='bash --rcfile /dev/null' # 2006-01-27: recently installed packages on antilope: alias whatsnew='ls -crtl /var/cache/apt/archives L' alias PLAN='links http://events.ccc.de/congress/2005/fahrplan/day_2.en.html' alias WIKI='links https://events.ccc.de/congress/2005/wiki/22C3_Public_Wiki' # 2005-12-23 function morse { echo $* | figlet -m0 -k -f morse } # alias LAST='last -10' LAST () { ( for user in \ chris dirkgomez epost esc ftimmer grabosch guckes hofmann \ maxen nostromo prenzel ramiro reisener silkemeyer skyandy; do last -1 $user | head -1 done ) | grep logged.in } # 2005-11-21 # catching errors # TRAPZERR() { echo 'dang!'; } # ;-) # adding the colon and the tick to the list of # word characters, so you jump over URLs, too, eg # "echo 'http://www.guckes.net/foo.php?pass=xyxxy'" WORDCHARS="*?_-.[]~=/&;!#$%^(){}<>:\'" # uptime dick size wars - function by Julius Plenz function dick () { uptime | perl -ne "/(\d+) d/;print 8,q(=)x\$1,\"D\n\"" } # show the current settings for caption and hardstatus lines for screen: alias screen_cap_hard="egrep '^ (caption|hardstatus) ' .screenrc" setopt AUTO_CD alias PDF='wget http://infotage.pf-lug.de/vortraege.pdf' alias bz='bzip2 -v9' alias dfg="df -h ." alias duh="du -ks" # alias _spacemove="mmv '* *' '#1_#2'" function _zmv_remove_spaces { zmv '* *' '$f:gs/ /_' } alias KSPadd="gpg --no-default-keyring --keyring $HOME/.gnupg/LC05-keys.gpg --recv-keys" # 2005-04-29 cartoon get, 2005-10-07 s/--http-pass/&word/ alias cget='wget -Y off --http-user=bitte --http-password=danke' # 2005-04-22 function shortcuts { grep SHORTCUTURL bookmarks.html | \ sed 's/.*HREF=.\([^ ]*\).*SHORTCUTURL=.\([^ ]*\).*/\2\t\1/' } # 2005-03-15 function help { $1 --help | $PAGER } # function wp () { links http://en.wikipedia.org/wiki/$1 } alias LOAD='atsar -P' # alias LOAD='\grep load ~/Mail.IN/CRON | less' function doc { cd /usr/share/doc/$1 } # "ls file count" - Dateien zaehlen alias lsfc='ls *(.)|wc -l' # add a comment to a picture. # i use this to add the originating URL # so i'll remember where i have found it. function _comment_add { if [[ $# -ne 2 ]] then echo "Usage: $0 picture comment" echo "Purpose: add the comment to the picture" echo "suggested info:" echo "YYYY-MM-DD, Place, Event_Name, Photographer, Original_URL, Names of People, License" else # remember the current date+time of the file: TMPFILE=/tmp/$$ touch -r $1 $TMPFILE # add the comment: convert -comment $2 $1 $1.new && mv $1.new $1 # change back the date+time: touch -r $TMPFILE $1 fi } function _comm () { for file in $*; do jhead $1 | sed 's/.*Comment *: //p' done } #for pic in *.big.jpg; do #echo convert -verbose -geometry 1024x768 $pic `basename $pic .big.jpg`.jpg #done #for pic in *.big.jpg; do #touch -r $pic `basename $pic .big.jpg`.jpg; #done ### Dealing with pictures alias _watch='watch -d -n 1 du -hks' alias _public='setopt GLOB_DOTS; _P . index.html * .tmp/**/*' function kick { for pic in $*; do rm -f .tmp/**/*$pic* done } function _JRL { for pic in $*; do TEMPFILE=$1_rot270_$$_tmp.jpg [ -f "$pic" ] echo "$pic"; /usr/bin/jpegtran -rotate 270 -copy all "$pic" >$TEMPFILE && touch -r "$pic" $TEMPFILE; mv $TEMPFILE "$pic" done } function _JRR { for pic in $*; do TEMPFILE=$1_rot090_$$_tmp.jpg [ -f "$pic" ] echo "$pic"; /usr/bin/jpegtran -rotate 90 -copy all "$pic" >$TEMPFILE && touch -r "$pic" $TEMPFILE; mv $TEMPFILE "$pic" done } function _jpg_rotate_right { TEMPFILE=$1_rot090_$$_tmp.jpg [ -f "$1" ] /usr/bin/jpegtran -rotate 90 -copy all "$1" >$TEMPFILE && mv $TEMPFILE "$1" } function _jpg_rotate_left { TEMPFILE=$1_rot270_$$_tmp.jpg [ -f "$1" ] /usr/bin/jpegtran -rotate 270 -copy all "$1" >$TEMPFILE && mv $TEMPFILE "$1" } alias ALBUM='album -file_sizes -geometry 200x200 -medium 640x480' alias to='links http://gw.kunstlabor.at/to/' # APT-CACHE function acse { apt-cache search $1 | sort | less -S +/$1 } function acsh { apt-cache show $1 | less -S +/$1 } # alias home='ssh guckes@home.guckes.net' # counts today's incoming mails. alias mailcount='grep -c "`date +%a\ %b\ %e`" ~/.LOG/maillog' alias mailcountyesterday='grep -c "`date -d yesterday +%a\ %b\ %e`" ~/.LOG/maillog' # contact Andreas Borchert on his own chat system alias aditalk='telnet adi.mathematik.uni-ulm.de 4711' # table of contents of an archive - gziped only alias toc='tar tvvzf' # "-N": timestamping # "-Y off": proxY off alias WGET='wget -N -Y off' # date+time TIMESERVER=time.fu-berlin.de alias dt="/usr/sbin/ntpdate -q $TIMESERVER" # alias F="fetchmail -a" # also shows when it has finished: # alias F="fetchmail -a; date" # also keep a date stamp: # alias F='date >> ~/.fetchmail.times ; fetchmail -a; date' # also show the last two lines of the timestamp log: alias F='date >> ~/.fetchmail.times ; fetchmail -a; tail -1 ~/.fetchmail.times; date' alias FF='tail -10 .fetchmail.times' # see the last ten fetchmail requests # alias whois="links http://www.domaininformation.de/whoisserver_list.html" # function whois { links http://www.domaininformation.de/whois/$1 } # 2004-09-07 www.domaininformation.de is down! ################################################################### ### GnuPG aka GPG ################################################################### # 2005-12-06 alias asc='gpg --export -a' # 2005-01-24 # avoid "gpg: please do a --check-trustdb" messages # alias gpg='gpg --no-auto-check-trustdb' # 2004-02-12 some more aliases + functions function gpgls { gpg --list-sigs ${1:="0x57f77f09"} | \ sed 's/^.....................//' | sort -n | tail $2 } # 2004-01-18 - for monster key signing #alias -g G='2&>1| grep -v "^gpg: "' alias gpgh='gpg --help|$PAGER' alias gsearch='gpg --search-keys' alias gpgl='gpg --list-keys --with-fingerprint' alias glist='gpg --list-keys --with-fingerprint' alias grecv='gpg --recv-keys' alias gsign='gpg --sign-key' alias gsigs='gpg --list-sigs' alias gupload='gpg --send-keys' # alias newsig='gpg --list-sigs 0x57f77f09 | \ # sed 's/^.....................//' | sort -n | tail' function newsig { gpg --list-sigs ${1:=0x57f77f09} | \ sed 's/^.....................//' | sort -n | tail } # mal - mutt aliases # 2005-02-15: added pager call # 2007-03-28 added maillists file # 2008-09-05: added "aliases*" function mal { grep -h -i $1 ~/.mutt/aliases* ~/.mutt/maillists | less +/$1 } # 2004-01-05, 2006-04-25 alias WHOIS="links 'http://www.gandi.net/whois?l=en'" function fon { grep -h -i $1 ~/.phone/*.txt } function tel { agrep -h -i -d '^$' $1 ~/.phone/*.txt } function m { mutt -f ~/Mail.IN/$1 } # function mf { mutt -f ~/Mail/$1 } function mf { if [[ -f ./$1 ]] then; mutt -f $1 ; fi if [[ -f ~/Mail/$1 ]] then; mutt -f ~/Mail/$1 ; fi if [[ -f ~/Mail.IN/$1 ]] then; mutt -f ~/Mail.IN/$1 ; fi echo $1 } alias LL='ls -rtld --color=auto *(/) | head -30' # 031003 # sorting the contents of a zip file by date using sed and sort: # unzip -l foo.zip | \ # sed 's/.*\([0-9][0-9]-[0-9][0-9]\)-\([09][0-9]\).*/\2-\1/' | sort -n # 2003-10-03 # "identify" is much to long ;-) # alias I='identify' function I { identify $* | sed 's/^\([^[]*\)\[\([0-9]*\)\]/\2 \1/' } # 2003-09-03 # GG $MID $outfile # Google Groups: get an article by MID and save it in file as given by $2 function GG { wget -U links "http://groups.google.de/groups?selm=$1&output=gplain" -O ${2:=ARTICLE} } # http://www.google.com/search?q=WORD1+WORD2 alias gg='TERM=linux links www.google.com' # 2003-09-06 # access the database of the mounted ftp server ftp.fu-berlin.de # alias loftp='locate -d /import/ftp/.locatedb' # 2003-07-26, 2007-11-08, 2008-05-19 # alias lo='locate -d ~/.locate/locatedb' # alias low='locate -d ~/.locate/locatedb.public_html' function lo { pushd ~ ; locate -d ~/.locate/locatedb "$@"; popd } function low { pushd ~ ; locate -d ~/.locate/locatedb.public_html "$@"; popd } # # alias updb='updatedb --localpaths="$HOME /import/Mweb/guckes" --output=$HOME/.locatedb --prunefs=/' # function updb { updatedb --localpaths="$HOME /import/Mweb/guckes" \ # --output=$HOME/.locatedb --prunefs="/ ~/INSTALL ~/share" } # # function updb { updatedb --localpaths="$HOME /import/Mweb/guckes" \ # --output=$HOME/.locatedb \ # --prunefs="/ $HOME/INSTALL $HOME/share" } # "--preunefs=/" seems to be required - but why?? # # function updb { updatedb --localpaths="$HOME" \ # --output=$HOME/.locatedb \ # --prunefs="/" } function updb { DATE=`date +%Y-%m-%d` DIRWEB=/home/www/$USER/public_html LOCATEDIR=$HOME/.locate LOCATEDBHOME=$LOCATEDIR/locatedb.$DATE LOCATEDBPUBL=$LOCATEDIR/locatedb.$DATE.public_html # date cd; time updatedb -U ./ -o $LOCATEDBHOME cd $DIRWEB; time updatedb -U $DIRWEB -o $LOCATEDBPUBL date # cd $LOCATEDIR time bzip2 -cv9 $LOCATEDBHOME > $LOCATEDBHOME.bz2 time bzip2 -cv9 $LOCATEDBPUBL > $LOCATEDBPUBL.bz2 ln -fs $LOCATEDBHOME $LOCATEDIR/locatedb ln -fs $LOCATEDBPUBL $LOCATEDIR/locatedb.public_html ls -l *$DATE*(.) } # function MAIL { grep -B 2 "Folder: /var/mail/guckes" ~/.LOG/maillog | tail -50 } # function MAIL { tail -1000 ~/.LOG/maillog | grep -B 2 "Folder: /var/mail/guckes" | tail -50} function MAIL { tail -1000 ~/.LOG/maillog | grep -B 2 "Folder:.*${1:=Mailbox}" | tail -50} alias 80="stty columns 80" alias 113="stty columns 113" alias 145="stty columns 145" alias getslrn='cd ~/.P/INSTALL/ && \ mkdir slrn-cvs-`date +%y%m%d` && \ cd slrn-cvs-`date +%y%m%d` && \ cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/slrn login && \ cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/slrn co slrn' alias ch='./configure --help' ################################################################### # GLOBAL ALIASES ################################################################### # include the pipe symbol # idea from Franz Lax :-) alias -g L="| less" # view the output # these come quite natural, too: alias -g H="| head" # see the beginning alias -g T="| tail" # see the end alias -g V='| vim -' # edit it with vim! # grepping the fast way! # alias -g A='agrep -d "^-- $\"' # 2005-02-28 alias -g G='| grep' alias -g g='| grep -i' alias -g P='|' # "type the pipe!" :) alias -g S='| sort ' alias -g C='| wc -l ' # example: # command G searchword L alias -g PN='~/.P/pics/NEW' # alias -g grep='grep -in --color=auto' # counting the lines of an output alias -g W='| wc -l' # example: "locate . W" # suffix aliases! alias -s pdf=xpdf alias -s tex=vim alias -s txt=less # alias -s txt=vim alias -s htm="exec links" alias -s html="exec links" alias -s shtml="exec links" # alias -s at="exec links" alias -s ch="exec links" alias -s de="exec links" alias -s lu="exec links" alias -s com="exec links" alias -s net="exec links" alias -s org="exec links" ################################################################### # GPG alias gpgh='gpg --help|$PAGER' alias gpgs='gpg --search-keys' # calendar in colour alias CAL8='cal-4.0 -e -f -u -a=8' alias CAL='cal-4.0 -e -f -u' ################################################################### # DATE stuff ################################################################### # september date - days since Sep 1st 1993 aka the "eternal september" alias sepdate='echo $(((`date +%s` - 746748000) / 86400)). September 1993' alias fravia='days "30 aug 1952"' # 2003-06-27 function showdays { BIRTHDAY="6 apr 1967" DATE=${1:=$BIRTHDAY} for offset in \ `echo 1111 2222 3333 4444 5555 6666 7777 8888 9999 11111 12345` \ `seq -w 1000 1000 20000`; do echo -n "$DATE + $offset = "; date +%Y-%m-%d -d "$DATE $offset days" done } function tage () { print $(( (`date +%s -d $2` - `date +%s -d $1` )/60/60/24 )) } function days () { BIRTHDAY="6 apr 1967" print $(( (`date +%s -d ${2:="now"}` - `date +%s -d ${1:=$BIRTHDAY}` )/60/60/24 )) } # function days () { # BIRTHDAY="6 apr 1967" # if [[ $# = 0 ]] # then # echo 'Usage: $0 [date1] [date2]' # echo 'Purpose: give the number of days from date1 to date2.' # echo 'if date2 is not given then the current day assumed.' # echo "if date1 is not given then $BIRTHDAY is assumed." # else # print $(( (`date +%s -d ${2:="now"}` - `date +%s -d ${1:=$BIRTHDAY}` )/60/60/24 )) # fi # } # alias dad='days "28 jan 1944"' # $ date -d '28 jan 1944 22222 days' # Tue Nov 30 00:00:00 CET 2004 # 2006-06-27 # show the weekday of a given date function day () { date +%a -d ${1:="today"} } # tests: # day now # day today # day tomorrow ################################################################### # mutt manual - lookup for options function mm { noglob less "+/6.* $1" ~/.P/mutt/doc/manual.txt } function gif2png { if [[ $# = 0 ]] then echo "Usage: $0 foo.gif" echo "Purpose: change a GIF file to a PNG file" else output=`basename $1 .gif`.png convert $1 $output touch -r $1 $output ls -l $1 $output fi } # extract signatures from my signature file function _sig { agrep -d '^-- $' $1 ~/.P/sig/SIGS echo # somehow it's necessary } # extract signatures from my quotes collection function _quote { agrep -d '^-- $' $1 ~/.P/quotes/collection # echo # somehow it's necessary } # moving old mail folders function mmove { SOURCE=~/Mail/$1 TARGET=~/Mail.OLD/$1.gz gzip -v9c $SOURCE > $TARGET touch -r $SOURCE $TARGET ls -l $SOURCE $TARGET } ################################################################### ### IRC ################################################################### # alias IRC='epic SvenG satanii.enemy.org' # alias IRC='irc SvenG irc.lugs.ch' # alias ircclt="screen -t IRC 10 epic SvenG irc.fu-berlin.de -c '#clt2004'" alias irckl='screen -t IRC 10 irssi -c irc.kunstlabor.at' alias irclog='$PAGER +G ~/.IRC' ################################################################### ### MAIL ################################################################### # alias maillog='$PAGER +G ~/.LOG/maillog' # alias M='$PAGER +G ~/.LOG/maillog' # alias maillog="tail -1000 ~/.LOG/maillog | \ # sed -e 'N;N;/CRON/d' \ # -e 'N;N;/SPAM.SPAM/d' \ # -e 's,/var/mail/guckes,INBOX,' | \ # less +/'^ Folder:.*'" # # alias maillog="tail -1000 ~/.LOG/maillog | \ # sed -e '/From .*\n^ Subject.*\n^ Folder:.*SPAM/d' \ # -e 's,/var/mail/guckes,INBOX,' | \ # less +/'^ Folder:.*'" # # alias maillog="tail -1000 ~/.LOG/maillog | \ # \grep -v SPAM | \grep Folder: | \ # sed -e 's/^ *Folder: //' \ # -e 's,/var/mail/guckes,INBOX,' \ # -e 's/ [ ]*\([0-9][0-9]*\)$/\t\t\1/' | \ # less -N" # # 2007-06-27: alias maillog="tail -3000 ~/.LOG/maillog | \ \grep -v SPAM | \grep Folder: | \ sed -e 's/^ *Folder: //' \ -e 's/ [ ]*\([0-9][0-9]*\)$/\t\t\1/' | \ less -N" # less -p 'Folder: [A-Z][-A-Z]* '" # alias maillog="tail -1000 ~/.LOG/maillog | less +/'^ Folder:.*'" # -e '/^From guckes@antilope.in-berlin.de/N;N;d' # From guckes@antilope.in-berlin.de Sun Jan 2 01:13:02 2005 # Subject: Cron uptime # Folder: CRON 879 alias M='less +G ~/.LOG/maillog' alias MM=maillog ################################################################### ### NEWS ################################################################### alias gmane='screen -t GMANE slrn -n -C -k0 -h news.gmane.org' alias tugnews='screen -t TU-GRAZ slrn -n -C -k0 -h news.tugraz.at' # read all those uppercase files which usually come with most programs: alias lAZ='$PAGER [A-Z]*' # _lap foo -- list all programs with prefix "foo": # function _lap { for i in ${(@)$(hash -m $1\*)#*=}; do ls -l $i; done} # function _lap { for i in "${(@f)$(whence -pm $1\*)}"; do ls -l $i; done} # Peter Stephenson: function _lap { local tmp tmp=("${(@f)$(whence -pm $1\*)}") (( $#tmp )) && ls -l $tmp } # start mutt without setup files on an empty folder: alias muttem='mutt -n -f /dev/null -F /dev/null' # display free inodes for ufs disks alias dfiu='df -o i -F ufs' # 020110 # DM -> Euro function dm2euro { noglob echo $1/1.95583 | bc } function euro2dm { noglob echo $1*1.95583 | bc } # check the existence of each dir in $PATH: function _pathcheck { for dir in `echo ${PATH//:/ }`; do ls -ld $dir done } # PING - check for availability of my home machine # using the pseudo name is has # alias PING='nslookup guckes.penguinpowered.com' # use pstree with "hup" options :-) # alias pshup='pstree -hup' alias pst='pstree -hup $USER' # psg = ps grep alias psg='ps -u $USER| grep' # example: psg vim ############# # Variables # ############# # a list of directories to check also when using the "cd" command CDPATH=..:~/.P:~/.P/EVENTS:~/.P/PERSONS # CDPATH=..:~/.P:~/.P/PERSONS:~/.P/pics:~/.P/pics/cartoons:~/.P/pics/2005/ # CDPATH=..:~/.P:~/.P/PERSONS:~/.P/pics/2004/:~/.P/pics/2005/ # 2003-06-15 # export LC_ALL=en_EN # See below for more settings for the prompt! PS1='%n@%m:%4c%1v> ' # PS1='guckes@f451:%4c> ' # PS1='guckes@in-berlin:%4c> ' # PS1='guckes@in-luxembourg.lu:%4c> ' # 2007-02-06 vortrag # RPS1='%l %D{%A %y%m%d %T}' # PS1='$#jobstates guckes@in-berlin:%4c> ' # PS1='%j guckes@in-berlin:%4c> ' # 011126: # http://www.guckes.net/unix/#bc export BC_ENV_ARGS="$HOME/.bcrc" # PRINTER=a2central # PRINTER=a3og1b # PRINTER=a3eg # export PRINTER=A3EG # export PRINTER=A2CENTRAL export EDITOR=vim export PAGER=less # TERM=vt100 export VIEW=$PAGER # gzip GZIP=-v9 # irc clients: export IRCNAME='Sven Guckes (0x57F77F09)' # export IRCNAME='Sven Guckes' export IRCNICK=SvenG # export IRCSERVER=irc.fu-berlin.de # http://www.guckes.net/less/ export LESS=aCMsei # 2007-07-03: Colorize you man pages! :) export LESS_TERMCAP_mb=$'\E[01;31m' export LESS_TERMCAP_md=$'\E[01;31m' export LESS_TERMCAP_me=$'\E[0m' export LESS_TERMCAP_se=$'\E[0m' export LESS_TERMCAP_so=$'\E[01;44;33m' # export LESS_TERMCAP_so=$'\E[01;47;34m' export LESS_TERMCAP_ue=$'\E[0m' export LESS_TERMCAP_us=$'\E[01;32m' # Check for logins # WATCH=notme # WATCHFMT="%D %T %M %l %n %a" ######### # bindkey ######### bindkey "," copy-prev-word bindkey "-" copy-prev-word # up: OA # down: OB # right: OC # left: OD ######### # Aliases ######### # function HOMEIP { echo 160.45.216.101 } # alias -g HOMEIP='212.42.238.183' # alias -g HOMEIP='217.197.85.183' alias ftp=ncftp # alias ftp=ncftp3 # alias ncftp=ncftp3 alias _cdmail='cd /var/spool/mail' # Directories on the mounted ftp server: # alias _cdless='cd /import/ftp/unix/gnu/less' # alias _cdmutt='cd /import/ftp/unix/mail/mutt/' # alias _cdslrn='cd /import/ftp/unix/news/slrn/' # alias _cdvim='cd /import/ftp/misc/editors/vim/' # alias _cdzsh='cd /import/ftp/unix/shells/zsh/' # alias _home='TERM=xterm; stty rows 30 columns 80' # alias _homexterm='TERM=xterm; stty rows 36 columns 80' # alias _dec-vt220='TERM=vt220; stty rows 49 columns 80' ######### # picture conversion ######### alias _GIF='convert -verbose -interlace LINE' alias _thumb='convert -geometry 100x100 -interlace LINE -verbose' alias _thumb150='convert -geometry 150x150 -interlace LINE -verbose' alias _thumb200='convert -geometry 200x200 -interlace LINE -verbose' alias _mpo='mutt -f ~/News/posted' alias _lposted='$PAGER ~/News/posted' function _thumbs { for bild in PATTERN; do echo convert -verbose -geometry 640x480 $bild `basename $bild .EXT`.640x480.jpg done } # the /bin/ln seems to be broken. # use /usr/bin/ln instead: # alias lns='/usr/bin/ln -s' # /bin/ls seems to be broken on Solaris # alias lns='/usr/bin/ln -s' ## obsolete picture conversion project # alias _cd='cd /vol/druckerei' # alias _cdb1='cd /vol/druckerei/buch1/tex' # alias _cdb2='cd /vol/druckerei/buch2/tex' # alias _cdbuch='cd /Vol/druckerei/pics' # alias _cdbuch='cd /import/druckerei/' # alias _cdbuchpics='cd ~`echo hgrshpuf|rot13`/.public_html/buch/pics' # function _such { grep $1 /import/druckerei/buch?/tex/*tex } ######### # NEWS/USENET ######### # show (un)subscribed newsgroups alias _sub="sed -e 's/^\(.*\) .*/\1/' ~/.newsrc | grep : | sort | $PAGER" alias _unsub="sed -e 's/^\(.*\) .*/\1/' ~/.newsrc | grep ! | sort | $PAGER" # alias _netscape='/import/communicator/netscape &' ############# # Functions # ############# # display sample text in all available figlet fonts: function FIGLET { # for font in ~/lib/fonts/*.flf; do for font in /usr/share/figlet/*.flf; do echo $font: echo $1 | figlet -m0 -k -f $font echo ----------------------------------------- done } # create a new webpage # updated on 2003-11-11 function _newpage { if [[ $# = 0 ]] then echo "Usage: $0 pagename" else cd ~/.P mkdir $1 cd $1 touch $1.index.html ln -s $1.index.html index.html chmod 755 . chmod 644 index.html fi } # "ma" = (find) "mail alias" # grep through my mail aliases file for addresses: # function _ma { grep -i $1 ~/.mutt.aliases ~/.mutt.personal } function _ma { mutt -A $1 } # _example : Special Prompt for shell examples # alias _example='PS1="";RPS1="";' function _promptreset { PS1='%n@%m:%4c%1v>'; RPS1='%l %D{%A %y%m%d %T}' } function _promptexample { PS1='guckes@example:%3c>'; RPS1='' } function _promptshort { PS1='$ '; RPS1='' } # send a message to a pager: # function _scall { echo -n '$*' | mutt 9162793@scall.de } #################################################################### # installing programs ( configure && make && make install ) #################################################################### # 2003-10-29 generic configure command for myself alias compile="./configure --prefix=$HOME" # 2003-05-12 function _compile_cicq { ./configure --prefix=$HOME \ --disable-nls \ --with-included-gettext } # 2007-05-09 function _compile_centercim { ./configure --prefix=$HOME \ --disable-nls \ --disable-aim \ --disable-irc \ --disable-gg \ --disable-msn \ --disable-rss \ --disable-lj \ --with-included-gettext } # 2002-12-12, 2003-08-19, 2008-02-06 # function _compile_elinks { # ./configure --prefix=$HOME --without-gpm --disable-ipv6 --enable-leds # } function _compile_elinks { ./configure --prefix=$HOME \ --enable-256-colors \ --enable-exmode \ --enable-html-highlight \ --without-lua } # 020816 function _compile_elvis { ./configure --prefix=$HOME --without-x --verbose } # 2003-10-28 function _compile_gcal { ./configure --prefix=$HOME --disable-nls --with-included-regexps --with-included-gettext } # 021127 function _compile_gnupg { ./configure --prefix=$HOME --disable-nls } # 2003-03-18 function _compile_irssi { ./configure --prefix=$HOME --with-textui } # 020424 function _compile_less { ./configure --prefix=$HOME --disable-nls --with-included-gettext --with-editor=vim } # 2003-08-27 function _compile_links { ./configure --prefix=$HOME } # 030715 function _compile_lynx { ./configure --prefix=$HOME --with-ssl --enable-color-style --enable-prettysrc --enable-read-eta --enable-underlines } # 020107,021104,030613 # 2007-04-27 NEW: --enable-hcache # 2007-04-30 NEW: --without-idn # 2007-05-01 NEW: IDN problem requires iconv, # so i have removed "--disable-iconv" again. # function _compile_mutt { ./configure --prefix=$HOME \ --disable-nls \ --enable-buffy-size \ --enable-hcache \ --enable-locales-fix \ --enable-imap \ --enable-pop \ --without-idn \ --with-included-gettext \ --with-regex \ --without-wc-funcs } # 2005-02-07, no IMAP or POP, but NNTP # function _compile_muttng { ./configure --prefix=$HOME \ --disable-iconv \ --disable-nls \ --enable-buffy-size \ --enable-hcache \ --enable-locales-fix \ --enable-pop \ --with-included-gettext \ --with-regex \ --without-wc-funcs } # no nntp! # 2007-05-03, 2008-02-07 function _compile_nano { ./configure --prefix=$HOME --enable-all } # function _compile_nano { # ./configure --prefix=$HOME \ # --disable-nls \ # --enable-all # --enable-color \ # --enable-extra \ # --enable-multibuffer \ # --enable-nanorc \ # --enable-undo \ # --enable-utf8 # } # 2003-09-02 function _compile_ncftp { ./configure --prefix=$HOME } # 020128 function _compile_screen { ./configure --prefix=$HOME --enable-colors256 } # 030313 function _compile_sed { ./configure --prefix=$HOME --disable-nls --enable-html --with-included-gettext } # 031027 function _compile_slang { ./configure --prefix=$HOME } # 2002-11-18 function _compile_slrn { ./configure --prefix=$HOME --disable-nls --with-included-gettext } # 020325 function _compile_vim { ./configure --prefix=$HOME --enable-gui=no \ --with-compiledby="Sven Guckes guckes@vim.org" } # 2003-09-13 function _compile_wget { ./configure --prefix=$HOME --disable-nls } # 2003-09-08 function _compile_zsh { ./configure --prefix=$HOME --enable-maildir-support --with-curses-terminfo } #################################################################### # SCREEN #################################################################### # 2009-06-18 function caphard { if [[ $# = 0 ]] then echo "Usage: $0 on|off" echo "Purpose: turn caption and hardstatus lines on/off." fi if [[ $1 == "off" ]] then screen -X caption splitonly screen -X hardstatus ignore fi if [[ $1 == "on" ]] then screen -X caption always screen -X hardstatus alwayslastline fi } # start mutt on some big folders - # does not require a shell and they # can start up in the background. alias AU='screen -t AUGSBURG mutt -f ~/Mail/AUGSBURG' # 2006-03-08 alias BB='screen -t BLIT mutt -f ~/Mail/BRANDENBURG' alias BR='screen -t BLIT mutt -f ~/Mail/BRANDENBURG' alias CH='screen -t Chemnitz mutt -f ~/Mail/CHEMNITZ' alias DD='screen -t Dresden mutt -f ~/Mail.IN/DRESDEN' alias EA='screen -t EH07 mutt -f ~/Mail/EASTERHEGG' alias FO='screen -t FOSDEM mutt -f ~/Mail/FOSDEM' alias FR='screen -t FrOSCon mutt -f ~/Mail/FROSCON' # 2006-06-13 alias FS='screen -t Graz mutt -f ~/Mail/FREESUMMER' alias KA='screen -t Karlsruhe mutt -f ~/Mail/KARLSRUHE' alias LI='screen -t LINZ mutt -f ~/Mail/LINZ' # 2006-06-13 alias LT='screen -t LinuxTag mutt -f ~/Mail/LINUXTAG' # 2004-11-15 alias MD='screen -t Magdeburg mutt -f ~/Mail.IN/MAGDEBURG' alias PF='screen -t Pforzheim mutt -f ~/Mail/PFORZHEIM' alias TT='screen -t THINKTANK mutt -f ~/Mail/THINKTANK' # 2007-01-21 alias UK='screen -t UKUUG mutt -f ~/Mail/UKUUG' # 2005-04-25 alias VO='screen -t VORTRAEGE mutt -f ~/Mail/VORTRAEGE' # 2005-09-02 # alias WI='screen -t WIEN mutt -f ~/Mail/WIEN' # 2005-04-26 alias WI='screen -t WIESBADEN mutt -f ~/Mail/WIESBADEN' # 2006-04-26 alias ZW='screen -t Zweibruecken mutt -f ~/Mail/ZWEIBRUECKEN' # 2005-07-23 # alias scmail='screen -t +MAIL 7 mutt -y' alias scmutt='screen -t +MUTT 8 mutt -f ~/Mail.IN/MUTT' alias scvim=' screen -t +VIM 9 mutt -f ~/Mail.IN/VIM' # invoke special manual alias screenh='man ~/man/man1/screen.1' # 2003-07-08 # fix the broken setup for DISPLAY # export DISPLAY="`cat ~/.ip`:0.0" alias _su='screen -X setenv DISPLAY `cat ~/.ip`:0.0' # 2005-01-08 # full communication # alias COMM='screen -t COMM 9 screen -m -e^xx -S communication irssi' alias COMM='screen -t COMM 9 screen -m -c ~/.screenrc.comm' alias COMM='screen -t COMM 9 screen -m -c ~/.screenrc.comm' alias WORK='screen -m -c ~/.screenrc.work' alias work='screen -d -r work' alias U='screen -U -r' # 2005-01-21 # rename current screen session to PID.$HOST.newname function sessionname {screen -S $STY -X sessionname $HOST.$1 } # todo: this needs to adjust $STY to allow another change. alias number='screen -S $STY -X number' # I needed a quick way to start the page on the 23C3: # alias 23='exec links http://www.guckes.net/cccc2006/' # alias 23='screen -t 23C3 links http://www.guckes.net/cccc2006/' # alias 23='screen -t 23C3 links http://events.ccc.de/' # 2009-03-10 # function 's' selects the window $1 # and sends $2 as text into it. # could be used from within vim # within a subshell. s () { # TODO: echo usage instructions screen -p $1 -X stuff $2 } # for my own version of screen in ~/bin/screen export SCREENDIR=/var/run/screen/S-guckes # pick up the communications session again # on window #9 with title "COMM": function pickupcomm { screen -S work -X screen 9 screen -S work -X title COMM screen -S work -X stuff '! comm ' } # 2001-10-24 # st == screen-title # set the title of the current screen window to $1: # function st { echo ""$1\" } # this won't break vim's syntax coloring: function st { print -n "\E\"$*\E\134" } #################################################################### # completion control for mutt aliases by Anthony Tong #################################################################### # requires zsh with completion control supporting option "-W"! # function _ma() { # if [[ -r ~/.mutt.aliases ]] { # < ~/.mutt.aliases | while read token alias addy # do if [[ $token == alias ]] reply=($reply $alias) done } # } # # compctl -K _ma + -f + -k "(-f)" -S "=" + -x 's[-f=]' -f -W ~/Mail -- mutt #################################################################### # requesting info from webpages or starting the text browser on them #################################################################### # call "links" - but without the pattern globbing alias li='noglob links' # fir () { firefox -a firefox -remote "openURL($1)" } # ..,2003-07-25 # startup on special webpages alias rich="links http://www.richholmes.net/genealogy/academic.html" # alias kino='links http://www.kino-berlin.de' alias kino='links http://berlin.stadtus.de/kino/' alias limd='links http://orga.mdlug.de/gruni/neu/vortrag.html' # 020111 alias netmind='links http://www.netmind.com/URL-minder/new/register.html' # 011117,011205 # call the dictionary interface at TU Chemnitz: alias dict='screen -t DICT links dict.tu-chemnitz.de' # 011223,021117 # _acro -> expand an acronym # todo: take a look at the site # http://www.abbreviations.com/ function _acro { if [[ $# = 0 ]] then echo "Usage: $0 acronym" echo "Purpose: expand an acronym" else #links "http://www.ucc.ie/cgi-bin/acronym?$1" links "http://www.acronymfinder.com/af-query.asp?String=exact&Acronym=$1" fi } ##################################################################### # special stuff comes last - much easier to debug ;-) ##################################################################### # Tetris! :-) autoload -U tetris zle -N tetris bindkey "^Xt" tetris # C-x t zum Spielen # Viele vorinstallierte Completions für *diverse* Programme. autoload -U compinit ; compinit -u # U.A. farbige Completion zmodload -i zsh/complist # cd & co.: Nur Verzeichnisse anzeigen. compctl -g '*(-/)' + -g '.*(/)' cd chdir dirs pushd rmdir dircmp cl # tar & co.: Nur Archivdateien und Verzeichnisse anzeigen. compctl -g '*.(gz|z|Z|t[agp]z|tarZ|tz)' + -g '*(-/)' gunzip gzcat zcat # Soundprogramme: Sounds + Playlisten + Verzeichnisse anzeigen. compctl -g '*.(mp3|MP3|ogg|OGG|temp|TEMP|m3u|pls)' + -g '*(-/)' mpg123 xmms EP # Browser: Nur HTML-Seiten und Verzeichnisse. compctl -g "*.html *.htm" + -g "*(-/) .*(-/)" + -H 0 '' w3m lynx elinks wget opera EL O # xpdf: Nur PDFs und Verzeichnisse. # compctl -g '*.(pdf|PDF)' + -g '*(-/)' xpdf pdf2ps # compctl -g '*.(pdf|PDF)' xpdf pdf2ps compctl -g '*.pdf' xpdf pdf2ps # Bilderanzeige: Nur Bilder und Verzeichnisse. compctl -g '*.(jpg|JPG|jpeg|JPEG|gif|GIF|png|PNG|bmp)' + -g '*(-/)' gimp xv display gqview # xdvi: DVIs und Verzeichnisse anzeigen. compctl -g '*.dvi' + -g '*(-/)' dvips xdvi gxdvi # lp und gv: Postscript-Dateien und Verzeichnisse anzeigen. compctl -g '*.ps' + -g '*(-/)' lp gv staedte=(bregenz eisenstadt graz innsbruck klagenfurt linz salzburg stpoelten wien) compctl -k staedte lw # autoload compinit complist # zstyle ':completion:*:ssh:*' hosts `sed -e 's/[ \t,].*//' ~/.ssh/known_hosts` # snarf snarf.. local _myhosts _myhosts=( ${${${${(f)"$(<$HOME/.ssh/known_hosts|grep -v '#')"}:#[0-9]*}%%\ *}%%,*} ) zstyle ':completion:*' hosts $_myhosts # kill - unglaubliche Completions! zstyle ':completion:*:kill:*' command 'ps xf -u $USER -o pid,%cpu,tty,cputime,cmd' zstyle ':completion:*:kill:*' insert-ids single zstyle ':completion:*:*:kill:*' menu yes select zstyle ':completion:*:kill:*' force-list always # less und mutt: Umfangreiches Menü. zstyle ':completion:*:*:less:*' menu yes select zstyle ':completion:*:*:mutt:*' menu yes select # echo personal end # vim: set et ft=sh: THPXRF EOF