zsh配置

当前的zsh配置文件(mac系统下),我没有用 oh-my-zsh 觉得里面很多自己用不上,还是根据自己的习惯配置的。
推荐一下 zsh-syntax-highlighting 这个插件,当命令输入不正确时颜色为红色,拼写正确为绿色。

autoload -Uz promptinit
promptinit
prompt adam1

setopt histignorealldups sharehistory
# Use emacs keybindings even if our EDITOR is set to vi
bindkey -e

source ~/.zsh_plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
source ~/.zsh_plugins/zsh-history-substring-search.zsh
source ~/.zprompt

bindkey '^r' history-incremental-pattern-search-backward
#bindkey '^f' history-incremental-pattern-search-forward

bindkey "^[[A" history-search-backward
bindkey "^[[B" history-search-forward
bindkey '^p' history-search-backward
bindkey '^n' history-search-forward

# Keep 1000 lines of history within the shell and save it to ~/.zsh_history:
HISTSIZE=2000
SAVEHIST=2000
HISTFILE=~/.zsh_history

# Use modern completion system
autoload -Uz compinit
compinit

zstyle ':completion:*' auto-description 'specify: %d'
zstyle ':completion:*' completer _expand _complete _correct _approximate
zstyle ':completion:*' format 'Completing %d'
zstyle ':completion:*' group-name ''
zstyle ':completion:*' menu select=2
#eval "$(dircolors -b)"
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
zstyle ':completion:*' list-colors ''
zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s
zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}' 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=* l:|=*'
zstyle ':completion:*' menu select=long
zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s
zstyle ':completion:*' use-compctl false
zstyle ':completion:*' verbose true

zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd'

zstyle ':completion:*:manuals'    separate-sections true
zstyle ':completion:*:manuals.*'  insert-sections   true
zstyle ':completion:*:man:*'      menu yes select

#fpath=(~/.zsh/completion $fpath)

# alias
alias -g ...='../..'
alias -g ....='../../..'
alias '?'='history | grep -i '
alias 'p?'='ps aux | grep -i '

alias which='which -a'
alias sed='/usr/local/bin/gsed'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
alias screen='screen -s zsh'
#alias ss='xfce4-screenshooter -r'
alias xclip='xclip -selection clipboard'
alias history='history -1000'
#alias man='TERMINFO=~/.terminfo/ LESS=C TERM=mostlike PAGER=less man'
alias man='TERMINFO=~/.terminfo/ LESS=C PAGER=less man'
alias ls='ls -G'
alias ll='ls -l'
alias la='ls -A'
alias l='ls -CF'
alias less='/usr/share/vim/vimcurrent/macros/less.sh'
alias find='find . '
alias emacs='emacs -q'
alias scala='EMACS="" && scala -deprecation '
alias polipo-proxy='polipo socksParentProxy=localhost:1984 proxyPort=4891'
alias ecl='open -n /data/tools/eclipse/Eclipse.app'
#alias mvn='mvn3 -s /data/tools/maven/settings-ali.xml'
alias mvn='mvn2' 
alias clhsdb='java -classpath .:$JAVA_HOME/lib/sa-jdi.jar sun.jvm.hotspot.CLHSDB'
alias hsdb='java -classpath .:$JAVA_HOME/lib/sa-jdi.jar sun.jvm.hotspot.HSDB'

export EDITOR=vim
#export LANG=en_US.UTF-8

hash -d alibaba="/data/work/alibaba"
hash -d tb="/data/work/taobao"
hash -d bbl="/data/work/alibaba/bbl"
hash -d opensources="/data/work/opensources"
hash -d downloads="/data/downloads"
hash -d music="/data/music"
hash -d jdkopt="/System/Library/Frameworks/JavaVM.framework/Versions"

#screen integration to set caption bar dynamically
function title {
if [[ $TERM == "screen" || $TERM == "screen.linux" ]]; then
    # Use these two for GNU Screen:
    print -nR $'\033k'$1$'\033'\\\

    print -nR $'\033]0;'$2$'\a'
elif [[ $TERM == "xterm" || $TERM == "urxvt" ]]; then
    # Use this one instead for XTerms:
    print -nR $'\033]0;'$*$'\a'
    #trap 'echo -ne "\e]0;$USER@$HOSTNAME: $BASH_COMMAND\007"' DEBUG
fi
}

function calc() { echo "$*" | bc -l; }
function upto() { cd "${PWD/\/$@\/*//$@}" }
function lower() { echo ${@,,};}
function upper() { echo ${@^^};}

#path
PATH=`echo $PATH | sed -e 's#/usr/local/bin:##' -e 's#^#/usr/local/bin:#'`
PATH="/usr/local/sbin:$PATH"
if [ -d "$HOME/bin" ]; then
  PATH="$HOME/bin:$PATH"
fi
export SCALA_HOME="/data/tools/scala"
export JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home"
export PATH=$JAVA_HOME/bin:$SCALA_HOME/bin:$PATH

#for homebrew
export CPPFLAGS=-I/opt/X11/include
export CFLAGS=-I/opt/X11/include

#autojump
if [ -f `brew --prefix`/etc/autojump.zsh ]; then
  . `brew --prefix`/etc/autojump.zsh
fi
export AUTOJUMP_IGNORE_CASE=1
export AUTOJUMP_KEEP_SYMLINKS=1

#fasd
eval "$(fasd --init posix-alias zsh-hook zsh-ccomp zsh-ccomp-install zsh-wcomp zsh-wcomp-install)"
alias c='fasd_cd -di'

#for iterm
function setTitle() { printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}" }

发表评论

电子邮件地址不会被公开。 必填项已用*标注