# ~/.zshrc: executed by zsh # Rechte von neuen Dateien korrekt setzen umask 022 ############# PROMPT #################################### setprompt () { setopt prompt_subst autoload colors zsh/terminfo if [[ "$terminfo[colors]" -ge 8 ]]; then colors fi for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; do eval PR_$color='%{$terminfo[bold]$fg[${(L)color}]%}' eval PR_LIGHT_$color='%{$fg[${(L)color}]%}' (( count = $count + 1 )) done PR_NO_COLOUR="%{$terminfo[sgr0]%}" typeset -A altchar set -A altchar ${(s..)terminfo[acsc]} PR_SET_CHARSET="%{$terminfo[enacs]%}" PR_SHIFT_IN="%{$terminfo[smacs]%}" PR_SHIFT_OUT="%{$terminfo[rmacs]%}" PR_HBAR=${altchar[q]:--} P_ULCORNER=${altchar[l]:--} PR_LLCORNER=${altchar[m]:--} PR_LRCORNER=${altchar[j]:--} PR_URCORNER=${altchar[k]:--} case $TERM in xterm*) PR_TITLEBAR=$'%{\e]0;%(!.-=*[ROOT]*=- | .)%n@%m:%~ | ${COLUMNS}x${LINES} | %y\a%}' ;; screen) PR_TITLEBAR=$'%{\e_screen \005 (\005t) | %(!.-=[ROOT]=- | .)%n@%m:%~ | ${COLUMNS}x${LINES} | %y\e\\%}' ;; *) PR_TITLEBAR='' ;; esac if [[ "$TERM" == "screen" ]]; then PR_STITLE=$'%{\ekzsh\e\\%}' else PR_STITLE='' fi if which ibam > /dev/null; then PR_APM='$PR_RED${${PR_APM_RESULT[(f)1]}[(w)-2]}%%(${${PR_APM_RESULT[(f)3]}[(w)-1]})$PR_LIGHT_BLUE:' elif which apm > /dev/null; then PR_APM='$PR_RED${PR_APM_RESULT[(w)5,(w)6]/\% /%%}$PR_LIGHT_BLUE:' else PR_APM='' fi PROMPT='$PR_SET_CHARSET$PR_STITLE${(e)PR_TITLEBAR}\ $PR_CYAN$PR_SHIFT_IN$PR_ULCORNER$PR_BLUE$PR_HBAR$PR_SHIFT_OUT(\ $PR_GREEN%(!.%SROOT%s.%n)$PR_BLUE@$PR_GREEN%m$PR_BLUE:$PR_MAGENTA%d\ $PR_BLUE)$PR_SHIFT_IN$PR_HBAR$PR_CYAN$PR_HBAR${(e)PR_FILLBAR}\ $PR_SHIFT_IN$PR_HBAR$PR_CYAN$PR_URCORNER$PR_SHIFT_OUT\ $PR_CYAN$PR_SHIFT_IN$PR_LLCORNER$PR_BLUE$PR_HBAR$PR_SHIFT_OUT(\ %(?,$PR_LIGHT_GREEN%?,$PR_RED%?)\ ${(e)PR_APM}\ $PR_LIGHT_BLUE:%(!.$PR_RED.$PR_WHITE)%#$PR_BLUE)$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT\ $PR_CYAN$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT\ $PR_NO_COLOUR ' RPROMPT='$PR_CYAN$PR_SHIFT_IN$PR_HBAR$PR_CYAN$PR_LRCORNER$PR_SHIFT_OUT$PR_NO_COLOUR' PS2='$PR_CYAN$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT\ $PR_BLUE$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT(\ $PR_LIGHT_GREEN%_$PR_BLUE)$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT\ $PR_CYAN$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT$PR_NO_COLOUR ' } setprompt ############# INCLUDE #################################### # record from ~/misc/calendar if [[ -x /usr/bin/calendar && -f ${HOME}/misc/calendar ]] then print /usr/bin/calendar -A 3 -f ${HOME}/misc/calendar print fi # fortune cookie if [[ -x /usr/games/fortune ]] then /usr/games/fortune fi ############# EXPORT ###################################### # History auf 3000 Eintraege erweitern HISTSIZE=3000 SAVEHIST=3000 # Ort + Name der History HISTFILE=~/.zsh_history if [[ -n ${SSH_CLIENT} && ${TERM} != "screen" ]] then TMOUT=600 fi # Farben fuer ls definieren LS_COLORS='no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.svgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01; 35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:' export LS_COLORS # Farben fuer man definieren export LESS_TERMCAP_mb=$'\E[01;35m' export LESS_TERMCAP_md=$'\E[0;34m' export LESS_TERMCAP_me=$'\E[0m' export LESS_TERMCAP_se=$'\E[0m' export LESS_TERMCAP_so=$'\E[01;44;33m' export LESS_TERMCAP_ue=$'\E[0m' export LESS_TERMCAP_us=$'\E[0m' export ZLSCOLORS="${LS_COLORS}" export GREP_OPTIONS="--color=auto" export PAGER="less" export TMPDIR="/tmp" export TZ="Europe/Berlin" export VISUAL=${EDITOR} export CDPATH=":..:${HOME}:/" export EDITOR="vim.gtk" ############# SETOPT ###################################### setopt AUTO_CD \ AUTO_PUSHD \ AUTO_LIST \ AUTO_MENU \ MENU_COMPLETE \ PUSHD_IGNORE_DUPS \ CHASE_LINKS \ COMPLETE_IN_WORD \ CORRECT \ EXTENDED_GLOB \ GLOB_DOTS \ HIST_IGNORE_ALL_DUPS \ HIST_IGNORE_SPACE \ HIST_NO_STORE \ HIST_REDUCE_BLANKS \ HIST_VERIFY \ INC_APPEND_HISTORY \ LONG_LIST_JOBS \ MARK_DIRS \ NO_NOTIFY \ PUSHD_IGNORE_DUPS \ PUSHD_SILENT \ SHARE_HISTORY \ TRANSIENT_RPROMPT ############# AUTOLOAD ###################################### autoload -Uz promptinit promptinit prompt walters # moderne + bunte Vervollstaendigung aktivieren autoload colors ; colors autoload -Uz compinit compinit -C ############# ZSTYLE ###################################### zstyle ':completion:*' completer _complete _match _approximate _expand zstyle ':completion:*:match:*' original only zstyle ':completion:*:approximate:*' max-errors 1 numeric zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31' zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd' compdef pkill=kill compdef pkill=killall zstyle ':completion:*:cd:*' ignore-parents parent pwd zstyle ':completion::complete:*' '\\' zstyle ':completion:*:descriptions' format $'\e[01;33m -- %d --\e[0m' zstyle ':completion:*:messages' format $'\e[01;35m -- %d --\e[0m' zstyle ':completion:*:warnings' format "No match in: %B%d%b"zstyle ':completion:*' format 'Completing %d' zstyle ':completion:*:matches' group 'yes' zstyle ':completion:*:options' description 'yes' zstyle ':completion:*:options' auto-description '%d' zstyle ':completion:*:warnings' format $'\e[01;31m -- No Matches Found --\e[0m' zstyle ':completion:*:*:*:default' menu yes select zstyle ':completion:*:*:default' force-list always zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS} zstyle ':completion:*' auto-description 'specify: %d' zstyle ':completion:*' group-name '' zstyle ':completion:*' menu select=2 zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS} zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}' 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=* l:|=*' zstyle ':completion:*' menu select=long zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s zstyle ':completion:*' use-compctl false zstyle ':completion:*' verbose true zstyle ':completion:*' use-cache on zstyle ':completion:*' cache-path ~/.zsh/cache zstyle ':completion:*' expand 'yes' zstyle ':completion:*' squeeze-shlashes 'yes' ############# BINDKEY ###################################### # Tasten fest definieren bindkey -e bindkey '^i' expand-or-complete-prefix # Tab bindkey "^[[2~" yank # Insert bindkey "^[[3~" delete-char # Del bindkey "^[[5~" history-beginning-search-backward # PageUp bindkey "^[[6~" history-beginning-search-forward # PageDown bindkey "^[e" expand-cmd-path # Alt-e bindkey "^[[A" up-line-or-search # up arrow bindkey "^[[B" down-line-or-search # down arrow bindkey " " magic-space # history expansion on space ############# ALIAS ###################################### alias -s html=w3m alias -s ini=vim.gtk alias -s conf=vim.gtk # ls-Befehl optimieren if [ "$TERM" != "dumb" ]; then eval "$(dircolors -b)" # verleiht dem "ls"-Befehl Farbe alias ls='ls --color=auto -Fh' # zeigt alle Dateien und Verzeichnisse ausfuehrlich an alias la='ls -laFh --color=auto' # zeigt Dateien und Verzeichnisse ausfuehrlich an alias ll='ls -lFh --color=auto --group-directories-first' # zeigt die zuletzt geaenderten Dateien unten an alias llr='ls -lartFh --color=auto --group-directories-first' # zeigt Dateien und Verzeichnisse an alias dir='ls --color=auto --format=vertical' # zeigt mehr Infos zu Dateien und Verzeichnissen an alias vdir='ls --color=auto --format=long' fi alias rm='rm -I' # zeigt einen Verzeichnis-Baum an alias tree='tree -Csu' # workaround fuer alte aptitude Version & grosser sources.list alias aptitude-update='export LANG=C ; aptitude update ; export LANG=de_DE.UTF-8' # update sources.list alias checkupdates='sudo apt-get update' # alias mkdd='mkdir $(date +%Y%m%d)' alias mkdd='mkdir $(date +%Y%m%d)' # fuegt einen neuen Key Launchpad PPAs fuer Ubuntu hinzu alias launchpadkey='sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys' # Ergebnisse von grep werden nun farblich markiert if [ -x /usr/bin/dircolors ]; then test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" eval $(dircolors --bourne-shell) fi alias grep='grep --color=auto' alias fgrep='fgrep --color=auto' alias egrep='egrep --color=auto' # zeigt den aktuellen Timestamp im ISO 8601 Format an alias timestamp='date "+%Y%m%dT%H%M%S"' # zeigt rekursiv Dateien und Verzeichnisse die in der letzten Stunde anfasst wurden an alias lf='find ./* -ctime -1 | xargs ls -ltr --color' # zeigt deine oeffentliche IP-Adresse an alias myip='GET http://www.whatismyip.com/automation/n09230945.asp && echo' # wechselt ein Verzeichnis nach oben alias ..='cd ../' # wechselt zwei Verzeichnisse nach oben alias ::='cd ../..' # zeigt die/den entsprechenden Prozess an alias 'psx'='ps auxwf | grep' # zeigt die Prozessstruktur uebersichtlich an alias pst='pstree -Alpha' # zeigt alle meine Prozesse an alias psmy='ps -ef | grep $USER' # zeigt die Ports an, welche die Applikationen verwenden alias lsport='sudo lsof -i -T -n' # zeigt weitere Infos üie Ports an, welche die Applikationen verwenden alias llport='netstat -nape --inet' # zeigt den Festplattenverbrauch eines Verzeichnisses leserlich an alias du='du -kh' # zeigt den kompletten Festplattenverbrauch leserlich an alias df='df -kTh' ############# FUNCTION ######################################## # entpacken von Komprimierten Dateien extract() { if [ -f $1 ] ; then case $1 in *.tar.bz2) tar xvjf $1 ;; *.tar.gz) tar xvzf $1 ;; *.bz2) bunzip2 $1 ;; *.rar) unrar x $1 ;; *.gz) gunzip $1 ;; *.tar) tar xvf $1 ;; *.tbz2) tar xvjf $1 ;; *.tgz) tar xvzf $1 ;; *.zip) unzip $1 ;; *.Z) uncompress $1 ;; *.7z) 7z x $1 ;; *) echo "'$1' cannot be extracted via >extract<" ;; esac else echo "'$1' is not a valid file" fi } # zeigt alle Dateien in dem akuellen Verzeichnis an (rekursiev) ff() { find . -type f -iname '*'$*'*' -ls ; } # Finde Text in Dateien fstr() { OPTIND=1 local case="" local usage="fstr: find string in files. Usage: fstr [-i] \"pattern\" [\"filename pattern\"] " while getopts :it opt do case "$opt" in i) case="-i " ;; *) echo "$usage"; return;; esac done shift $(( $OPTIND - 1 )) if [ "$#" -lt 1 ]; then echo "$usage" return; fi find . -type f -name "${2:-*}" -print0 | \ xargs -0 egrep --color=always -sn ${case} "$1" 2>&- | more } # Infos zu einer Datei ausgeben file_information() { if [ $1 ]; then PLACE=`type -path $1` if [ -z $PLACE ]; then echo "$1: not found"; return 1; fi echo $PLACE ls -l $PLACE file $PLACE ldd $PLACE else echo "Missing argument" fi } alias finfo=file_information # ein Backup einer Datei anlegen (mit Datum) file_backup() { for FILE ; do [[ -e "$1" ]] && cp "$1" "${1}_$(date +%Y-%m-%d_%H-%M-%S)" || echo "\"$1\" not found." >&2 done } alias fback=file_backup # Ein komprimiertes Backup + Datum erstellen packen() { tar czvf "$1-$(date +%y%m%d-%H%M%S).tar.gz" "$1" ; } # ssh Verbindung aufbauen + ein Logfile schreiben logssh() { ssh $1 | tee sshlog ; } # mehrere Dateien gleichzeitig aendern replace() { if [ $3 ]; then find $1 -type f | xargs perl -pi -e 's/$2/$3/g' else echo "Missing argument" fi }