Commits

Bruce Wang committed 760a7c0

可以输中文的版本!

Comments (0)

Files changed (1)

+# history
+HISTFILE=~/.zsh_history
+HISTSIZE=5000
+SAVEHIST=1000
+setopt appendhistory autocd extendedglob
 
+# default apps
+  (( ${+BROWSER} )) || export BROWSER="w3m";
+  (( ${+PAGER} ))   || export PAGER="less";
 
-# next lets set some enviromental/shell pref stuff up
-# setopt NOHUP
-#setopt NOTIFY
-#setopt NO_FLOW_CONTROL
-setopt INC_APPEND_HISTORY SHARE_HISTORY
-setopt APPEND_HISTORY
-# setopt AUTO_LIST		# these two should be turned off
-# setopt AUTO_REMOVE_SLASH
-# setopt AUTO_RESUME		# tries to resume command of same name
-unsetopt BG_NICE		# do NOT nice bg commands
-setopt CORRECT			# command CORRECTION
-setopt EXTENDED_HISTORY		# puts timestamps in the history
-# setopt HASH_CMDS		# turns on hashing
-#
 setopt MENUCOMPLETE
-setopt ALL_EXPORT
+
 
 # Some options..
 setopt   notify globdots pushdtohome cdablevars autolist
 setopt   autopushd pushdminus extendedglob rcquotes mailwarning
 unsetopt bgnice autoparamslash
 
-setopt MULTIBYTE
 
-# Autoload zsh modules when they are referenced
-zmodload -a zsh/stat stat
-zmodload -a zsh/zpty zpty
-zmodload -a zsh/zprof zprof
-#zmodload -ap zsh/mapfile mapfile
+# prompt (if running screen, show window #)
+if [ x$WINDOW != x ]; then
+    PROMPT="$WINDOW:%~"
+else
+    PROMPT='%~'
+fi
 
-# Set some vars for progs
-HISTFILE=$HOME/.zhistory
-HISTSIZE=50000
-SAVEHIST=50000
-
-# Prompt, PS1 is left, RPS1 is right.
-
-HOSTNAME="`hostname`"
-PAGER='less'
-EDITOR='vim'
-    autoload colors zsh/terminfo
-    if [[ "$terminfo[colors]" -ge 8 ]]; then
+setopt ALL_EXPORT
+autoload colors zsh/terminfo
+if [[ "$terminfo[colors]" -ge 8 ]]; then
    colors
-    fi
-    for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; do
+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_COLOR="%{$terminfo[sgr0]%}"
-PS1="[ $PR_RED%2c$PR_NO_COLOR ]%(!.#.$) "
+done
+PR_NO_COLOR="%{$terminfo[sgr0]%}"
+PS1="[ $PR_RED$PROMPT$PR_NO_COLOR ]%(!.#.$) "
 RPS1="$PR_LIGHT_YELLOW(%D{%m-%d %H:%M})$PR_NO_COLOR"
-LANGUAGE=en_US
-LC_ALL='en_US.UTF-8'
-LANG='en_US.UTF-8'
-LC_CTYPE=C
-
-LESSCHARSET=UTF-8
 
 # Shell options
 TIMEFMT=$'real\t%*Es\nuser\t%*Us\nsys \t%*Ss\ncpu \t%P'
 
 unsetopt ALL_EXPORT
 
+# format titles for screen and rxvt
+function title() {
+  # escape '%' chars in $1, make nonprintables visible
+  a=${(V)1//\%/\%\%}
 
-# # --------------------------------------------------------------------
-# # aliases
-# # --------------------------------------------------------------------
+  # Truncate command, and join lines.
+  a=$(print -Pn "%40>...>$a" | tr -d "\n")
 
-alias man='LC_ALL=C LANG=C man'
-alias f=finger
-alias ll='ls -al'
-alias ls='ls --color=auto '
-alias rest2html-css='rst2html --embed-stylesheet --stylesheet-path=/usr/share/python-docutils/s5_html/themes/default/print.css'
+  case $TERM in
+  screen)
+    print -Pn "\ek$a:$3\e\\"      # screen title (in ^A")
+    ;;
+  xterm*|rxvt)
+    print -Pn "\e]2;$2 | $a:$3\a" # plain xterm title
+    ;;
+  esac
+}
 
-# Completion rules
-# for appropriate extensions for that proggy.
-compctl -g '*.py' python
-compctl -g '*.(jpg|png|gif)' eog feh
+# precmd is called just before the prompt is printed
+function precmd() {
+  title "zsh" "$USER@%m" "%55<...<%~"
+}
+
+# preexec is called just before any command line is executed
+function preexec() {
+  title "$1" "$USER@%m" "%35<...<%~"
+}
+
+# vi editing
+bindkey -v
+
+# colorful listings
+zmodload -i zsh/complist
 
 autoload -U compinit
 compinit
-bindkey -v
-bindkey '\e[3~' delete-char
-bindkey "^?" backward-delete-char
-bindkey '^[OH' beginning-of-line
-bindkey '^[OF' end-of-line
-bindkey '^[[5~' up-line-or-history
-bindkey '^[[6~' down-line-or-history
-bindkey "^r" history-incremental-search-backward
-bindkey ' ' magic-space    # also do history expansion on space
-bindkey '^I' complete-word # complete on tab, leave expansion to _expand
 zstyle ':completion::complete:*' use-cache on
 zstyle ':completion::complete:*' cache-path ~/.zsh/cache/$HOST
 
 # list of completers to use
 # n:*' list-prompt '%SAt %p: Hit TAB for more, or the charac    ter to insert%s'
 zstyle ':completion:*::::' completer _expand _complete _ignored _approximate
-
-# allow one error for every three characters typed in approximate completer
-zstyle -e ':completion:*:approximate:*' max-errors \
-    'reply=( $(( ($#PREFIX+$#SUFFIX)/2 )) numeric )'
-    
-# 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 ''
-
 # match uppercase from lowercase
 zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
 
 # offer indexes before parameters in subscripts
 zstyle ':completion:*:*:-subscript-:*' tag-order indexes parameters
-
-# command for process lists, the local web server details and host completion
-# on processes completion complete all user processes
-# zstyle ':completion:*:processes' command 'ps -au$USER'
-
-## add colors to processes for kill completion
-zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
-
-#zstyle ':completion:*:processes' command 'ps ax -o pid,s,nice,stime,args | sed "/ps/d"'
-zstyle ':completion:*:*:kill:*:processes' command 'ps --forest -A -o pid,user,cmd'
-zstyle ':completion:*:processes-names' command 'ps axho command' 
-#zstyle ':completion:*:urls' local 'www' '/var/www/htdocs' 'public_html'
-#
-#NEW completion:
-# 1. All /etc/hosts hostnames are in autocomplete
-# 2. If you have a comment in /etc/hosts like #%foobar.domain,
-#    then foobar.domain will show up in autocomplete!
 zstyle ':completion:*' hosts $(awk '/^[^#]/ {print $2 $3" "$4" "$5}' /etc/hosts | grep -v ip6- && grep "^#%" /etc/hosts | awk -F% '{print $2}') 
 # Filename suffixes to ignore during completion (except after rm command)
 zstyle ':completion:*:*:(^rm):*:*files' ignored-patterns '*?.o' '*?.c~' \
     '*?.old' '*?.pro'
-# the same for old style completion
-#fignore=(.o .c~ .old .pro)
 
-# ignore completion functions (until the _ignored completer)
-zstyle ':completion:*:functions' ignored-patterns '_*'
-zstyle ':completion:*:*:*:users' ignored-patterns \
-        adm apache bin daemon games gdm halt ident junkbust lp mail mailnull \
-        named news nfsnobody nobody nscd ntp operator pcap postgres radvd \
-        rpc rpcuser rpm shutdown squid sshd sync uucp vcsa xfs avahi-autoipd\
-        avahi backup messagebus beagleindex debian-tor dhcp dnsmasq fetchmail\
-        firebird gnats haldaemon hplip irc klog list man cupsys postfix\
-        proxy syslog www-data mldonkey sys snort
 # SSH Completion
 zstyle ':completion:*:scp:*' tag-order \
    files users 'hosts:-host hosts:-domain:domain hosts:-ipaddr"IP\ Address *'
 
 
 
-# To kill agents through keychain.
-alias kagent="/usr/bin/keychain --stop all"
-# To start keychain and source agent variables.
-alias agent="/usr/bin/keychain -q ~/.ssh/id_dsa; . ~/.keychain/$(hostname)-sh"
+# aliases
+alias mv='nocorrect mv'       # no spelling correction on mv
+alias cp='nocorrect cp'
+alias mkdir='nocorrect mkdir'
+alias j=jobs
+if ls -F --color=auto >&/dev/null; then
+  alias ls="ls --color=auto -F"
+else
+  alias ls="ls -F"
+fi
+alias ll="ls -l"
+alias l.='ls -d .[^.]*'
+alias lsd='ls -ld *(-/DN)'
+alias md='mkdir -p'
+alias rd='rmdir'
+alias cd..='cd ..'
+alias ..='cd ..'
+alias po='popd'
+alias pu='pushd'
+alias tsl="tail -f /var/log/syslog"
+alias df="df -hT"
+alias em="emacs -nw"
+
+# functions
+mdc() { mkdir -p "$1" && cd "$1" }
+setenv() { export $1=$2 }  # csh compatibility
+sdate() { date +%Y.%m.%d }
+pc() { awk "{print \$$1}" }
+rot13 () { tr "[a-m][n-z][A-M][N-Z]" "[n-z][a-m][N-Z][A-M]" }
+
+# shuffle input lines. Nice for mp3 playlists etc...
+shuffle() {
+  RANDOM=`date +%s`
+  (
+  while IFS= read -r i; do
+    echo $RANDOM$RANDOM "$i";
+  done
+  ) | sort | sed 's/^[0-9]* //'
+}
 
 export TD="$HOME/temp/`date +'%Y-%m-%d'`"
 td(){
     unset td
     }
 
-#setopt PRINT_EIGHT_BIT
-