Skip to content

Instantly share code, notes, and snippets.

@kamaln7
Created August 21, 2015 21:14
Show Gist options
  • Save kamaln7/aa9f831c75e3ba4ec8d8 to your computer and use it in GitHub Desktop.
Save kamaln7/aa9f831c75e3ba4ec8d8 to your computer and use it in GitHub Desktop.
autoload -U compinit promptinit zcalc zsh-mime-setup
compinit
promptinit
zsh-mime-setup
#}}}
#{{{ Options
# why would you type 'cd dir' if you could just type 'dir'?
setopt AUTO_CD
# Now we can pipe to multiple outputs!
setopt MULTIOS
# Spell check commands! (Sometimes annoying)
setopt CORRECT
# This will use named dirs when possible
setopt AUTO_NAME_DIRS
# If we have a glob this will expand it
setopt GLOB_COMPLETE
# No more annoying pushd messages...
# setopt PUSHD_SILENT
# 10 second wait if you do something that will delete everything. I wish I'd had this before...
setopt RM_STAR_WAIT
# use magic (this is default, but it can't hurt!)
setopt ZLE
setopt NO_HUP
setopt VI
# only fools wouldn't do this ;-)
export EDITOR="vim"
setopt IGNORE_EOF
# If I could disable Ctrl-s completely I would!
setopt NO_FLOW_CONTROL
# beeps are annoying
setopt NO_BEEP
# Keep echo "station" > station from clobbering station
setopt NO_CLOBBER
# Case insensitive globbing
setopt NO_CASE_GLOB
# Be Reasonable!
setopt NUMERIC_GLOB_SORT
# I don't know why I never set this before.
setopt EXTENDED_GLOB
#}}}
#{{{ Completion Stuff
# Faster! (?)
zstyle ':completion::complete:*' use-cache 1
# case insensitive completion
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
zstyle ':completion:*' verbose yes
zstyle ':completion:*:descriptions' format '%B%d%b'
zstyle ':completion:*:messages' format '%d'
zstyle ':completion:*:warnings' format 'No matches for: %d'
zstyle ':completion:*' group-name ''
#zstyle ':completion:*' completer _oldlist _expand _force_rehash _complete
zstyle ':completion:*' completer _expand _force_rehash _complete _approximate _ignored
# generate descriptions with magic.
zstyle ':completion:*' auto-description 'specify: %d'
# Don't prompt for a huge list, page it!
zstyle ':completion:*:default' list-prompt '%S%M matches%s'
# Don't prompt for a huge list, menu it!
zstyle ':completion:*:default' menu 'select=0'
# Have the newer files last so I see them first
zstyle ':completion:*' file-sort modification reverse
# color code completion!!!! Wohoo!
zstyle ':completion:*' list-colors "=(#b) #([0-9]#)*=36=31"
unsetopt LIST_AMBIGUOUS
setopt COMPLETE_IN_WORD
# Separate man page sections. Neat.
zstyle ':completion:*:manuals' separate-sections true
# Egomaniac!
zstyle ':completion:*' list-separator 'fREW'
# complete with a menu for xwindow ids
zstyle ':completion:*:windows' menu on=0
zstyle ':completion:*:expand:*' tag-order all-expansions
# more errors allowed for large words and fewer for small words
zstyle ':completion:*:approximate:*' max-errors 'reply=( $(( ($#PREFIX+$#SUFFIX)/3 )) )'
# Errors format
zstyle ':completion:*:corrections' format '%B%d (errors %e)%b'
# Don't complete stuff already on the line
zstyle ':completion::*:(rm|vi):*' ignore-line true
# Don't complete directory we are already in (../here)
zstyle ':completion:*' ignore-parents parent pwd
zstyle ':completion::approximate*:*' prefix-needed false
#}}}
#{{{ Key bindings
# Who doesn't want home and end to work?
bindkey '\e[1~' beginning-of-line
bindkey '\e[4~' end-of-line
# Ensure that arrow keys work as they should
bindkey '\e[A' up-line-or-history
bindkey '\e[B' down-line-or-history
bindkey '\eOA' up-line-or-history
bindkey '\eOB' down-line-or-history
bindkey '\e[C' forward-char
bindkey '\e[D' backward-char
bindkey '\eOC' forward-char
bindkey '\eOD' backward-char
bindkey -M viins 'jj' vi-cmd-mode
bindkey -M vicmd 'u' undo
# Rebind the insert key. I really can't stand what it currently does.
bindkey '\e[2~' overwrite-mode
# Rebind the delete key. Again, useless.
bindkey '\e[3~' delete-char
#}}}
#{{{ History Stuff
# Where it gets saved
HISTFILE=~/.zsh_history
# Remember about a years worth of history (AWESOME)
SAVEHIST=10000
HISTSIZE=10000
# Don't overwrite, append!
setopt APPEND_HISTORY
# Write after each command
# setopt INC_APPEND_HISTORY
# Killer: share history between multiple shells
setopt SHARE_HISTORY
# Pretty Obvious. Right?
setopt HIST_REDUCE_BLANKS
# If a line starts with a space, don't save it.
setopt HIST_IGNORE_SPACE
setopt HIST_NO_STORE
host_color=cyan
user_color=green
root_color=red
directory_color=magenta
host_prompt="%{$fg_bold[$host_color]%}%m%{$reset_color%}"
case "$TERM" in
(screen)
function precmd() { print -Pn "\033]0;S $TTY:t{%100<...<%~%<<}\007" }
;;
(xterm)
directory_prompt=""
;;
(*)
directory_prompt="%{$fg[$directory_color]%}%~%{$reset_color%} "
;;
esac
if [[ $USER == root ]]; then
post_prompt="%{$fg_bold[$root_color]%}%#%{$reset_color%}"
else
post_prompt="%{$fg_bold[$user_color]%}%#%{$reset_color%}"
fi
PS1="${host_prompt} ${directory_prompt}${post_prompt} "
autoload -U compinit promptinit zcalc zsh-mime-setup
compinit
promptinit
zsh-mime-setup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment