From 40fccf1f460d2967a7743bb9b437065fc039cae1 Mon Sep 17 00:00:00 2001 From: shiludeng Date: Wed, 21 May 2014 10:29:26 +0800 Subject: [PATCH 01/16] add my own theme. --- themes/azure.zsh-theme | 381 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 381 insertions(+) create mode 100644 themes/azure.zsh-theme diff --git a/themes/azure.zsh-theme b/themes/azure.zsh-theme new file mode 100644 index 000000000..0e91ba17d --- /dev/null +++ b/themes/azure.zsh-theme @@ -0,0 +1,381 @@ +#color{{{ +autoload colors +colors + +for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; do +eval _$color='%{$terminfo[bold]$fg[${(L)color}]%}' +eval $color='%{$fg[${(L)color}]%}' +(( count = $count + 1 )) +done +FINISH="%{$terminfo[sgr0]%}" +#}}} + +#命令提示符 +RPROMPT=$(echo "$RED%D %T$FINISH") +PROMPT=$(echo "$CYAN%n@$YELLOW%M:$GREEN%/$_YELLOW>$FINISH ") + +#PROMPT=$(echo "$BLUE%M$GREEN%/ +#$CYAN%n@$BLUE%M:$GREEN%/$_YELLOW>>>$FINISH ") +#标题栏、任务栏样式{{{ +case $TERM in (*xterm*|*rxvt*|(dt|k|E)term) +precmd () { print -Pn "\e]0;%n@%M//%/\a" } +preexec () { print -Pn "\e]0;%n@%M//%/\ $1\a" } +;; +esac +#}}} + +#编辑器 +export EDITOR=vim +#输入法 +export XMODIFIERS="@im=ibus" +export QT_MODULE=ibus +export GTK_MODULE=ibus +#关于历史纪录的配置 {{{ +#历史纪录条目数量 +export HISTSIZE=10000 +#注销后保存的历史纪录条目数量 +export SAVEHIST=10000 +#历史纪录文件 +export HISTFILE=~/.zhistory +#以附加的方式写入历史纪录 +setopt INC_APPEND_HISTORY +#如果连续输入的命令相同,历史纪录中只保留一个 +setopt HIST_IGNORE_DUPS +#为历史纪录中的命令添加时间戳 +setopt EXTENDED_HISTORY + +#启用 cd 命令的历史纪录,cd -[TAB]进入历史路径 +setopt AUTO_PUSHD +#相同的历史路径只保留一个 +setopt PUSHD_IGNORE_DUPS + +#在命令前添加空格,不将此命令添加到纪录文件中 +#setopt HIST_IGNORE_SPACE +#}}} + +#每个目录使用独立的历史纪录{{{ +cd() { +builtin cd "$@" # do actual cd +fc -W # write current history file +local HISTDIR="$HOME/.zsh_history$PWD" # use nested folders for history +if [ ! -d "$HISTDIR" ] ; then # create folder if needed +mkdir -p "$HISTDIR" +fi +export HISTFILE="$HISTDIR/zhistory" # set new history file +touch $HISTFILE +local ohistsize=$HISTSIZE +HISTSIZE=0 # Discard previous dir's history +HISTSIZE=$ohistsize # Prepare for new dir's history +fc -R #read from current histfile +} +mkdir -p $HOME/.zsh_history$PWD +export HISTFILE="$HOME/.zsh_history$PWD/zhistory" + +function allhistory { cat $(find $HOME/.zsh_history -name zhistory) } +function convhistory { +sort $1 | uniq | +sed 's/^:\([ 0-9]*\):[0-9]*;\(.*\)/\1::::::\2/' | +awk -F"::::::" '{ $1=strftime("%Y-%m-%d %T",$1) "|"; print }' +} +#使用 histall 命令查看全部历史纪录 +function histall { convhistory =(allhistory) | +sed '/^.\{20\} *cd/i\\' } +#使用 hist 查看当前目录历史纪录 +function hist { convhistory $HISTFILE } + +#全部历史纪录 top50 +function top50 { allhistory | awk -F':[ 0-9]*:[0-9]*;' '{ $1="" ; print }' | sed 's/ /\n/g' | sed '/^$/d' | sort | uniq -c | sort -nr | head -n 50 } + +#}}} + +#杂项 {{{ +#允许在交互模式中使用注释 例如: +#cmd #这是注释 +setopt INTERACTIVE_COMMENTS + +#启用自动 cd,输入目录名回车进入目录 +#稍微有点混乱,不如 cd 补全实用 +setopt AUTO_CD + +#扩展路径 +#/v/c/p/p => /var/cache/pacman/pkg +setopt complete_in_word + +#禁用 core dumps +#limit coredumpsize 0 + +#Emacs风格 键绑定 +bindkey -e +#bindkey -v +#设置 [DEL]键 为向后删除 +#bindkey "\e[3~" delete-char + +#以下字符视为单词的一部分 +WORDCHARS='*?_-[]~=&;!#$%^(){}<>' +#}}} + +#自动补全功能 {{{ +setopt AUTO_LIST +setopt AUTO_MENU +#开启此选项,补全时会直接选中菜单项 +#setopt MENU_COMPLETE + +autoload -U compinit +compinit + +#自动补全缓存 +#zstyle ':completion::complete:*' use-cache on +#zstyle ':completion::complete:*' cache-path .zcache +#zstyle ':completion:*:cd:*' ignore-parents parent pwd + +#自动补全选项 +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 _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' + +#修正大小写 +zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}' +#错误校正 +zstyle ':completion:*' completer _complete _match _approximate +zstyle ':completion:*:match:*' original only +zstyle ':completion:*:approximate:*' max-errors 1 numeric + +#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 +#}}} + +#命令别名 {{{ +alias cp='cp -i' +alias mv='mv -i' +alias rm='rm -i' +alias ls='ls -F --color=auto' +alias ll='ls -al' +alias grep='grep --color=auto' +alias la='ls -a' +alias pacman='sudo pacman-color' +alias p='sudo pacman-color' +alias y='yaourt' +alias h='htop' +#git alias +alias g='git' +alias gb='git branch' +alias gst='git status' +alias gsh='git show' +alias gd='git diff' +alias gco='git checkout' +#adb alias +alias aks='adb kill-server' +alias ass='adb start-server' +alias ars='aks && ass' +alias alog='adb logcat -C' +#[Esc][h] man 当前命令时,显示简短说明 +alias run-help >&/dev/null && unalias run-help +autoload run-help + +#历史命令 top10 +alias top10='print -l ${(o)history%% *} | uniq -c | sort -nr | head -n 10' +#}}} + +#路径别名 {{{ +#进入相应的路径时只要 cd ~xxx +#hash -d A="/media/ayu/dearest" +#hash -d H="/media/data/backup/ayu" +#hash -d E="/etc/" +#hash -d D="/home/ayumi/Documents" +hash -d weigo="/home/users/shiludeng/data/dev/weigo" +hash -d ub="/home/users/shiludeng/data/dev/public/ub" +hash -d example="/home/users/shiludeng/data/dev/com/tools/ubgen" +#}}} + +##for Emacs {{{ +#在 Emacs终端 中使用 Zsh 的一些设置 不推荐在 Emacs 中使用它 +#if [[ "$TERM" == "dumb" ]]; then +#setopt No_zle +#PROMPT='%n@%M %/ +#>>' +#alias ls='ls -F' +#fi +#}}} + +#{{{自定义补全 +#补全 ping +zstyle ':completion:*:ping:*' hosts 192.168.1.{1,50,51,100,101} www.google.com + +#补全 ssh scp sftp 等 +#zstyle -e ':completion::*:*:*:hosts' hosts 'reply=(${=${${(f)"$(cat {/etc/ssh_,~/.ssh/known_}hosts(|2)(N) /dev/null)"}%%[# ]*}//,/ })' +#}}} + +#{{{ F1 计算器 +arith-eval-echo() { +LBUFFER="${LBUFFER}echo \$(( " +RBUFFER=" ))$RBUFFER" +} +zle -N arith-eval-echo +bindkey "^[[11~" arith-eval-echo +#}}} + +####{{{ +function timeconv { date -d @$1 +"%Y-%m-%d %T" } + +# }}} + +zmodload zsh/mathfunc +autoload -U zsh-mime-setup +zsh-mime-setup +setopt EXTENDED_GLOB +#autoload -U promptinit +#promptinit +#prompt redhat + +setopt correctall +autoload compinstall + +#漂亮又实用的命令高亮界面 +setopt extended_glob + TOKENS_FOLLOWED_BY_COMMANDS=('|' '||' ';' '&' '&&' 'sudo' 'do' 'time' 'strace') + + recolor-cmd() { + region_highlight=() + colorize=true + start_pos=0 + for arg in ${(z)BUFFER}; do + ((start_pos+=${#BUFFER[$start_pos+1,-1]}-${#${BUFFER[$start_pos+1,-1]## #}})) + ((end_pos=$start_pos+${#arg})) + if $colorize; then + colorize=false + res=$(LC_ALL=C builtin type $arg 2>/dev/null) + case $res in + *'reserved word'*) style="fg=magenta,bold";; + *'alias for'*) style="fg=cyan,bold";; + *'shell builtin'*) style="fg=yellow,bold";; + *'shell function'*) style='fg=green,bold';; + *"$arg is"*) + [[ $arg = 'sudo' ]] && style="fg=red,bold" || style="fg=blue,bold";; + *) style='none,bold';; + esac + region_highlight+=("$start_pos $end_pos $style") + fi + [[ ${${TOKENS_FOLLOWED_BY_COMMANDS[(r)${arg//|/\|}]}:+yes} = 'yes' ]] && colorize=true + start_pos=$end_pos + done + } +check-cmd-self-insert() { zle .self-insert && recolor-cmd } +check-cmd-backward-delete-char() { zle .backward-delete-char && recolor-cmd } + +zle -N self-insert check-cmd-self-insert +zle -N backward-delete-char check-cmd-backward-delete-char +# Initialize colors. +autoload -U colors +colors + +# Allow for functions in the prompt. +setopt PROMPT_SUBST + +# Autoload zsh functions. +fpath=(~/.zsh/functions $fpath) +autoload -U ~/.zsh/functions/*(:t) + +## Enable auto-execution of functions. +#typeset -ga preexec_functions +#typeset -ga precmd_functions +#typeset -ga chpwd_functions + +## Append git functions needed for prompt. +#preexec_functions+='preexec_update_git_vars' +#precmd_functions+='precmd_update_git_vars' +#chpwd_functions+='chpwd_update_git_vars' + +# Set the prompt. +#PROMPT=$'%{${fg[cyan]}%}%B%~%b$(prompt_git_info)%{${fg[default]}%} ' + +local ret_status="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ %s)" +PROMPT='%{${fg[cyan]}%}%n@%{${fg[yellow]}%}%m:%{${fg[cyan]}%}%B%~%{$fg_bold[blue]%}$(git_prompt_info)%{${fg[default]}%}%{${fg[yellow]}%}> ' +#PROMPT='${ret_status}%{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}' + +ZSH_THEME_GIT_PROMPT_PREFIX=" git:(%{$fg[red]%}" +ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" +#ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗%{$reset_color%}" +ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}x%{$reset_color%}" +ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})" From 0745edfb5e0ea5ada51158d42ff48304245a6f14 Mon Sep 17 00:00:00 2001 From: shiludeng Date: Sun, 1 Jun 2014 14:39:45 +0800 Subject: [PATCH 02/16] add new directory shortcut -- weigou. --- themes/azure.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/azure.zsh-theme b/themes/azure.zsh-theme index 0e91ba17d..46164ce36 100644 --- a/themes/azure.zsh-theme +++ b/themes/azure.zsh-theme @@ -264,7 +264,7 @@ alias top10='print -l ${(o)history%% *} | uniq -c | sort -nr | head -n 10' #hash -d H="/media/data/backup/ayu" #hash -d E="/etc/" #hash -d D="/home/ayumi/Documents" -hash -d weigo="/home/users/shiludeng/data/dev/weigo" +hash -d weigou="/home/users/shiludeng/data/dev/app/ecom/weigou" hash -d ub="/home/users/shiludeng/data/dev/public/ub" hash -d example="/home/users/shiludeng/data/dev/com/tools/ubgen" #}}} From 4817245d42edbb82856a5bb0b7437ccea7abb6f8 Mon Sep 17 00:00:00 2001 From: shiludeng Date: Mon, 4 Aug 2014 13:43:58 +0800 Subject: [PATCH 03/16] add .zshrc & install.txt to .oh-my-zsh --- .zshrc | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++ install.txt | 1 + 2 files changed, 80 insertions(+) create mode 100644 .zshrc create mode 100644 install.txt diff --git a/.zshrc b/.zshrc new file mode 100644 index 000000000..af1b8cac1 --- /dev/null +++ b/.zshrc @@ -0,0 +1,79 @@ +# Path to your oh-my-zsh installation. +export ZSH=$HOME/.oh-my-zsh + +# Set name of the theme to load. +# Look in ~/.oh-my-zsh/themes/ +# Optionally, if you set this to "random", it'll load a random theme each +# time that oh-my-zsh is loaded. +#ZSH_THEME="robbyrussell" +ZSH_THEME="azure" + +# Example aliases +# alias zshconfig="mate ~/.zshrc" +# alias ohmyzsh="mate ~/.oh-my-zsh" + +# Uncomment the following line to use case-sensitive completion. +# CASE_SENSITIVE="true" + +# Uncomment the following line to disable bi-weekly auto-update checks. +# DISABLE_AUTO_UPDATE="true" + +# Uncomment the following line to change how often to auto-update (in days). +# export UPDATE_ZSH_DAYS=13 + +# Uncomment the following line to disable colors in ls. +# DISABLE_LS_COLORS="true" + +# Uncomment the following line to disable auto-setting terminal title. +# DISABLE_AUTO_TITLE="true" + +# Uncomment the following line to disable command auto-correction. +# DISABLE_CORRECTION="true" + +# Uncomment the following line to display red dots whilst waiting for completion. +# COMPLETION_WAITING_DOTS="true" + +# Uncomment the following line if you want to disable marking untracked files +# under VCS as dirty. This makes repository status check for large repositories +# much, much faster. +# DISABLE_UNTRACKED_FILES_DIRTY="true" + +# Uncomment the following line if you want to change the command execution time +# stamp shown in the history command output. +# The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd" +# HIST_STAMPS="mm/dd/yyyy" + +# Would you like to use another custom folder than $ZSH/custom? +# ZSH_CUSTOM=/path/to/new-custom-folder + +# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*) +# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/ +# Example format: plugins=(rails git textmate ruby lighthouse) +plugins=(git) + +source $ZSH/oh-my-zsh.sh + +# User configuration + +export JAVA_HOME=/home/users/shiludeng/.jumbo/opt/sun-java6 +export HADOOP_INSTALL=/home/users/shiludeng/data/dev/hadoop/hadoop +#/home/tools/tools/maven/apache-maven-2.2.1/bin +export PATH=$HOME/bin:$HADOOP_INSTALL/bin:/usr/local/bin:$PATH +bash ~/.bash_profile +# export MANPATH="/usr/local/man:$MANPATH" + +# You may need to manually set your language environment +#export LANG=en_US.UTF-8 + +# Preferred editor for local and remote sessions +# if [[ -n $SSH_CONNECTION ]]; then +# export EDITOR='vim' +# else +# export EDITOR='mvim' +# fi + +# Compilation flags +# export ARCHFLAGS="-arch x86_64" + +# ssh +# export SSH_KEY_PATH="~/.ssh/dsa_id" diff --git a/install.txt b/install.txt new file mode 100644 index 000000000..ad02ba585 --- /dev/null +++ b/install.txt @@ -0,0 +1 @@ +在home目录建立.zshrc和.oh-my-zsh的软链接 From cdeeb99b57cef4cde8c1761b7342f0692bc76709 Mon Sep 17 00:00:00 2001 From: shiludeng Date: Thu, 18 Dec 2014 20:56:09 +0800 Subject: [PATCH 04/16] add movie path shortcut --- themes/azure.zsh-theme | 1 + 1 file changed, 1 insertion(+) diff --git a/themes/azure.zsh-theme b/themes/azure.zsh-theme index 46164ce36..10ea68755 100644 --- a/themes/azure.zsh-theme +++ b/themes/azure.zsh-theme @@ -265,6 +265,7 @@ alias top10='print -l ${(o)history%% *} | uniq -c | sort -nr | head -n 10' #hash -d E="/etc/" #hash -d D="/home/ayumi/Documents" hash -d weigou="/home/users/shiludeng/data/dev/app/ecom/weigou" +hash -d movie="/home/users/shiludeng/data/dev/app/search/user/se" hash -d ub="/home/users/shiludeng/data/dev/public/ub" hash -d example="/home/users/shiludeng/data/dev/com/tools/ubgen" #}}} From b538cbd61d4a04738937a5e7e7d85d9ceca43742 Mon Sep 17 00:00:00 2001 From: shiludeng Date: Thu, 18 Dec 2014 20:58:45 +0800 Subject: [PATCH 05/16] update movie path --- themes/azure.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/azure.zsh-theme b/themes/azure.zsh-theme index 10ea68755..c23402383 100644 --- a/themes/azure.zsh-theme +++ b/themes/azure.zsh-theme @@ -265,7 +265,7 @@ alias top10='print -l ${(o)history%% *} | uniq -c | sort -nr | head -n 10' #hash -d E="/etc/" #hash -d D="/home/ayumi/Documents" hash -d weigou="/home/users/shiludeng/data/dev/app/ecom/weigou" -hash -d movie="/home/users/shiludeng/data/dev/app/search/user/se" +hash -d movie="/home/users/shiludeng/data/dev/app/search/movie/user/se" hash -d ub="/home/users/shiludeng/data/dev/public/ub" hash -d example="/home/users/shiludeng/data/dev/com/tools/ubgen" #}}} From f1ef09581247cce4e3ef6ef316a6f53f3288d137 Mon Sep 17 00:00:00 2001 From: shiludeng Date: Fri, 19 Dec 2014 14:41:53 +0800 Subject: [PATCH 06/16] update moviese shortcut name --- themes/azure.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/azure.zsh-theme b/themes/azure.zsh-theme index c23402383..87e2a98f6 100644 --- a/themes/azure.zsh-theme +++ b/themes/azure.zsh-theme @@ -265,7 +265,7 @@ alias top10='print -l ${(o)history%% *} | uniq -c | sort -nr | head -n 10' #hash -d E="/etc/" #hash -d D="/home/ayumi/Documents" hash -d weigou="/home/users/shiludeng/data/dev/app/ecom/weigou" -hash -d movie="/home/users/shiludeng/data/dev/app/search/movie/user/se" +hash -d moviese="/home/users/shiludeng/data/dev/app/search/movie/user/se" hash -d ub="/home/users/shiludeng/data/dev/public/ub" hash -d example="/home/users/shiludeng/data/dev/com/tools/ubgen" #}}} From 1a87e33164e321db90083242c5e140b2e6955fd8 Mon Sep 17 00:00:00 2001 From: shiludeng Date: Fri, 6 Feb 2015 17:37:23 +0800 Subject: [PATCH 07/16] update azure.zsh-theme --- themes/azure.zsh-theme | 47 ++++++++++++++++-------------------------- 1 file changed, 18 insertions(+), 29 deletions(-) diff --git a/themes/azure.zsh-theme b/themes/azure.zsh-theme index 87e2a98f6..d3f85109a 100644 --- a/themes/azure.zsh-theme +++ b/themes/azure.zsh-theme @@ -270,16 +270,6 @@ hash -d ub="/home/users/shiludeng/data/dev/public/ub" hash -d example="/home/users/shiludeng/data/dev/com/tools/ubgen" #}}} -##for Emacs {{{ -#在 Emacs终端 中使用 Zsh 的一些设置 不推荐在 Emacs 中使用它 -#if [[ "$TERM" == "dumb" ]]; then -#setopt No_zle -#PROMPT='%n@%M %/ -#>>' -#alias ls='ls -F' -#fi -#}}} - #{{{自定义补全 #补全 ping zstyle ':completion:*:ping:*' hosts 192.168.1.{1,50,51,100,101} www.google.com @@ -357,26 +347,25 @@ setopt PROMPT_SUBST # Autoload zsh functions. fpath=(~/.zsh/functions $fpath) autoload -U ~/.zsh/functions/*(:t) - -## Enable auto-execution of functions. -#typeset -ga preexec_functions -#typeset -ga precmd_functions -#typeset -ga chpwd_functions - -## Append git functions needed for prompt. -#preexec_functions+='preexec_update_git_vars' -#precmd_functions+='precmd_update_git_vars' -#chpwd_functions+='chpwd_update_git_vars' - + # Set the prompt. -#PROMPT=$'%{${fg[cyan]}%}%B%~%b$(prompt_git_info)%{${fg[default]}%} ' - local ret_status="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ %s)" -PROMPT='%{${fg[cyan]}%}%n@%{${fg[yellow]}%}%m:%{${fg[cyan]}%}%B%~%{$fg_bold[blue]%}$(git_prompt_info)%{${fg[default]}%}%{${fg[yellow]}%}> ' -#PROMPT='${ret_status}%{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}' +PROMPT='%{${fg[cyan]}%}┌%n@%{${fg[yellow]}%}%m:%{${fg[cyan]}%}%B%~%{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%}$(svn_prompt_info)%{${fg[default]}%}%{$fg[cyan]%} +└> %' -ZSH_THEME_GIT_PROMPT_PREFIX=" git:(%{$fg[red]%}" +ZSH_PROMPT_BASE_COLOR="%{$fg_bold[blue]%}" +ZSH_THEME_REPO_NAME_COLOR="%{$fg_bold[yello]%}" +ZSH_THEME_REPO_NAME_COLOR="%{$fg_bold[yello]%}" +SVN_SHOW_BRANCH="true" + +ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[magenta]%} -git- %{$reset_color%}%{$fg_bold[yellow]%}" ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" -#ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗%{$reset_color%}" -ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}x%{$reset_color%}" -ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})" +ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[cyan]%} ?" +ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg_bold[red]%} ±" +ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg_bold[red]%} ♥" + +ZSH_THEME_SVN_PROMPT_PREFIX="%{$fg_bold[magenta]%} -svn- %{$reset_color%}%{$fg_bold[yellow]%}" +ZSH_THEME_SVN_PROMPT_SUFFIX="%{$reset_color%}" +ZSH_THEME_SVN_PROMPT_UNTRACKED="%{$fg[cyan]%} ?" +ZSH_THEME_SVN_PROMPT_DIRTY="%{$fg_bold[red]%} ±" +ZSH_THEME_SVN_PROMPT_CLEAN="%{$fg_bold[red]%} ♥" From 673c664cb0b8f84fd7e1b10d4efff99988ae7e1d Mon Sep 17 00:00:00 2001 From: shiludeng Date: Fri, 6 Feb 2015 19:09:15 +0800 Subject: [PATCH 08/16] update svn plugin for untracked filed --- plugins/svn/svn.plugin.zsh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/plugins/svn/svn.plugin.zsh b/plugins/svn/svn.plugin.zsh index ef6da5bd3..a9c39b6db 100644 --- a/plugins/svn/svn.plugin.zsh +++ b/plugins/svn/svn.plugin.zsh @@ -61,18 +61,21 @@ function svn_get_rev_nr() { function svn_dirty_choose() { if in_svn; then root=`svn info 2> /dev/null | sed -n 's/^Working Copy Root Path: //p'` - if $(svn status $root 2> /dev/null | grep -Eq '^\s*[ACDIM!?L]'); then + status_str=`svn status $root 2> /dev/null` + if $(echo $status_str | grep -Eq '^\s*[ACDIM!L]'); then # Grep exits with 0 when "One or more lines were selected", return "dirty". echo $1 + elif $(echo $status_str | grep -Eq '^\s*[?]'); then + echo $2 else # Otherwise, no lines were found, or an error occurred. Return clean. - echo $2 + echo $3 fi fi } function svn_dirty() { - svn_dirty_choose $ZSH_THEME_SVN_PROMPT_DIRTY $ZSH_THEME_SVN_PROMPT_CLEAN + svn_dirty_choose $ZSH_THEME_SVN_PROMPT_DIRTY $ZSH_THEME_SVN_PROMPT_UNTRACKED $ZSH_THEME_SVN_PROMPT_CLEAN } function svn_dirty_choose_pwd () { From 3a73464766f06815b28cabdf6547d01923593f0b Mon Sep 17 00:00:00 2001 From: shiludeng Date: Mon, 16 Mar 2015 10:42:34 +0800 Subject: [PATCH 09/16] use full host name --- themes/azure.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/azure.zsh-theme b/themes/azure.zsh-theme index d3f85109a..0934881c8 100644 --- a/themes/azure.zsh-theme +++ b/themes/azure.zsh-theme @@ -350,7 +350,7 @@ autoload -U ~/.zsh/functions/*(:t) # Set the prompt. local ret_status="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ %s)" -PROMPT='%{${fg[cyan]}%}┌%n@%{${fg[yellow]}%}%m:%{${fg[cyan]}%}%B%~%{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%}$(svn_prompt_info)%{${fg[default]}%}%{$fg[cyan]%} +PROMPT='%{${fg[cyan]}%}┌%n@%{${fg[yellow]}%}%M:%{${fg[cyan]}%}%B%~%{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%}$(svn_prompt_info)%{${fg[default]}%}%{$fg[cyan]%} └> %' ZSH_PROMPT_BASE_COLOR="%{$fg_bold[blue]%}" From c78069d2e20be74a893ee6bcc04db43ea76c8927 Mon Sep 17 00:00:00 2001 From: shiludeng Date: Mon, 13 Apr 2015 18:15:32 +0800 Subject: [PATCH 10/16] fix svn branch name prompt: when not trunk, display NOT trunk --- plugins/svn/svn.plugin.zsh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/svn/svn.plugin.zsh b/plugins/svn/svn.plugin.zsh index a9c39b6db..d8ed34079 100644 --- a/plugins/svn/svn.plugin.zsh +++ b/plugins/svn/svn.plugin.zsh @@ -46,8 +46,10 @@ function svn_get_branch_name() { if [ "x$_DISPLAY" = "x" ]; then svn_get_repo_name + elif [ "x$_DISPLAY" = "xtrunk" ]; then + echo "trunk" else - echo $_DISPLAY + echo "NOT trunk" fi unset _DISPLAY } From e7aed72a7578a6c868ed96db92966325477b618e Mon Sep 17 00:00:00 2001 From: shiludeng Date: Tue, 23 Jun 2015 16:21:11 +0800 Subject: [PATCH 11/16] update azure.zsh-theme --- themes/azure.zsh-theme | 2 ++ 1 file changed, 2 insertions(+) diff --git a/themes/azure.zsh-theme b/themes/azure.zsh-theme index 0934881c8..65a1e7db3 100644 --- a/themes/azure.zsh-theme +++ b/themes/azure.zsh-theme @@ -122,6 +122,8 @@ setopt AUTO_MENU autoload -U compinit compinit +autoload -U select-word-style +select-word-style whitespace #自动补全缓存 #zstyle ':completion::complete:*' use-cache on From f2ca414da47215320ec174b9f3637e356d69079a Mon Sep 17 00:00:00 2001 From: shiludeng Date: Wed, 30 Dec 2015 13:04:26 +0800 Subject: [PATCH 12/16] update .zshrc & azure.zsh-theme --- .zshrc | 5 +++-- themes/azure.zsh-theme | 22 +++++----------------- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/.zshrc b/.zshrc index af1b8cac1..2f6a81fbe 100644 --- a/.zshrc +++ b/.zshrc @@ -49,8 +49,9 @@ ZSH_THEME="azure" # Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*) # Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/ # Example format: plugins=(rails git textmate ruby lighthouse) -plugins=(git) +plugins=(git vi-mode) +source ~/.bash_profile source $ZSH/oh-my-zsh.sh # User configuration @@ -59,7 +60,7 @@ export JAVA_HOME=/home/users/shiludeng/.jumbo/opt/sun-java6 export HADOOP_INSTALL=/home/users/shiludeng/data/dev/hadoop/hadoop #/home/tools/tools/maven/apache-maven-2.2.1/bin export PATH=$HOME/bin:$HADOOP_INSTALL/bin:/usr/local/bin:$PATH -bash ~/.bash_profile + # export MANPATH="/usr/local/man:$MANPATH" # You may need to manually set your language environment diff --git a/themes/azure.zsh-theme b/themes/azure.zsh-theme index 65a1e7db3..61a41e247 100644 --- a/themes/azure.zsh-theme +++ b/themes/azure.zsh-theme @@ -11,7 +11,7 @@ FINISH="%{$terminfo[sgr0]%}" #}}} #命令提示符 -RPROMPT=$(echo "$RED%D %T$FINISH") +#RPROMPT=$(echo "$RED%D %T$FINISH") PROMPT=$(echo "$CYAN%n@$YELLOW%M:$GREEN%/$_YELLOW>$FINISH ") #PROMPT=$(echo "$BLUE%M$GREEN%/ @@ -120,8 +120,8 @@ setopt AUTO_MENU #开启此选项,补全时会直接选中菜单项 #setopt MENU_COMPLETE -autoload -U compinit -compinit +#autoload -U compinit +#compinit autoload -U select-word-style select-word-style whitespace @@ -216,18 +216,6 @@ 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 -#}}} - #命令别名 {{{ alias cp='cp -i' alias mv='mv -i' @@ -352,8 +340,8 @@ autoload -U ~/.zsh/functions/*(:t) # Set the prompt. local ret_status="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ %s)" -PROMPT='%{${fg[cyan]}%}┌%n@%{${fg[yellow]}%}%M:%{${fg[cyan]}%}%B%~%{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%}$(svn_prompt_info)%{${fg[default]}%}%{$fg[cyan]%} -└> %' +PROMPT='%{${fg[cyan]}%}%n@%{${fg[yellow]}%}%M:%{${fg[cyan]}%}%B%/%{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%}$(svn_prompt_info)%{${fg[default]}%}%{$fg[cyan]%} +> %' ZSH_PROMPT_BASE_COLOR="%{$fg_bold[blue]%}" ZSH_THEME_REPO_NAME_COLOR="%{$fg_bold[yello]%}" From 0f60c59915fd68637bfddc538391c2c3902814ec Mon Sep 17 00:00:00 2001 From: shiludeng Date: Thu, 8 Dec 2016 14:55:07 +0800 Subject: [PATCH 13/16] add zsh vim-mode --- themes/azure.zsh-theme | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/themes/azure.zsh-theme b/themes/azure.zsh-theme index 61a41e247..6bf2279fb 100644 --- a/themes/azure.zsh-theme +++ b/themes/azure.zsh-theme @@ -340,8 +340,10 @@ autoload -U ~/.zsh/functions/*(:t) # Set the prompt. local ret_status="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ %s)" -PROMPT='%{${fg[cyan]}%}%n@%{${fg[yellow]}%}%M:%{${fg[cyan]}%}%B%/%{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%}$(svn_prompt_info)%{${fg[default]}%}%{$fg[cyan]%} -> %' +export MODE_INDICATOR="<<>>" +RPS2="$(vi_mode_prompt_info)" +PROMPT='%{${fg[cyan]}%}%n@%{${fg[yellow]}%}%M:%{${fg[cyan]}%}%B%/%{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%}$(svn_prompt_info)%{${fg[default]}%}%{$fg[cyan]%}$(vi_mode_prompt_info) +> ' ZSH_PROMPT_BASE_COLOR="%{$fg_bold[blue]%}" ZSH_THEME_REPO_NAME_COLOR="%{$fg_bold[yello]%}" From 90354316d49f3b1ab4328f95d6babd024d4b8ba7 Mon Sep 17 00:00:00 2001 From: shiludeng Date: Wed, 18 Jan 2017 17:32:01 +0800 Subject: [PATCH 14/16] set JAVA_HOME when not set --- .zshrc | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/.zshrc b/.zshrc index 2f6a81fbe..758f410a4 100644 --- a/.zshrc +++ b/.zshrc @@ -6,11 +6,18 @@ export ZSH=$HOME/.oh-my-zsh # Optionally, if you set this to "random", it'll load a random theme each # time that oh-my-zsh is loaded. #ZSH_THEME="robbyrussell" +#ZSH_THEME="random" ZSH_THEME="azure" +#ZSH_THEME="re5et" +#ZSH_THEME="fox" # Example aliases # alias zshconfig="mate ~/.zshrc" # alias ohmyzsh="mate ~/.oh-my-zsh" +alias astyle="astyle --style=kr --convert-tabs --indent=spaces=4 --add-brackets \ +--pad-header --unpad-paren --pad-oper --max-code-length=100 --formatted --align-pointer=type \ +--align-reference=type -Y" +#alias eagle.py="eagle.py -f" # Uncomment the following line to use case-sensitive completion. # CASE_SENSITIVE="true" @@ -36,7 +43,7 @@ ZSH_THEME="azure" # Uncomment the following line if you want to disable marking untracked files # under VCS as dirty. This makes repository status check for large repositories # much, much faster. -# DISABLE_UNTRACKED_FILES_DIRTY="true" +#DISABLE_UNTRACKED_FILES_DIRTY="true" # Uncomment the following line if you want to change the command execution time # stamp shown in the history command output. @@ -49,20 +56,27 @@ ZSH_THEME="azure" # Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*) # Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/ # Example format: plugins=(rails git textmate ruby lighthouse) -plugins=(git vi-mode) +plugins=(git-prompt git svn vi-mode) -source ~/.bash_profile source $ZSH/oh-my-zsh.sh # User configuration -export JAVA_HOME=/home/users/shiludeng/.jumbo/opt/sun-java6 +if [[ -z $JAVA_HOME ]]; then + export JAVA_HOME=/home/users/shiludeng/.jumbo/opt/sun-java6 +fi export HADOOP_INSTALL=/home/users/shiludeng/data/dev/hadoop/hadoop #/home/tools/tools/maven/apache-maven-2.2.1/bin -export PATH=$HOME/bin:$HADOOP_INSTALL/bin:/usr/local/bin:$PATH +export PATH=$HOME/programs/ccover/bin:$HOME/programs/bin/:$HOME/bin:$HADOOP_INSTALL/bin:/usr/local/bin:$PATH +source ~/.bash_profile +source ~/.bashrc +export MAC=64 # export MANPATH="/usr/local/man:$MANPATH" +hash -d weigou="/home/users/shiludeng/data/dev/app/ecom/weigou" +hash -d moviese="/home/users/shiludeng/data/dev/app/search/movie/user/se" +export SVN_EDITOR=vim # You may need to manually set your language environment #export LANG=en_US.UTF-8 @@ -78,3 +92,4 @@ export PATH=$HOME/bin:$HADOOP_INSTALL/bin:/usr/local/bin:$PATH # ssh # export SSH_KEY_PATH="~/.ssh/dsa_id" +setopt no_nomatch From 156bf6bfc63353df5ba76ca0c4f16c63411e6e7b Mon Sep 17 00:00:00 2001 From: shiludeng Date: Sun, 26 Nov 2017 18:06:57 +0800 Subject: [PATCH 15/16] update svn.plugin.zsh --- plugins/svn/svn.plugin.zsh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/plugins/svn/svn.plugin.zsh b/plugins/svn/svn.plugin.zsh index d8ed34079..87495baaa 100644 --- a/plugins/svn/svn.plugin.zsh +++ b/plugins/svn/svn.plugin.zsh @@ -62,9 +62,8 @@ function svn_get_rev_nr() { function svn_dirty_choose() { if in_svn; then - root=`svn info 2> /dev/null | sed -n 's/^Working Copy Root Path: //p'` - status_str=`svn status $root 2> /dev/null` - if $(echo $status_str | grep -Eq '^\s*[ACDIM!L]'); then + local root=$(LANG=C svn info 2> /dev/null | sed -n 's/^Working Copy Root Path: //p') + if svn status $root 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'; then # Grep exits with 0 when "One or more lines were selected", return "dirty". echo $1 elif $(echo $status_str | grep -Eq '^\s*[?]'); then @@ -76,8 +75,8 @@ function svn_dirty_choose() { fi } -function svn_dirty() { - svn_dirty_choose $ZSH_THEME_SVN_PROMPT_DIRTY $ZSH_THEME_SVN_PROMPT_UNTRACKED $ZSH_THEME_SVN_PROMPT_CLEAN +svn_dirty_pwd () { + svn_dirty_choose_pwd $ZSH_THEME_SVN_PROMPT_DIRTY_PWD $ZSH_THEME_SVN_PROMPT_CLEAN_PWD } function svn_dirty_choose_pwd () { From b54c5c62626491d8f35fdd1a30132ad31bdf7827 Mon Sep 17 00:00:00 2001 From: shiludeng Date: Sun, 26 Nov 2017 18:09:56 +0800 Subject: [PATCH 16/16] update svn.plugin.zsh --- plugins/svn/svn.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/svn/svn.plugin.zsh b/plugins/svn/svn.plugin.zsh index 87495baaa..a5de56c0f 100644 --- a/plugins/svn/svn.plugin.zsh +++ b/plugins/svn/svn.plugin.zsh @@ -76,7 +76,7 @@ function svn_dirty_choose() { } svn_dirty_pwd () { - svn_dirty_choose_pwd $ZSH_THEME_SVN_PROMPT_DIRTY_PWD $ZSH_THEME_SVN_PROMPT_CLEAN_PWD + svn_dirty_choose_pwd $ZSH_THEME_SVN_PROMPT_DIRTY_PWD $ZSH_THEME_SVN_PROMPT_CLEAN_PWD } function svn_dirty_choose_pwd () {