Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Update zsh config

  • Loading branch information...
commit 531ed6fe111c26db190f5ef95ecb08ca290f8024 1 parent 278fd20
@rainux authored
Showing with 315 additions and 218 deletions.
  1. +64 −0 .zsh/git.zsh
  2. +96 −0 .zsh/rc.zsh
  3. +154 −0 .zsh/theme.zsh
  4. +1 −218 .zshrc
View
64 .zsh/git.zsh
@@ -0,0 +1,64 @@
+# get the name of the branch we are on
+function git_prompt_info() {
+ ref=$(git symbolic-ref HEAD 2> /dev/null) || return
+ echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX"
+}
+
+# Checks if working tree is dirty
+parse_git_dirty() {
+ if [[ -n $(git status -s 2> /dev/null) ]]; then
+ echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
+ else
+ echo "$ZSH_THEME_GIT_PROMPT_CLEAN"
+ fi
+}
+
+# Checks if there are commits ahead from remote
+function git_prompt_ahead() {
+ if $(echo "$(git log origin/$(current_branch)..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then
+ echo "$ZSH_THEME_GIT_PROMPT_AHEAD"
+ fi
+}
+
+# Formats prompt string for current git commit short SHA
+function git_prompt_short_sha() {
+ SHA=$(git rev-parse --short HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER"
+}
+
+# Formats prompt string for current git commit long SHA
+function git_prompt_long_sha() {
+ SHA=$(git rev-parse HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER"
+}
+
+# Get the status of the working tree
+git_prompt_status() {
+ INDEX=$(git status --porcelain 2> /dev/null)
+ STATUS=""
+ if $(echo "$INDEX" | grep '^?? ' &> /dev/null); then
+ STATUS="$ZSH_THEME_GIT_PROMPT_UNTRACKED$STATUS"
+ fi
+ if $(echo "$INDEX" | grep '^A ' &> /dev/null); then
+ STATUS="$ZSH_THEME_GIT_PROMPT_ADDED$STATUS"
+ elif $(echo "$INDEX" | grep '^M ' &> /dev/null); then
+ STATUS="$ZSH_THEME_GIT_PROMPT_ADDED$STATUS"
+ fi
+ if $(echo "$INDEX" | grep '^ M ' &> /dev/null); then
+ STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS"
+ elif $(echo "$INDEX" | grep '^AM ' &> /dev/null); then
+ STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS"
+ elif $(echo "$INDEX" | grep '^ T ' &> /dev/null); then
+ STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS"
+ fi
+ if $(echo "$INDEX" | grep '^R ' &> /dev/null); then
+ STATUS="$ZSH_THEME_GIT_PROMPT_RENAMED$STATUS"
+ fi
+ if $(echo "$INDEX" | grep '^ D ' &> /dev/null); then
+ STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS"
+ elif $(echo "$INDEX" | grep '^AD ' &> /dev/null); then
+ STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS"
+ fi
+ if $(echo "$INDEX" | grep '^UU ' &> /dev/null); then
+ STATUS="$ZSH_THEME_GIT_PROMPT_UNMERGED$STATUS"
+ fi
+ echo $STATUS
+}
View
96 .zsh/rc.zsh
@@ -0,0 +1,96 @@
+# 关于历史纪录的配置
+# number of lines kept in history
+HISTSIZE=100000
+# number of lines saved in the history after logout
+SAVEHIST=100000
+# location of history
+export HISTFILE=~/.zsh_history
+# append command to history file once executed
+setopt INC_APPEND_HISTORY
+
+# Disable core dumps
+limit coredumpsize 0
+
+# Vi 风格键绑定
+bindkey -v
+bindkey '^R' history-incremental-search-backward
+
+# 以下字符视为单词的一部分
+WORDCHARS='*?_-[]~=&;!#$%^(){}<>'
+
+# Fuck OMZ settings
+# unsetopt correct_all
+# unsetopt share_history
+
+# 自动补全功能
+setopt AUTO_LIST
+setopt AUTO_MENU
+setopt MENU_COMPLETE
+
+autoload -U compinit
+compinit
+
+# Completion caching
+zstyle ':completion::complete:*' use-cache on
+zstyle ':completion::complete:*' cache-path .zcache
+# zstyle ':completion:*:cd:*' ignore-parents parent pwd
+
+# Completion Options
+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
+
+# Path Expansion
+zstyle ':completion:*' expand 'yes'
+zstyle ':completion:*' squeeze-shlashes 'yes'
+zstyle ':completion::complete:*' '\\'
+
+zstyle ':completion:*:*:*:default' menu no select
+zstyle ':completion:*:*:default' force-list always
+
+# 自动补全时候选菜单中的选项使用 dircolors 设定的彩色显示
+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:*' completer _complete _match _approximate
+zstyle ':completion:*:match:*' original only
+zstyle ':completion:*:approximate:*' max-errors 1 numeric
+
+compdef pkill=kill
+compdef pkill=killall
+zstyle ':completion:*:*:kill:*' menu no select
+zstyle ':completion:*:processes' command 'ps -au$USER'
+
+# Group matches and Describe
+zstyle ':completion:*:matches' group 'yes'
+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'
+
+# Import .my_bashrc
+[ -f ~/.my_bashrc ] && . ~/.my_bashrc
+
+# 路径别名 进入相应的路径时只要 cd ~xxx
+hash -d VHOST="/var/www/vhosts"
+
+# For Emacs在Emacs终端中使用Zsh的一些设置 不推荐在Emacs中使用它
+if [[ "$TERM" == "dumb" ]]; then
+ setopt No_zle
+ PROMPT='%n@%M %/
+ >>'
+ alias ls='ls -F'
+fi
+
+source ~/.zsh/theme.zsh
+
+
+source /usr/share/zsh/plugins/zsh-syntax-highlight/zsh-syntax-highlighting.zsh
+
+[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
View
154 .zsh/theme.zsh
@@ -0,0 +1,154 @@
+autoload colors; colors
+
+ZSH_THEME_GIT_PROMPT_PREFIX="git:(%{$fg[blue]%}"
+ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
+ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗%{$reset_color%}"
+ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})"
+
+source ~/.zsh/git.zsh
+
+# 效果超炫的提示符,如需要禁用,注释下面配置
+function precmd {
+
+ local TERMWIDTH
+ (( TERMWIDTH = ${COLUMNS} - 1 ))
+
+
+ ###
+ # Truncate the path if it's too long.
+
+ PR_FILLBAR=""
+ PR_PWDLEN=""
+
+ local promptsize=${#${(%):---(%n@%m:%l)---()--}}
+ local pwdsize=${#${(%):-%~}}
+
+ if [[ "$promptsize + $pwdsize" -gt $TERMWIDTH ]]; then
+ ((PR_PWDLEN=$TERMWIDTH - $promptsize))
+ else
+ PR_FILLBAR="\${(l.(($TERMWIDTH - ($promptsize + $pwdsize)))..${PR_HBAR}.)}"
+ fi
+
+ ###
+ # Get APM info.
+
+ # if which ibam > /dev/null; then
+ # PR_APM_RESULT=`ibam --percentbattery`
+ # elif which apm > /dev/null; then
+ # PR_APM_RESULT=`apm`
+ # fi
+}
+
+
+setopt extended_glob
+
+function preexec {
+ if [[ "$TERM" == "screen" ]]; then
+ local CMD=${1[(wr)^(*=*|sudo|-*)]}
+ echo -n "\ek$CMD\e\\"
+ fi
+
+ print -rn -- $terminfo[el]
+}
+
+setopt prompt_subst
+
+function setprompt {
+ ###
+ # Need this so the prompt will work.
+
+ setopt prompt_subst
+
+
+ ###
+ # See if we can use colors.
+
+ autoload colors zsh/terminfo
+ if [[ "$terminfo[colors]" -ge 8 ]]; then
+ colors
+ 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_COLOUR="%{$terminfo[sgr0]%}"
+
+
+ ###
+ # See if we can use extended characters to look nicer.
+
+ typeset -A altchar
+ set -A altchar ${(s..)terminfo[acsc]}
+ PR_SET_CHARSET="%{$terminfo[enacs]%}"
+ PR_SHIFT_IN="%{$terminfo[smacs]%}"
+ PR_SHIFT_OUT="%{$terminfo[rmacs]%}"
+ PR_HBAR=${altchar[q]:--}
+ # PR_HBAR=" "
+ PR_ULCORNER=${altchar[l]:--}
+ PR_LLCORNER=${altchar[m]:--}
+ PR_LRCORNER=${altchar[j]:--}
+ PR_URCORNER=${altchar[k]:--}
+
+
+ ###
+ # Decide if we need to set titlebar text.
+
+ case $TERM in
+ xterm*)
+ PR_TITLEBAR=$'%{\e]0;%(!.-=*[ROOT]*=- | .)%n@%m:%~ | ${COLUMNS}x${LINES} | %y\a%}'
+ ;;
+ screen)
+ PR_TITLEBAR=$'%{\e_screen \005 (\005t) | %(!.-=[ROOT]=- | .)%n@%m:%~ | ${COLUMNS}x${LINES} | %y\e\\%}'
+ ;;
+ *)
+ PR_TITLEBAR=''
+ ;;
+ esac
+
+
+ ###
+ # Decide whether to set a screen title
+ if [[ "$TERM" == "screen" ]]; then
+ PR_STITLE=$'%{\ekzsh\e\\%}'
+ else
+ PR_STITLE=''
+ fi
+
+
+ ###
+ # APM detection
+
+ # if which ibam > /dev/null; then
+ # PR_APM='$PR_RED${${PR_APM_RESULT[(f)1]}[(w)-2]}%%(${${PR_APM_RESULT[(f)3]}[(w)-1]})$PR_LIGHT_BLUE:'
+ # elif which apm > /dev/null; then
+ # PR_APM='$PR_RED${PR_APM_RESULT[(w)5,(w)6]/\% /%%}$PR_LIGHT_BLUE:'
+ # else
+ PR_APM=''
+ # fi
+
+
+ ###
+ # Finally, the prompt.
+
+ PROMPT_LINE1="$PR_SET_CHARSET$PR_STITLE${(e)PR_TITLEBAR}%{$fg[cyan]%}%n%{$fg[magenta]%}@%{$fg[blue]%}%M %{$fg[green]%}%~ %{$reset_color%}\$(git_prompt_info)"
+ PROMPT_LINE2="%{$fg[red]%}%#%{$reset_color%} YUKI.N> "
+ PROMPT="$PROMPT_LINE1
+$PROMPT_LINE2"
+}
+
+setprompt
+
+function zle-line-init zle-keymap-select {
+ terminfo_down_sc=$terminfo[cud1]$terminfo[cuu1]$terminfo[sc]$terminfo[cud1]
+ MODE_INDICATOR="${${KEYMAP/vicmd/"%F{red}-- NORMAL --%f"}/(main|viins)/"%F{green}-- INSERT --%f"}"
+ PROMPT="$PROMPT_LINE1
+%{$terminfo_down_sc$MODE_INDICATOR$terminfo[rc]%}$PROMPT_LINE2"
+
+ zle reset-prompt
+}
+
+zle -N zle-line-init
+zle -N zle-keymap-select
+
+# vim:set ft=zsh:
View
219 .zshrc
@@ -1,218 +1 @@
-# 关于历史纪录的配置
-# number of lines kept in history
-export HISTSIZE=10000
-# number of lines saved in the history after logout
-export SAVEHIST=10000
-# location of history
-export HISTFILE=~/.zhistory
-# append command to history file once executed
-setopt INC_APPEND_HISTORY
-
-# Disable core dumps
-limit coredumpsize 0
-
-# Vi 风格键绑定
-bindkey -v
-bindkey '^R' history-incremental-search-backward
-
-# 以下字符视为单词的一部分
-WORDCHARS='*?_-[]~=&;!#$%^(){}<>'
-
-# 自动补全功能
-setopt AUTO_LIST
-setopt AUTO_MENU
-setopt MENU_COMPLETE
-
-autoload -U compinit
-compinit
-
-# Completion caching
-zstyle ':completion::complete:*' use-cache on
-zstyle ':completion::complete:*' cache-path .zcache
-# zstyle ':completion:*:cd:*' ignore-parents parent pwd
-
-# Completion Options
-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
-
-# Path Expansion
-zstyle ':completion:*' expand 'yes'
-zstyle ':completion:*' squeeze-shlashes 'yes'
-zstyle ':completion::complete:*' '\\'
-
-zstyle ':completion:*:*:*:default' menu no select
-zstyle ':completion:*:*:default' force-list always
-
-# 自动补全时候选菜单中的选项使用 dircolors 设定的彩色显示
-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:*' completer _complete _match _approximate
-zstyle ':completion:*:match:*' original only
-zstyle ':completion:*:approximate:*' max-errors 1 numeric
-
-compdef pkill=kill
-compdef pkill=killall
-zstyle ':completion:*:*:kill:*' menu no select
-zstyle ':completion:*:processes' command 'ps -au$USER'
-
-# Group matches and Describe
-zstyle ':completion:*:matches' group 'yes'
-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'
-
-# Import .my_bashrc
-[ -f ~/.my_bashrc ] && . ~/.my_bashrc
-
-# 路径别名 进入相应的路径时只要 cd ~xxx
-hash -d VHOST="/var/www/vhosts"
-
-# For Emacs在Emacs终端中使用Zsh的一些设置 不推荐在Emacs中使用它
-if [[ "$TERM" == "dumb" ]]; then
- setopt No_zle
- PROMPT='%n@%M %/
- >>'
- alias ls='ls -F'
-fi
-
-
-
-
-# 效果超炫的提示符,如需要禁用,注释下面配置
-function precmd {
-
-local TERMWIDTH
-(( TERMWIDTH = ${COLUMNS} - 1 ))
-
-
-###
-# Truncate the path if it's too long.
-
-PR_FILLBAR=""
-PR_PWDLEN=""
-
-local promptsize=${#${(%):---(%n@%m:%l)---()--}}
-local pwdsize=${#${(%):-%~}}
-
-if [[ "$promptsize + $pwdsize" -gt $TERMWIDTH ]]; then
- ((PR_PWDLEN=$TERMWIDTH - $promptsize))
-else
- PR_FILLBAR="\${(l.(($TERMWIDTH - ($promptsize + $pwdsize)))..${PR_HBAR}.)}"
-fi
-
-
-###
-# Get APM info.
-
-# if which ibam > /dev/null; then
- # PR_APM_RESULT=`ibam --percentbattery`
-# elif which apm > /dev/null; then
- # PR_APM_RESULT=`apm`
-# fi
-}
-
-
-setopt extended_glob
-preexec () {
- if [[ "$TERM" == "screen" ]]; then
- local CMD=${1[(wr)^(*=*|sudo|-*)]}
- echo -n "\ek$CMD\e\\"
- fi
-}
-
-setprompt () {
- ###
- # Need this so the prompt will work.
-
- setopt prompt_subst
-
-
- ###
- # See if we can use colors.
-
- autoload colors zsh/terminfo
- if [[ "$terminfo[colors]" -ge 8 ]]; then
- colors
- 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_COLOUR="%{$terminfo[sgr0]%}"
-
-
- ###
- # See if we can use extended characters to look nicer.
-
- typeset -A altchar
- set -A altchar ${(s..)terminfo[acsc]}
- PR_SET_CHARSET="%{$terminfo[enacs]%}"
- PR_SHIFT_IN="%{$terminfo[smacs]%}"
- PR_SHIFT_OUT="%{$terminfo[rmacs]%}"
- PR_HBAR=${altchar[q]:--}
- # PR_HBAR=" "
- PR_ULCORNER=${altchar[l]:--}
- PR_LLCORNER=${altchar[m]:--}
- PR_LRCORNER=${altchar[j]:--}
- PR_URCORNER=${altchar[k]:--}
-
-
- ###
- # Decide if we need to set titlebar text.
-
- case $TERM in
- xterm*)
- PR_TITLEBAR=$'%{\e]0;%(!.-=*[ROOT]*=- | .)%n@%m:%~ | ${COLUMNS}x${LINES} | %y\a%}'
- ;;
- screen)
- PR_TITLEBAR=$'%{\e_screen \005 (\005t) | %(!.-=[ROOT]=- | .)%n@%m:%~ | ${COLUMNS}x${LINES} | %y\e\\%}'
- ;;
- *)
- PR_TITLEBAR=''
- ;;
- esac
-
-
- ###
- # Decide whether to set a screen title
- if [[ "$TERM" == "screen" ]]; then
- PR_STITLE=$'%{\ekzsh\e\\%}'
- else
- PR_STITLE=''
- fi
-
-
- ###
- # APM detection
-
- # if which ibam > /dev/null; then
- # PR_APM='$PR_RED${${PR_APM_RESULT[(f)1]}[(w)-2]}%%(${${PR_APM_RESULT[(f)3]}[(w)-1]})$PR_LIGHT_BLUE:'
- # elif which apm > /dev/null; then
- # PR_APM='$PR_RED${PR_APM_RESULT[(w)5,(w)6]/\% /%%}$PR_LIGHT_BLUE:'
- # else
- PR_APM=''
- # fi
-
-
- ###
- # Finally, the prompt.
-
- PROMPT='$PR_SET_CHARSET$PR_STITLE${(e)PR_TITLEBAR}%{%}%n%{%}@%{%}%M %{%}%~
-%{%}%#%{%} YUKI.N> '
-}
-
-setprompt
-
-[[ -s $HOME/.rvm/scripts/rvm ]] && source $HOME/.rvm/scripts/rvm
-
-# vim: set ft=zsh:
+. ~/.zsh/rc.zsh
Please sign in to comment.
Something went wrong with that request. Please try again.