wok-stable annotate zsh/stuff/example.zshrc @ rev 3054
linux-wireless: add rt2860sta
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Wed May 13 16:40:57 2009 +0200 (2009-05-13) |
parents | |
children |
rev | line source |
---|---|
pascal@1531 | 1 # history |
pascal@1531 | 2 HISTFILE=~/.zsh_history |
pascal@1531 | 3 HISTSIZE=5000 |
pascal@1531 | 4 SAVEHIST=1000 |
pascal@1531 | 5 setopt appendhistory autocd extendedglob |
pascal@1531 | 6 setopt EXTENDED_HISTORY # puts timestamps in the history |
pascal@1531 | 7 |
pascal@1531 | 8 # default apps |
pascal@1531 | 9 (( ${+BROWSER} )) || export BROWSER="w3m" |
pascal@1531 | 10 (( ${+PAGER} )) || export PAGER="less" |
pascal@1531 | 11 |
pascal@1531 | 12 BLACK="%{"$'\033[01;30m'"%}" |
pascal@1531 | 13 GREEN="%{"$'\033[01;32m'"%}" |
pascal@1531 | 14 RED="%{"$'\033[01;31m'"%}" |
pascal@1531 | 15 YELLOW="%{"$'\033[01;33m'"%}" |
pascal@1531 | 16 BLUE="%{"$'\033[01;34m'"%}" |
pascal@1531 | 17 BOLD="%{"$'\033[01;39m'"%}" |
pascal@1531 | 18 NORM="%{"$'\033[00m'"%}" |
pascal@1531 | 19 |
pascal@1531 | 20 |
pascal@1531 | 21 # prompt (if running screen, show window #) |
pascal@1531 | 22 if [ x$WINDOW != x ]; then |
pascal@1531 | 23 export PS1="$WINDOW:%~%# " |
pascal@1531 | 24 else |
pascal@1531 | 25 export PS1="[${RED}%n${YELLOW}@${BLUE}%U%m%u$:${GREEN}%2c${NORM}]%(!.#.$) " |
pascal@1531 | 26 #right prompt - time/date stamp |
pascal@1531 | 27 export RPS1="${GREEN}(%D{%m-%d %H:%M})${NORM}" |
pascal@1531 | 28 fi |
pascal@1531 | 29 |
pascal@1531 | 30 # format titles for screen and rxvt |
pascal@1531 | 31 function title() { |
pascal@1531 | 32 # escape '%' chars in $1, make nonprintables visible |
pascal@1531 | 33 a=${(V)1//\%/\%\%} |
pascal@1531 | 34 |
pascal@1531 | 35 # Truncate command, and join lines. |
pascal@1531 | 36 a=$(print -Pn "%40>...>$a" | tr -d "\n") |
pascal@1531 | 37 |
pascal@1531 | 38 case $TERM in |
pascal@1531 | 39 screen) |
pascal@1531 | 40 print -Pn "\ek$a:$3\e\\" # screen title (in ^A") |
pascal@1531 | 41 ;; |
pascal@1531 | 42 xterm*|rxvt) |
pascal@1531 | 43 print -Pn "\e]2;$2 | $a:$3\a" # plain xterm title |
pascal@1531 | 44 ;; |
pascal@1531 | 45 esac |
pascal@1531 | 46 } |
pascal@1531 | 47 |
pascal@1531 | 48 # precmd is called just before the prompt is printed |
pascal@1531 | 49 function precmd() { |
pascal@1531 | 50 title "zsh" "$USER@%m" "%55<...<%~" |
pascal@1531 | 51 } |
pascal@1531 | 52 |
pascal@1531 | 53 # preexec is called just before any command line is executed |
pascal@1531 | 54 function preexec() { |
pascal@1531 | 55 title "$1" "$USER@%m" "%35<...<%~" |
pascal@1531 | 56 } |
pascal@1531 | 57 |
pascal@1531 | 58 # vi editing |
pascal@1531 | 59 bindkey -v |
pascal@1531 | 60 |
pascal@1531 | 61 # colorful listings |
pascal@1531 | 62 zmodload -i zsh/complist |
pascal@1531 | 63 zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS} |
pascal@1531 | 64 |
pascal@1531 | 65 autoload -U compinit |
pascal@1531 | 66 compinit |
pascal@1531 | 67 |
pascal@1531 | 68 # aliases |
pascal@1531 | 69 alias mv='nocorrect mv' # no spelling correction on mv |
pascal@1531 | 70 alias cp='nocorrect cp' |
pascal@1531 | 71 alias mkdir='nocorrect mkdir' |
pascal@1531 | 72 alias j=jobs |
pascal@1531 | 73 if ls -F --color=auto >&/dev/null; then |
pascal@1531 | 74 alias ls="ls --color=auto -F" |
pascal@1531 | 75 else |
pascal@1531 | 76 alias ls="ls -F" |
pascal@1531 | 77 fi |
pascal@1531 | 78 alias ll="ls -l" |
pascal@1531 | 79 alias ..='cd ..' |
pascal@1531 | 80 alias .='pwd' |
pascal@1531 | 81 |
pascal@1531 | 82 # functions |
pascal@1531 | 83 setenv() { export $1=$2 } # csh compatibility |
pascal@1531 | 84 |
pascal@1531 | 85 #bash style ctrl-a (beginning of line) and ctrl-e (end of line) |
pascal@1531 | 86 bindkey '^a' beginning-of-line |
pascal@1531 | 87 bindkey '^e' end-of-line |
pascal@1531 | 88 |
pascal@1531 | 89 # Emulate tcsh's backward-delete-word |
pascal@1531 | 90 tcsh-backward-delete-word () { |
pascal@1531 | 91 #local WORDCHARS="${WORDCHARS:s#/#}" |
pascal@1531 | 92 local WORDCHARS='*?_[]~\!#$%^<>|`@#$%^*()+?' |
pascal@1531 | 93 zle backward-delete-word |
pascal@1531 | 94 } |
pascal@1531 | 95 |
pascal@1531 | 96 zle -N tcsh-backward-delete-word |
pascal@1531 | 97 |
pascal@1531 | 98 bindkey '\e^H' tcsh-backward-delete-word |
pascal@1531 | 99 |
pascal@1531 | 100 #if this is uncommented, it will ignore the stop-at-special-chars |
pascal@1531 | 101 #bindkey '\e^H' backward-delete-word |
pascal@1531 | 102 |
pascal@1531 | 103 #uncomment this to have a nice update script that will cause ur zshrc to update from a central location |
pascal@1531 | 104 |
pascal@1531 | 105 #selfupdate(){ |
pascal@1531 | 106 # URL="http://stuff.mit.edu/~jdong/misc/zshrc" |
pascal@1531 | 107 # echo "Updating zshrc from $URL..." |
pascal@1531 | 108 # echo "Press Ctrl+C within 5 seconds to abort..." |
pascal@1531 | 109 # sleep 5 |
pascal@1531 | 110 # cp ~/.zshrc ~/.zshrc.old |
pascal@1531 | 111 # wget $URL -O ~/.zshrc |
pascal@1531 | 112 # echo "Done; existing .zshrc saved as .zshrc.old" |
pascal@1531 | 113 #} |