Skip to content

Instantly share code, notes, and snippets.

@zinovyev
Last active August 29, 2015 14:09
Show Gist options
  • Save zinovyev/1f1d93303d1e08c2de46 to your computer and use it in GitHub Desktop.
Save zinovyev/1f1d93303d1e08c2de46 to your computer and use it in GitHub Desktop.
.zshrc
# Start tmux on every shell login
# 1. If not running interactively, do not do anything
# [[ $- != *i* ]] && return
# [[ -z "$TMUX" ]] && exec tmux
# 2. Only create a session if no tmux is running
# if which tmux >/dev/null 2>&1; then
# #if not inside a tmux session, and if no session is started, start a new session
# test -z "$TMUX" && (tmux attach || tmux new-session)
# fi
## Export
export EDITOR=vi
## Alias
alias ls='ls --color=auto'
alias grep='grep --color=auto'
alias -s {avi,mpeg,mpg,mov,m2v}=vlc
alias -s {odt,doc,sxw,rtf}=openoffice.org
autoload -U pick-web-browser
alias -s {html,htm}=firefox
alias vi='vim'
## Commands
# Command completion
autoload -U compinit
compinit
zstyle ':completion:*' menu select
setopt completealiases
# Command corrections
setopt correctall
## History
export HISTSIZE=10000
export HISTFILE="$HOME/.history"
export SAVEHIST=$HISTSIZE
setopt hist_ignore_all_dups
setopt hist_ignore_space
## Key bindings
# create a zkbd compatible hash;
# to add other keys to this hash, see: man 5 terminfo
typeset -A key
# basic keys
key[Home]=${terminfo[khome]}
key[End]=${terminfo[kend]}
key[Insert]=${terminfo[kich1]}
key[Delete]=${terminfo[kdch1]}
key[Up]=${terminfo[kcuu1]}
key[Down]=${terminfo[kcud1]}
key[Left]=${terminfo[kcub1]}
key[Right]=${terminfo[kcuf1]}
key[PageUp]=${terminfo[kpp]}
key[PageDown]=${terminfo[knp]}
# setup key accordingly
[[ -n "${key[Home]}" ]] && bindkey "${key[Home]}" beginning-of-line
[[ -n "${key[End]}" ]] && bindkey "${key[End]}" end-of-line
[[ -n "${key[Insert]}" ]] && bindkey "${key[Insert]}" overwrite-mode
[[ -n "${key[Delete]}" ]] && bindkey "${key[Delete]}" delete-char
[[ -n "${key[Up]}" ]] && bindkey "${key[Up]}" up-line-or-history
[[ -n "${key[Down]}" ]] && bindkey "${key[Down]}" down-line-or-history
[[ -n "${key[Left]}" ]] && bindkey "${key[Left]}" backward-char
[[ -n "${key[Right]}" ]] && bindkey "${key[Right]}" forward-char
[[ -n "${key[PageUp]}" ]] && bindkey "${key[PageUp]}" beginning-of-buffer-or-history
[[ -n "${key[PageDown]}" ]] && bindkey "${key[PageDown]}" end-of-buffer-or-history
# Finally, make sure the terminal is in application mode, when zle is
# active. Only then are the values from $terminfo valid.
if (( ${+terminfo[smkx]} )) && (( ${+terminfo[rmkx]} )); then
function zle-line-init () {
printf '%s' "${terminfo[smkx]}"
}
function zle-line-finish () {
printf '%s' "${terminfo[rmkx]}"
}
zle -N zle-line-init
zle -N zle-line-finish
fi
# History search
bindkey '^R' history-incremental-search-backward
[[ -n "${key[PageUp]}" ]] && bindkey "${key[PageUp]}" history-beginning-search-backward
[[ -n "${key[PageDown]}" ]] && bindkey "${key[PageDown]}" history-beginning-search-forward
## Prompts
autoload -U promptinit
promptinit
prompt suse
## Help command
autoload -U run-help
autoload run-help-git
autoload run-help-svn
autoload run-help-svk
## unalias run-help
alias help=run-help
## Fish-like syntax highlighting
source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
## Auto cd
setopt autocd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment