常用Linux环境-zsh

系统 centos6.5

zsh配置

  • 切换默认shell为zsh
chsh
  • 安装oh-my-zsh
wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh
  • 常用zsh设置
ZSH_THEME="ys"

#可以用小键盘输入
bindkey -s "^[Op" "0"
bindkey -s "^[On" "."
bindkey -s "^[OM" "^M"
### 1 2 3                                                                                              
bindkey -s "^[Oq" "1"
bindkey -s "^[Or" "2"
bindkey -s "^[Os" "3"
### 4 5 6                                                                                              
bindkey -s "^[Ot" "4"
bindkey -s "^[Ou" "5"
bindkey -s "^[Ov" "6"
### 7 8 9                                                                                              
bindkey -s "^[Ow" "7"
bindkey -s "^[Ox" "8"
bindkey -s "^[Oy" "9"
### + - * /                                                                                            
bindkey -s "^[Ol" "+"
bindkey -s "^[Om" "-"
bindkey -s "^[Oj" "*"
bindkey -s "^[Oo" "/" 

#双击esc sudo
sudo-command-line() {                                                                                  
    [[ -z $BUFFER ]] && zle up-history                                                                 
    if [[ $BUFFER == sudo\ * ]]; then                                                                  
        LBUFFER="${LBUFFER#sudo }"                                                                     
    elif [[ $BUFFER == $EDITOR\ * ]]; then                                                             
        LBUFFER="${LBUFFER#$EDITOR }"                                                                  
        LBUFFER="sudoedit $LBUFFER"                                                                    
    elif [[ $BUFFER == sudoedit\ * ]]; then                                                            
        LBUFFER="${LBUFFER#sudoedit }"                                                                 
        LBUFFER="$EDITOR $LBUFFER"                                                                     
    else                                                                                               
        LBUFFER="sudo $LBUFFER"                                                                        
    fi                                                                                                 
}                                                                                                      
zle -N sudo-command-line                                                                               
# Defined shortcut keys: [Esc] [Esc]                                                                   
bindkey "\e\e" sudo-command-line 

HISTFILE=~/.histfile                                                                                   
HISTSIZE=10000                                                                                         
SAVEHIST=10000
setopt SHARE_HISTORY
  • zsh插件
  1. zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
  1. autojump
git clone git://github.com/joelthelion/autojump.git
cd autojump
./install.py

将安装完的提示记得添加到~/.zshrc,安装完autojump也有提示

你可能感兴趣的:(常用Linux环境-zsh)