Permalink
Browse files

the zsh configure file

  • Loading branch information...
1 parent a2a4a28 commit 8761317ea673b6361031dd1d7e4d416bf488e670 @chenfengyuan committed Nov 19, 2011
Showing with 263 additions and 0 deletions.
  1. +263 −0 zshrc
View
263 zshrc
@@ -0,0 +1,263 @@
+export LANG=en_US.utf-8
+export PATH=$HOME/.bin:~/perl5/bin:$PATH
+export PERL5LIB=~/perl5/lib/perl5
+# export PATH="/usr/lib/ccache/bin/:/usr/lib/distcc/bin/:${PATH}"
+# export INFOPATH=$INFOPATH:$HOME/info
+#关于历史纪录的配置 {{{
+#历史纪录条目数量
+export HISTSIZE=10000
+#注销后保存的历史纪录条目数量
+export SAVEHIST=10000
+#export HISTFILE=~/.histfile
+export HISTFILE=~/.zhistory
+#以附加的方式写入历史纪录
+setopt INC_APPEND_HISTORY
+#如果连续输入的命令相同,历史纪录中只保留一个
+setopt HIST_IGNORE_DUPS
+#为历史纪录中的命令添加时间戳
+setopt EXTENDED_HISTORY
+
+#启用 cd 命令的历史纪录,cd -[TAB]进入历史路径
+setopt AUTO_PUSHD
+#相同的历史路径只保留一个
+setopt PUSHD_IGNORE_DUPS
+
+#杂项 {{{
+#允许在交互模式中使用注释 例如:
+#cmd #这是注释
+setopt INTERACTIVE_COMMENTS
+
+setopt hash_list_all # search all paths before command completion
+#禁用 core dumps
+limit coredumpsize 0
+
+#方便得前后台切换,来自于roylez
+bindkey -s "" "fg\n"
+
+#Emacs风格 键绑定
+bindkey -e
+#设置 [DEL]键 为向后删除
+bindkey "\e[3~" delete-char
+
+#以下字符视为单词的一部分
+WORDCHARS='*?_-[]~=&;!#$%^(){}<>'
+#}}}
+
+#自动补全功能 {{{
+setopt AUTO_LIST
+setopt AUTO_MENU
+autoload -U compinit
+compinit
+
+#自动补全选项
+zstyle ':completion:*' verbose yes
+zstyle ':completion:*' menu select
+zstyle ':completion:*:*:default' force-list always
+zstyle ':completion:*' select-prompt '%SSelect: lines: %L matches: %M [%p]'
+
+zstyle ':completion:*:match:*' original only
+zstyle ':completion::prefix-1:*' completer _complete
+zstyle ':completion:predict:*' completer _complete
+zstyle ':completion:incremental:*' completer _complete _correct
+zstyle ':completion:*' completer _force_rehash _complete _prefix _correct _prefix _match _approximate
+
+#路径补全
+zstyle ':completion:*' expand 'yes'
+zstyle ':completion:*' squeeze-shlashes 'yes'
+zstyle ':completion::complete:*' '\\'
+
+#彩色补全菜单
+eval $(dircolors -b)
+export ZLSCOLORS="${LS_COLORS}"
+zmodload zsh/complist
+zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
+zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
+
+# completion for kill
+compdef pkill=kill
+compdef pkill=killall
+zstyle ':completion:*:*:kill:*' menu yes select
+zstyle ':completion:*:*:*:*:processes' force-list always
+zstyle ':completion:*:processes' command 'ps -au$USER'
+
+#补全类型提示分组
+zstyle ':completion:*:matches' group 'yes'
+zstyle ':completion:*' group-name ''
+zstyle ':completion:*:options' description 'yes'
+zstyle ':completion:*:options' auto-description '%d'
+zstyle ':completion:*:descriptions' format $'\e[01;33m -- %d --\e[0m'
+zstyle ':completion:*:messages' format $'\e[01;35m -- %d --\e[0m'
+zstyle ':completion:*:warnings' format $'\e[01;31m -- No Matches Found --\e[0m'
+zstyle ':completion:*:corrections' format $'\e[01;32m -- %d (errors: %e) --\e[0m'
+
+# cd ~ 补全顺序
+zstyle ':completion:*:-tilde-:*' group-order 'named-directories' 'path-directories' 'users' 'expand'
+#}}}
+
+##行编辑高亮模式 {{{
+# Ctrl+@ 设置标记,标记和光标点之间为 region
+zle_highlight=(region:bg=magenta #选中区域
+special:bold #特殊字符
+isearch:underline)#搜索时使用的关键字
+#}}}
+
+##空行(光标在行首)补全 "cd " {{{
+user-complete(){
+ case $BUFFER in
+ "" ) # 空行填入 "cd "
+ BUFFER="cd "
+ zle end-of-line
+ zle expand-or-complete
+ ;;
+ "cd --" ) # "cd --" 替换为 "cd +"
+ BUFFER="cd +"
+ zle end-of-line
+ zle expand-or-complete
+ ;;
+ "cd +-" ) # "cd +-" 替换为 "cd -"
+ BUFFER="cd -"
+ zle end-of-line
+ zle expand-or-complete
+ ;;
+ * )
+ zle expand-or-complete
+ ;;
+ esac
+}
+zle -N user-complete
+bindkey "\t" user-complete
+#}}}
+
+# ##在命令前插入 sudo {{{
+# #定义功能
+# sudo-command-line() {
+# [[ -z $BUFFER ]] && zle up-history
+# [[ $BUFFER != sudo\ * ]] && BUFFER="sudo $BUFFER"
+# zle end-of-line #光标移动到行末
+# }
+# zle -N sudo-command-line
+# #定义快捷键为: [Esc] [Esc]
+# bindkey "\e\e" sudo-command-line
+# #}}}
+
+# {{{1 command aliases
+alias cp='cp -i'
+alias mv='mv -iv'
+alias rm='rm -Iv'
+alias ls='ls --classify --color=auto'
+alias ll="ls --classify --color=auto -l"
+alias grep='grep --color=auto'
+alias e="emacsclient -n"
+alias B='|sed -r "s:\x1B\[[0-9;]*[mK]::g"'
+alias N="*(oc[1])"
+alias wgetpaste='wgetpaste -s ca'
+#alias mocp='mocp ~/foo.playlist.m3u'
+# alias -g DISTCC="MAKEOPTS=\"-j13\" FEATURES=\"distcc\""
+alias shutdown='sudo /sbin/shutdown -h now'
+alias lunar='lunar --utf8'
+alias fm='mplayer "http://pri.kts-af.net/redir/index.pls?esid=eb4f5f80569dabe3f640c7ca07676606&url_no=1&client_id=7&uid=68efed4d03ec7e45fd3978262c107180&clicksrc=xml"'
+alias dpmsoff='xset dpms force off'
+alias gpg='DISPLAY="" gpg'
+alias sudomount='sudo /bin/mount -o loop -t squashfs'
+alias umount='sudo umount'
+alias lsmac="/sbin/ifconfig -a | sed '/eth\|wl/!d;s/ Link.*HWaddr//'"
+idcheck_cfy(){perl -le '@a=split //,lc@ARGV[0];@b=split //,lc"79a584216379a5842";$s+=$a[$_]*hex $b[$_] for (0..$#a);$c=((12-($s%11))%11==10?"x":(12-($s%11))%11);unless(@a==18){print $c}else{print +($c eq $a[$#a])?"y":"n"}' $1}
+alias rsync='rsync --progress --partial'
+alias po2db=~'/gits/po2db/po2db.pl'
+alias adb='/home/cfy/temp/android/android-sdk-linux_x86/platform-tools/adb'
+alias ss='/usr/bin/import -frame /dev/shm/screen-shot.jpg && opera /dev/shm/screen-shot.jpg'
+alias ccl='/home/cfy/temp/ccl/lx86cl64'
+# alias ecl='/usr/lib/ecl/ecl-original'
+# }}}1
+
+# {{{1 path aliases
+# cd ~p <=> cd /home/ray/projects
+# hash -d c="/mnt/C"
+# hash -d d="/mnt/D"
+# hash -d ptg="/usr/portage"
+# hash -d x="/etc/X11"
+# hash -d a="/home/ray/algo"
+# hash -d p="/home/ray/projects"
+# }}}1
+
+
+
+
+RESET='[00m'
+RED='[01;31m'
+GREEN='[01;32m'
+YELLOW='[01;33m'
+BLUE='[01;34m'
+MAGENTA='[01;35m'
+CYAN='[01;36m'
+WHITE='[01;37m'
+UNDERLINE='[04m'
+
+header()
+{
+ begin_str=">>>"
+ end_str=">>>"
+ banner="debian"
+ length=$((${COLUMNS} - 1 - ${#begin_str} - ${#end_str} - ${#banner} - 2))
+ half=$(($length / 2))
+ line=`printf '%*s' $half`
+ echo -en "%{\e${RED}%}${begin_str}\e${WHITE}${line// /-}[\e${MAGENTA}${banner}\e${WHITE}]${line// /-}\e${RED}${end_str}\e${RESET}"
+}
+
+get_hg_repos_id()
+{
+ hg id -bint 2> /dev/null
+}
+
+get_git_repos_branch()
+{
+ git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1/"
+}
+
+repos_info()
+{
+ HG_REPOS_ID="$(get_hg_repos_id)"
+ if [ "${HG_REPOS_ID}" ]
+ then
+ echo "\n\e${WHITE}[\e${CYAN}Mercurial\e${WHITE}] Revision ID \e${YELLOW}${HG_REPOS_ID}"
+ else
+ GIT_REPOS_BRANCH="$(get_git_repos_branch)"
+ if [ "${GIT_REPOS_BRANCH}" ]
+ then
+ echo "\n%{\e${WHITE}%}[%{\e${CYAN}%}Git%{\e${WHITE}%}] Current Branch %{\e${YELLOW}%}${GIT_REPOS_BRANCH}"
+ else
+ echo
+ fi
+ fi
+}
+
+get_repos_info()
+{
+ echo "$(repos_info)"
+}
+
+my_prompt()
+{
+ echo -en "\n\e${WHITE}[\e${CYAN}Login\e${WHITE}] \e${GREEN}%n \e${RESET}at \e${WHITE}%m \e${RESET}in \e${BLUE}%d"
+ echo
+ echo "%{\e${RED}%}\$ %{\e${RESET}%}"
+}
+
+autoload -U promptinit colors
+promptinit
+colors
+
+typeset -ga chpwd_functions
+chpwd_functions+='get_repos_info'
+export PROMPT="$(header)$(my_prompt)"
+
+MAIL=/var/spool/mail/ray && export MAIL
@tusooa

tusooa Jan 1, 2012

你这明显抄的maskray的啊。也不改改。。。

@chenfengyuan

chenfengyuan Jan 24, 2012

Owner

确实应该找个时间改改

@tusooa

tusooa Jan 28, 2012

你不是用践兔了么,那咋是Debian

@chenfengyuan

chenfengyuan Jan 29, 2012

Owner

一直没改,现在去掉了

+
+export LESSOPEN='|lesspipe %s'
+
+#force rehash when command not found
+# http://zshwiki.org/home/examples/compsys/general
+_force_rehash() {
+ (( CURRENT == 1 )) && rehash
+ return 1 # Because we did not really complete anything
+}

0 comments on commit 8761317

Please sign in to comment.