# zshrc - ZSH Configuration File # Author: Sean B. Palmer, inamidst.com VERSION='2006-09-08' # Are we running remotely over ssh? case $SSH_CLIENT { 192.*|127.*|) REMOTE=0;; *) REMOTE=1;; } # Set PS1 based on locality if (( ! $REMOTE )) { PS1=$(echo -n "\n%{\e[32m%}%n@%m %{\e[36m%}%~%{\e[0m%}\n$ ") } else { PS1=$(echo -n "\n%n@%m %~\n$ ") } PS2='> ' # Set the title if [[ $TERM = xterm ]] { function precmd() { print -Pn "\e]0;%n@%m: %~\a"; } } # Environment Variables # Add DarwinPorts junk to path... export PATH=/usr/local/bin:/usr/local/sbin:/opt/local/bin:$PATH:~/scripts export HISTFILE=~/.zsh_history export HISTSIZE=50000 export SAVEHIST=50000 export HISTCONTROL=ignoredups export DIRSTACKSIZE=10 # @@ zsh only? # Cf. http://swhack.com/logs/2005-06-03#T21-40-26 export TIMEFMT=$'real\t%*Es\nuser\t%*Us\nsys \t%*Ss\ncpu \t%P' export INPUTRC=~/.inputrc export TZ=Europe/London # if [[ $(uname -o) != Cygwin ]] { # export LANG=en_GB.UTF-8 # } # According to its manpage, crontab uses "the editor specified by the # VISUAL or EDITOR environment variables [or] /usr/bin/editor" export EDITOR=emacs export GUIEDITOR=e # Other Stuff umask 0077 # Stop Ctrl+S and Ctrl+Q from being annoying # @@ get it to work after an ssh crash stty start "" stty stop "" # Key Bindings # @@ compctl -g "*(-/) .*(-/)" cd bindkey "\e[7~" beginning-of-line bindkey "\e[8~" end-of-line bindkey "\e[3~" delete-char bindkey "\e[5~" history-search-backward bindkey "\e[6~" history-search-forward # bindkey "^m" self-insert # ZSH Specific Options setopt autopushd pushdminus pushdsilent pushdtohome setopt autocd setopt cdablevars # cf. http://zsh.sunsite.dk/Intro/intro_2.html setopt extendedglob setopt globdots setopt ignoreeof setopt interactivecomments setopt noclobber setopt HIST_REDUCE_BLANKS setopt HIST_IGNORE_SPACE # Decent completion, for make etc. autoload -U compinit compinit -u # Aliases alias ls='ls -aF' # @@ AF? alias wget='wget -c' alias decr=dos2unix alias recr=unix2dos alias uhm='fc -l -7' alias dh='dirs -v' alias ducks='du -cks -h' # Shouldn't do this really, but... alias cp='cp -i' alias mv='mv -i' # if [[ ("$TERM" = screen) || (-n "$STY") ]] { # alias exit='echo BAD. YOU ARE IN SCREEN' # } # Some local stuff eval "www=$HOME/web/inamidst.com/www" && : ~www function chpwd() { case $OLDPWD in $HOME/web/inamidst.com/www*) umask 0077;; esac case $PWD in $HOME/web/inamidst.com/www*) umask 0022;; esac } # Temporary alias for nano -> emacs function nano() { echo "Try 'emacs $@' (or =nano)" } # Useful Functions # Some magic from deltab: http://swhack.com/logs/2004-08-13#T00-22-44-1 function withcd() { (cd "$1" && shift && "$@"); } # @@ The ZSH documentation's version of this doesn't work # http://zsh.sunsite.dk/Intro/intro_5.html function namedir() { eval "$1=$PWD" && : ~$1 echo Named $PWD '~'$1 } # Quickly cd function ,() { case "$PWD" { ~/web/inamidst.com/www) cd ~/stuff;; *) cd ~/web/inamidst.com/www;; } } # For OS X function spotfind() { mdfind "kMDItemDisplayName == '$@'wc" } # Messages # @@ These should probably be in .zlogin # Cf. http://zsh.sunsite.dk/Intro/intro_3.html#SEC3 echo -en "Using $ZSH_VERSION; $TERM; " date +"%Y-%m-%d %H:%M:%S" echo "(And .zshrc $VERSION)" # [EOF]