Skip to content

Instantly share code, notes, and snippets.

@kfl62
Created November 11, 2011 06:51
Show Gist options
  • Save kfl62/1357382 to your computer and use it in GitHub Desktop.
Save kfl62/1357382 to your computer and use it in GitHub Desktop.
zsh settings
# go to saved path if there is one
if [[ -f ~/.current_path~ ]]; then
cd `cat ~/.current_path~`
rm ~/.current_path~
fi
setopt nullglob
source /etc/profile.d/cnf.sh
[[ -s $HOME/.rvm/scripts/rvm ]] && source $HOME/.rvm/scripts/rvm
for file in ~/.zsh/modules-enabled/*; do
source $file
done
# use .localrc for settings specific to one system
[[ -f ~/.localrc ]] && . ~/.localrc
### at this moment I don't have a .localrc ###
if [[ -n $SSH_CONNECTION ]]; then
export PS1='%m:%3~$(git_info_for_prompt)> '
else
if [[ -s $HOME/.rvm/bin/rvm-prompt ]]; then
export PS1='|$(~/.rvm/bin/rvm-prompt v s)| %3~$(git_info_for_prompt)> '
else
export PS1='|system| %3~$(git_info_for_prompt)> '
fi
fi
export EDITOR='/usr/bin/vim'
export PATH="$PATH:$HOME/bin:/usr/local/lib"
cdpath=( /usr ~ ~/work )
fpath=(~/.zsh/functions $fpath)
autoload -U ~/.zsh/functions/*(:t)
HISTFILE=~/.zsh_history
HISTSIZE=1000
SAVEHIST=1000
setopt NO_BG_NICE # don't nice background tasks
setopt NO_HUP
setopt NO_LIST_BEEP
setopt LOCAL_OPTIONS # allow functions to have local options
setopt LOCAL_TRAPS # allow functions to have local traps
setopt HIST_VERIFY
setopt SHARE_HISTORY # share history between sessions ???
setopt EXTENDED_HISTORY # add timestamps to history
setopt PROMPT_SUBST
setopt CORRECT
setopt COMPLETE_IN_WORD
setopt IGNORE_EOF
setopt APPEND_HISTORY # adds history
setopt INC_APPEND_HISTORY SHARE_HISTORY # adds history incrementally and share it across sessions
setopt HIST_IGNORE_ALL_DUPS # don't record dupes in history
setopt HIST_REDUCE_BLANKS
autoload zkbd
function zkbd_file() {
[[ -f ~/.zkbd/${TERM}-${VENDOR}-${OSTYPE} ]] && printf '%s' ~/".zkbd/${TERM}-${VENDOR}-${OSTYPE}" && return 0
[[ -f ~/.zkbd/${TERM}-${DISPLAY} ]] && printf '%s' ~/".zkbd/${TERM}-${DISPLAY}" && return 0
return 1
}
[[ ! -d ~/.zkbd ]] && mkdir ~/.zkbd
keyfile=$(zkbd_file)
ret=$?
if [[ ${ret} -ne 0 ]]; then
zkbd
keyfile=$(zkbd_file)
ret=$?
fi
if [[ ${ret} -eq 0 ]] ; then
source "${keyfile}"
else
printf 'Failed to setup keys using zkbd.\n'
fi
unfunction zkbd_file; unset keyfile ret
# 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
bindkey "^[[A" history-search-backward
bindkey "^[[B" history-search-forward
zmodload zsh/complist
autoload -U compinit && compinit -C
### If you want zsh's completion to pick up new commands in $path automatically
### comment out the next line and un-comment the following 5 lines
zstyle ':completion:::::' completer _complete _approximate
#_force_rehash() {
# (( CURRENT == 1 )) && rehash
# return 1 # Because we didn't really complete anything
#}
#zstyle ':completion:::::' completer _force_rehash _complete _approximate
zstyle -e ':completion:*:approximate:*' max-errors 'reply=( $(( ($#PREFIX + $#SUFFIX) / 3 )) )'
zstyle ':completion:*:descriptions' format "- %d -"
zstyle ':completion:*:corrections' format "- %d - (errors %e})"
zstyle ':completion:*:default' list-prompt '%S%M matches%s'
zstyle ':completion:*' group-name ''
zstyle ':completion:*:manuals' separate-sections true
zstyle ':completion:*:manuals.(^1*)' insert-sections true
zstyle ':completion:*' menu select
zstyle ':completion:*' verbose yes
### /etc/profile.d/cnf.sh sourced in .zshenv ###
case "${SHELL}" in
*/zsh)
function command_not_found_handler () {
if [ -x /usr/bin/cnf-lookup ];then
cnf-lookup -c $1
fi
return 127
}
;;
*/bash)
function command_not_found_handle () {
if [ -x /usr/bin/cnf-lookup ];then
cnf-lookup -c $1
if [ ! $? -eq 0 ];then
echo "bash: $1: command not found"
fi
else
echo "bash: $1: command not found"
fi
return 127
}
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment