#!/bin/zsh # File: .zshrc # By: Hai Binh Nguyen # Date: 23-01-2002 # Desc: personalised zsh start-up script # the autocompletions are highly customised and are mostly for slack ;) ################################################################################ # GLOBAL VARS ################################################################## GTK_IM_MODULE=xim LANG=en_US.UTF-8 #LC_CTYPE=en_US.UTF-8 CFLAGS="-O3 -s" EDITOR=vim # sometimes I like to keep a history of my crap HISTSIZE=2000 SAVEHIST=9000 HISTFILE="$HOME/.zhistory" # additional path stuff if [ `echo $PATH_ADDED`x = x ] ; then PATH="$HOME/bin/:$PATH" PATH_ADDED=1 fi ################################################################################ # MISCELLANEOUS ################################################################ if [ -f ~/.ssh/.binh ] ; then ~/bin/keychain -q ~/.ssh/.binh . ~/.keychain/`uname -n`-sh fi #if [ -f .xsession-errors ] ; then # \rm .xsession-errors -rf #fi #dccm setterm -bfreq 0 ulimit -c 0 umask 077 if [ `whoami` = root ] ; then umask 022 fi watch=(notme) LOGCHECK=60 WATCHFMT='%n %a %l from %m at %t.' #stty erase ^\? #stty erase ^h ################################################################################ # ALIASES ###################################################################### if [ `whoami` = nguyen ] ; then alias bzflag="echo 'dont run bzflag you idiot'" fi alias zfresh='source $HOME/.zshrc' if [ -d ~/bin ] ; then alias rm="$HOME/bin/safe_rm" alias trash="$HOME/bin/trash" alias man="$HOME/bin/man_fixed" alias irssi="$HOME/bin/irssi_mine" fi alias md="mkdir" alias ..="cd .." alias ...="cd ../.." alias ....="cd ../../.." alias .....="cd ../../../.." alias gpp="g++" alias vi="vim" alias gvim="gvim -geom 111x60" alias c="clear" alias f="finger -s" alias k="chmod 600" alias x="chmod 700" alias ls="ls --color" alias la="ls -lhAF --color" alias ll="ls -liAF --color" ################################################################################ # PROMPT ####################################################################### BLK='%{%}' RED='%{%}' GRN='%{%}' YLW='%{%}' BLU='%{%}' MAG='%{%}' CYAN='%{%}' GRAY='%{%}' BOLD='%{%}' ULINE='%{%}' OFF='%{%}' function precmd { local TERMWIDTH (( TERMWIDTH = ${COLUMNS} - 1 )) local pwdlen="" local BAR='-' local fill="" let local promptsize=$(print -Pn -- "-[%n@%m:%l][]-" | wc -c | tr -d " ") let local pwdsize=$(print -Pn -- "%/" | wc -c | tr -d " ") if [[ "$promptsize + $pwdsize" -gt $TERMWIDTH ]]; then let pwdlen="$TERMWIDTH - $promptsize - 3" fill="$BAR$BAR$BAR$BAR" else let fillsize="$TERMWIDTH - ($promptsize + $pwdsize)-3" while [[ $fillsize -gt -4 ]] do fill="${fill}$BAR" let fillsize=${fillsize}-1 done fi PROMPT="$BEGINNING_OF_LINE\ $CYAN$BAR"["$OFF$YLW%n$CYAN"@"$MAG%m$OFF$CYAN":"$GRN%l$OFF$CYAN"]"\ $CYAN$fill"["$RED%$pwdlen<...<%/%<<$OFF$CYAN"]"$BAR\ $BAR$GRAY"$" $OFF" } ################################################################################ # AUTOCOMPLETES ################################################################ autoload -U compinit compinit bindkey "^[OH" beginning-of-line bindkey "^[OF" end-of-line bindkey "^B" backward-word bindkey "^F" forward-word zstyle ':completion:*' completer _complete _list _oldlist _expand _ignored _match _correct _approximate _prefix #slack package-management compdef -a _slackpack installpkg upgradepkg removepkg makepkg pkgtool explodepkg _slackpack() { local flags case "$service" in installpkg) _arguments -s $flags[@] '*:*:_files -g \*.tgz' ;; removepkg) _arguments -s $flags[@] '*:*:_files -W /var/log/packages/ -/' ;; upgradepkg) _arguments -s $flags[@] '*:*:_files -g \*.tgz' ;; explodepkg) _arguments -s '*:*:_files -g \*.tgz' ;; makepkg) _arguments -s $flags[@] ;; pkgtool) _arguments -s $flags[@] ;; esac } _slackpack "$@" #stuff not in the default system zstyle ':completion:*:*:unrar:*' file-patterns\ '*.(rar|RAR):*\ files *(-/):directories' zstyle ':completion:*:*:wine:*' file-patterns\ '*.exe:*\ files *(-/):directories' zstyle ':completion:*:*:(rpm2tgz|rpm2tgz_install):*' file-patterns\ '*.rpm:*\ files *(-/):directories' zstyle ':completion:*:*:display:*' file-patterns\ '*.(tiff|GIF|gif|JPG|jpg|bmp|xpm|png|svg|ppm|xpm|pcx):*\ files *(-/):directories' zstyle ':completion:*:*:(xmms|amp):*' file-patterns\ '*.(m3u|mp3|ogg):*\ files *(-/):directories' #add colors to completions zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS} #ps zstyle ':completion:*:processes' command 'ps -au$USER' #kill #zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31' ################################################################################