Skip to content

Instantly share code, notes, and snippets.

@virtualdreams
Last active August 9, 2018 18:29
Show Gist options
  • Save virtualdreams/640c768a7ed3bd749f5c to your computer and use it in GitHub Desktop.
Save virtualdreams/640c768a7ed3bd749f5c to your computer and use it in GitHub Desktop.
Simple zsh configuration
# init
autoload -U colors && colors
alias ls='ls --color=auto'
alias rm='rm -i'
setopt nobeep # avoid beep
setopt noglobdots # * shouldn't match dotfiles
setopt no_auto_remove_slash
setopt hash_list_all
#setopt auto_pushd
#setopt pushd_ignore_dups
# path modifications
autoload -U path
#path+=/foo/bar/bin
# edit command line
autoload -U edit-command-line
zle -N edit-command-line
bindkey "^x^e" edit-command-line
# history configuration
HISTFILE=${ZDOTDIR:-${HOME}}/.zsh_history
HISTSIZE=10000
SAVEHIST=10000
alias history='fc -fl 1'
setopt append_history
setopt extended_history
setopt share_history
setopt inc_append_history
setopt hist_expire_dups_first
setopt hist_ignore_dups
setopt hist_ignore_space
setopt hist_verify
# completion
autoload -U compinit && compinit
setopt complete_in_word
setopt auto_menu
setopt always_to_end
zstyle ':completion:*:*:*:*:*' menu select
zstyle ':completion:*' list-colors ''
zstyle ':completion:*:*:kill:*:processes' list-colors "=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01"
zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm -w -w"
zstyle ':completion:*' special-dirs ..
zstyle ':completion:*' verbose yes
zstyle ':completion:*:descriptions' format "$fg[yellow]%B--- %d%b"
zstyle ':completion:*' group-name ''
zstyle ':completion:*' accept-exact '*(N)'
zstyle ':completion:*' use-cache on
zstyle ':completion:*' cache-path ${ZDOTDIR:-${HOME}}/.zsh/cache
# git
autoload -Uz vcs_info
zstyle ':vcs_info:*' git enable
zstyle ':vcs_info:git*' formats "(%s) %c%u %b%m "
zstyle ':vcs_info:git*' actionformats "(%s|%a) %c%u %b%m "
zstyle ':vcs_info:git*:*' get-revision true
zstyle ':vcs_info:git*:*' check-for-changes true
precmd() {
vcs_info
# set xterm title
print -Pn "\e]0;%n@%m: %~\a"
}
# search history
autoload -U up-line-or-beginning-search
autoload -U down-line-or-beginning-search
zle -N up-line-or-beginning-search
zle -N down-line-or-beginning-search
bindkey "^r" history-incremental-search-backward
bindkey "${terminfo[kcuu1]}" up-line-or-beginning-search
bindkey "${terminfo[kcud1]}" down-line-or-beginning-search
bindkey "${terminfo[khome]}" beginning-of-line
bindkey "${terminfo[kend]}" end-of-line
bindkey "${terminfo[kpp]}" beginning-of-history
bindkey "${terminfo[knp]}" end-of-history
bindkey "${terminfo[kcbt]}" reverse-menu-complete
#bindkey "${terminfo[kcuu1]}" history-search-backward
#bindkey "${terminfo[kcud1]}" history-search-forward
# prompt
setopt prompt_subst
PROMPT='%{$fg_bold[blue]%}%n%{$reset_color%}@%m %{$fg_bold[default]%}%~ %{$fg_no_bold[cyan]%}${vcs_info_msg_0_}%{$fg[default]%}%#%{$reset_color%} '
RPROMPT=''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment