################################################## # ~/.zshrc # $Id: zshrc 2 2005-03-29 07:22:59Z pfeifer $ # Hagen Paul Pfeifer - hagen@jauu.net # http://www.jauu.net # ################################################## # core dumps up to 10000 blocks ulimit -c 10000 # file creation mask umask 022 ## ENV's # cvs-envs export CVSUMASK=003 export CVSEDITOR=vim # executable directories export PATH=$HOME/bin:/sbin:/usr/sbin/:${PATH} export MOZILLA_HOME=$HOME/.mozilla # newsserver export NNTPSERVER=news.t-online.de export PAGER="col -b | view -c 'set nomod' -" export MANPAGER="col -b | view -c 'hi StatusLine ctermbg=green| set ft=man nomod nolist' -" export TCGREP="irnH" # less options via env export LESS="--force --ignore-case -M" # classpath for java libaries export CLASSPATH=.:${CLASSPATH} # default encrypted session via rsync export RSYNC_RSH=ssh # Language Stuff # english messages && time, eur support export LANGUAGE=C export LANG=C export LC_MESSAGES=C export LC_TIME=C # corewars to the fullest export PMARSHOME=/usr/share/games/pmars/macros ## ALIASES # some piping stuff alias -g V='|vim -' alias -g L='|less' alias -g LL=' 2>&1|less' alias -g H='|head' alias -g T='|tail' alias -g G='|grep' # for ^x^h alias run-help='man' # don't print copyright messages at startup alias gdb="gdb -silent" # verbose remove 5iterations zero force alias shred="shred -v -u -n2 -z -f" # sort symbols numerically by their addresses alias nm="nm -n" # verbose mode alias fuser="fuser -v" # no spelling corrections on this commands alias mv="nocorrect mv" alias cp="nocorrect cp" alias mkdir="nocorrect mkdir" alias grep='nocorrect grep --color=auto' alias dirs='dirs -v' # ls - list directory contents alias d="ls --color=auto -T 0" alias ls="ls --color=auto -T 0" alias la="ls --color=auto -Al -T 0" alias ll="ls --color -l -T 0" # ls-tips # ls -sS list for Size # ls -sSr list for Reverse size # ls -t list for youngest modification # ls -tr list for oldest modification alias rm="rm -if" # speed kills! ;-) alias ..="cd .." alias ...="cd .. ; cd .." alias l.="ls -d .[A-Za-z]* --color=auto" # checksuming it alias rsync='rsync -P --checksum' # german setting (start week on monday) alias cal='cal -m' alias indent='indent -kr -i8' alias lsof='sudo lsof' # change current permissions for home directory alias homeopen="chmod -R go=rX $HOME" alias homeclose="chmod -R go= $HOME" alias diff='LC_ALL=C TZ=UTC0 diff' # hexdump alias hd='od -Ax -tx1z -v' alias pal='pal --color' # test if X is up and start links if possile with X support if test ! -z $XAUTHORITY then alias links='links -driver x' fi alias hg='fc -l 0|grep' # moc - a nice consolen music player alias xmoc='xterm -e mocp' alias svndiff='svn diff -r PREV:COMMITTED | view -' [ -x /usr/bin/lesspipe ] && eval "$(lesspipe)" ### check for OS case $(uname -s) in Linux) OS="linux" alias psa='ps axo "user,pid,ppid,%cpu,%mem,tty,stime,state,command"' # 0x20C3F4DD is my certification only key alias gpgsign='gpg -u 20C3F4DD --sign-key' ;; *[bB][Ss][Dd]) OS="bsd" alias psa='ps axo "user,pid,ppid,%cpu,%mem,tty,start,state,command"' ;; *) OS="unknown" ;; esac ### check for DIST if [ -f /etc/redhat-release ]; then DIST="redhat" elif [ -f /etc/gentoo-release ] || [ -f /usr/bin/emerge ]; then DIST="gentoo" fi case "${DIST}" in gentoo) #if [ -f /etc/profile.d/bash-completion ]; then # source /etc/profile.d/bash-completion #fi ;; *) ;; esac ### check for DOMAINNAME DOMAINNAME=$(dnsdomainname 2>/dev/null || hostname -d) case "${DOMAINNAME}" in furcht.bar*) ;; fh-furtwangen.de*) # news server export NNTPSERVER=news.ai-lab.fh-furtwangen.de export CFLAGS="-march=i386 -Os -fomit-frame-pointer -pipe"; export CXXFLAGS=$CFLAGS; alias clearcash="rm -rf ~/.firefox/default/71uumtop.slt/Cache/*" ;; *) ;; esac ### check for HOSTNAME HOSTNAME=$(hostname 2>/dev/null || hostname -f) case "${HOSTNAME}" in einstein*,bacon,euler*) export CFLAGS="-march=i386 -Os -fomit-frame-pointer -pipe"; export CXXFLAGS=$CFLAGS; ;; c3po*) export LANG=C; export LC_ALL=de_DE@euro; ;; jarjar*) alias javac5='/opt/jdk1.5.0_06/bin/javac' alias java5='/opt/jdk1.5.0_06/bin/java' ;; esac ## HOST SPEZIFIC DATA case $TERM in *xterm*|rxvt|(dt|k|E)term) # chpwd executes a command every time the directory changes # print is like echo, but with access to prompt expansion variables chpwd () {print -Pn "\e]0;%n@%m %d\a"} ;; esac zmodload -i zsh/complist # display colored directory entries # display current dircolors with dircolors -p if [ -f ${HOME}/.dir_colors ] then eval $(dircolors -b ${HOME}/.dir_colors) elif [ -f /etc/DIR_COLORS ] then eval $(dircolors -b /etc/DIR_COLORS) fi zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}" zstyle ':completion:*:*:kill:*' list-colors '=%*=01;31' # Load the completion system autoload -U compinit compinit zstyle ':completion:*:*:kill:*:jobs' verbose yes autoload -U sched # display a _oversized_ menu for each completion (zsh is feels like the good old # midnight commander ... ) #zstyle ':completion:*' menu select=1 #zstyle -e ':completion:*:ssh:*' hosts 'reply=($(sed -e "/^#/d" -e "s/ .*\$//" -e "s/,/ /g" /etc/ssh_known_hosts ~/.ssh/known_hosts ~/.ssh/known_hosts2 2>/dev/null))' # From the zshwiki. Hide CVS files/directores from being completed. zstyle ':completion:*:(all-|)files' ignored-patterns '(|*/)CVS' zstyle ':completion:*:cd:*' ignored-patterns '(*/)#CVS' # Pull hosts from $HOME/.ssh/known_hosts, also from the wiki #local _myhosts #_myhosts=( ${${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[0-9]*}%%\ *}%%,*} ) # frequently used hosts _hosts=(`hostname` arath.foo.fh-furtwangen.de mia.foo.fh-furtwangen.de c3po.0xdef.net einstein.ai-lab.fh-furtwangen.de unfug.org jarjar.furcht.bar. skywalker.furcht.bar. hellgate.furcht.bar. ) zstyle ':completion:*' hosts $_hosts # frequently used users names _users=(pfeifer hgndgtl unfug) zstyle ':completion:*' users $_users # turns on spelling correction for commands setopt nocorrect # ORRECTALL option turns on spelling correction for all arguments setopt nocorrectall # ignore duplicated entrys in history and with trailing spaces setopt histignoredups setopt histignorespace # only exit or logout to leave zsh #setopt ignoreeof # let you type comment's setopt interactivecomments # autocd allow you to type a directory, without a cd prefix #setopt autocd # now you can negates pattern [ ls -d ^*.c ] and the like ;-) setopt extendedglob setopt EXTENDEDGLOB # file globbing is awesome setopt AUTOMENU # Tab-completion should cycle. setopt AUTOLIST # ... and list the possibilities. setopt AUTO_PARAM_SLASH # Make directories pretty. setopt ALWAYS_TO_END # Push that cursor on completions. setopt AUTOCD # jump to the directory. setopt HIST_VERIFY # Make those history commands nice setopt NO_BEEP # self explanatory setopt AUTO_NAME_DIRS # change directories to variable names setopt CHASE_LINKS # if you pwd from a symlink, you get the actual path setopt AUTO_CONTINUE # automatically sent a CONT signal by disown setopt LONG_LIST_JOBS # List jobs in the long format by default setopt EXTENDED_HISTORY setopt HIST_IGNORE_ALL_DUPS setopt HIST_NO_FUNCTIONS setopt HIST_REDUCE_BLANKS # prompt if test -z $SSH_TTY then PROMPT=$'%{\e[01;32m%}\%j,%{\e[01;36m%}%l,%{\e[01;34m%}%?,%{\e[01;33m%}\%1~ %{\e[01;32m%}$%{\e[0m%} ' [ $UID = 0 ] && export PROMPT=$'%{\e[0;31m%}[%{\e[0m%}%n%{\e[0;31m%}@%{\e[0m%}%m%{\e[0;31m%}:%{\e[0m%}%~%{\e[0;31m%}]%{\e[0m%}%# ' else PROMPT=$'%{\e[01;32m%}\%j,%{\e[01;36m%}%m,%{\e[01;34m%}%?,%{\e[01;33m%}\%1~ %{\e[01;32m%}$%{\e[0m%} ' [ $UID = 0 ] && export PROMPT=$'%{\e[0;31m%}[%{\e[0m%}%n%{\e[0;31m%}@%{\e[0m%}%m%{\e[0;31m%}:%{\e[0m%}%~%{\e[0;31m%}]%{\e[0m%}%# ' fi # woo! so glad i found this. jump to each element in a path with m-f m-b, same # for kill-word, etc. export WORDCHARS='' export DIRSTACKSIZE=30 # max push/pop stack watch=(notme) LOGCHECK=300 WATCHFMT='%n %a %l from %m at %t.' # emacs keybinding's bindkey -e # insert all expansions for expand completer zstyle ':completion:*:expand:*' tag-order all-expansions # formatting and messages zstyle ':completion:*' verbose yes zstyle ':completion:*:descriptions' format '%B%d%b' zstyle ':completion:*:messages' format '%d' zstyle ':completion:*:warnings' format 'No matches for: %d' zstyle ':completion:*:corrections' format '%B%d (errors: %e)%b' zstyle ':completion:*' group-name '' # of course export EDITOR='/usr/bin/vim' # favorite pager (give more information) export PAGER='/usr/bin/less -M' # work with history mechanism HISTSIZE=1000 SAVEHIST=1000 HISTFILE=~/.zhistory ############################################################################# # COMMANDLINE COMPLETITION SECTION # only directories for cd && pushcd; nice feature! # or "compctl -g '*(-/)' cd pushd" without hidden dirs compctl -g '*(-/)' + -g '.*(-/)' -v cd pushd # only java files for javac compctl -g '*.java' javac # for ssh && scp connection's compctl -k hosts ssh scp ############################################################################# # KEY - BINDINGS # interactive help? type CTRL-x; CTRL-h bindkey "^X^H" run-help # search for command backward bindkey "^r" history-incremental-search-backward # emulate some bash feelings #bindkey "" backward-delete-word ############################################################################# # FUNCTIONS # look for definitions jargon () { BROWSER="links" JARGON_URL="http://info.astrian.net/jargon/terms" for i in ${*}; do ${BROWSER} ${JARGON_URL}/${i}.html done } # next two entrys found on svens hp => guckes.net # _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; ) } alias calc="noglob _calc" calcfx="noglob _calcfx" function _calc () { awk "BEGIN { print $* ; }" } function _calcfx () { gawk -v CONVFMT="%12.2f" -v OFMT="%.9g" "BEGIN { print $* ; }" } function cvsenv_koctopus { echo cvs -z3 -d:ext:hgndgtl@cvs.sourceforge.net:/cvsroot/koctopus co -P koctopus } function teatime () { # don't worry: visual bell == true! ;-) echo "Teatime!\nAllow to infuse for $1" sleep $1;echo "...ready!\n";while true;do echo -ne '\a';sleep 0.1s;done } # usefull function for quick & dirty hacks ... # FIXME: replace this with a here sting function cvim () { [ -e "$1" ] && echo "File exists!" && return echo -e "#include \n#include \n#include " > $1 echo -e "#include \n#include \n#include " >> $1 echo -e "#include \n#include \n#include \n" >> $1 echo -e "#include \n#include " >> $1 echo -e "#include \n#include \n#include " >> $1 echo -e "\nint\nmain(int argc, char *argv[])\n{" >> $1 echo -e "\tint ret = 0;\n\n\n\treturn ret;\n}\n\n" >> $1 echo -e "/* vim:set ft=c ts=4 sw=4 tw=78 noet: */" >> $1 eval vim -c '+20' $1 }