PCが変わるたびにzshの設定をするのが面倒なので、
完全に俺得なzshの設定をまとめる
Env
- OSX 10.11.3
- zsh 5.0.8
Setting
1. Download zsh-completions
$ git clone https://github.com/zsh-users/zsh-completions.git
...
$ mv zsh-completions /usr/local/share
2. Create zshrc
#---------------------------
# settings for alias
alias ls='ls -Gw'
alias ll='ls -l'
alias la='ls -a'
alias lf='ls -F'
alias du='du -h'
alias df='df -h'
alias dc='cd ~/Documents'
alias dl='cd ~/Downloads'
alias wget='wget -P ~/Downloads'
#--------------------------
# settings for language format
export LANG=ja_JP.UTF-8
#--------------------------
# settings for keybind
# like emacs
bindkey -e
# change dir to parent by pressing [ctrl+^]
function cdup() {
echo
cd ..
zle reset-prompt
}
zle -N cdup
bindkey '^^' cdup
#---------------------------
# settings for cd command
# can cd in dir name only
setopt auto_cd
# when cd, ls run automatically
function chpwd() { ls }
#---------------------------
# settings for prompt
PROMPT="%F{6}[%n]%f $ "
RPROMPT="%F{6}[%~]%f"
# show git info
autoload -Uz vcs_info
setopt prompt_subst
zstyle ':vcs_info:git:*' check-for-changes true
zstyle ':vcs_info:git:*' stagedstr "%F{yellow}!"
zstyle ':vcs_info:git:*' unstagedstr "%F{red}+"
zstyle ':vcs_info:*' formats "%F{green}%c%u[%b]%f"
zstyle ':vcs_info:*' actionformats '[%b|%a]'
precmd () { vcs_info }
RPROMPT=$RPROMPT'${vcs_info_msg_0_}'
#---------------------------
# settings for compinit
# compinit to enable
autoload -U compinit && compinit
# use zsh-completions
fpath=(/usr/local/share/zsh-completions/src $fpath)
# to match the capital letters in lower case
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
# use color to completions list
autoload colors
zstyle ':completion:*' list-colors "${LS_COLORS}"
# grouping for completions list
zstyle ':completion:*' group-name ''
# selectable menu for completions list
zstyle ':completion:*:default' menu select=2
# to complete by sudo
zstyle ':completion:*:sudo:*' command-path /usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin
# don't check by completions list overflow from display
LISTMAX=1000
# after several times cd, cd history is complemented by [cd -<TAB>]
DIRSTACKSIZE=100
setopt AUTO_PUSHD
zstyle ':completion:*' menu select
zstyle ':completion:*:cd:*' ignore-parents parent pwd
zstyle ':completion:*:descriptions' format '%BCompleting%b %U%d%u'
# completions to list
setopt auto_list
# switch completions by tab
setopt auto_menu
# automatically complement the brackets
setopt auto_param_keys
# complement the aliases
setopt complete_aliases
# complement after [=]
setopt magic_equal_subst
# compacked complete list display
setopt list_packed
#---------------------------
# settings for history
# history file path to set
HISTFILE=~/.zsh_history
# history file size to set
HISTSIZE=1000000
SAVEHIST=1000000
# history time format to set
HISTTIMEFORMAT="[%Y/%M/%D %H:%M:%S] "
# sharing to history
setopt share_history
# history ignore to
setopt hist_ignore_dups
setopt hist_find_no_dups
setopt hist_expire_dups_first
setopt hist_ignore_all_dups
setopt hist_no_store
setopt hist_reduce_blanks
# write login and logout time to history
setopt extended_history
####################
# other settings
# if you typo, asks correct it
setopt correct
# no beep
setopt NO_BEEP
setopt NO_LIST_BEEP