dotfiles/zshrc

193 lines
4.3 KiB
Bash
Raw Normal View History

2011-05-03 21:53:50 -07:00
# .zshrc
# vim: ft=zsh fdm=marker
2012-04-16 12:19:58 -07:00
#
# ZSH init for interactive shells
#
# Eryn Wells <eryn@erynwells.me>
2011-05-03 21:53:50 -07:00
PROMPT_THEME='loquacious'
ZLE_MODE='vim'
2012-04-16 12:19:58 -07:00
# load bash/zsh/ksh agnostic configurations
[[ -e $HOME/.rc ]] && source $HOME/.rc
2012-04-16 12:19:58 -07:00
2012-11-29 15:18:57 -08:00
print_heading -l 1 "Initializing interactive Z Shell"
function configure_general #{{{
{
2012-11-29 15:18:57 -08:00
print_info -l 2 'Configuring general ZSH settings'
# Report seconds since shell was invoked in milliseconds
typeset -F SECONDS
2012-11-29 15:18:57 -08:00
print_info_sub -l 3 'Setting shell options'
# See zshoptions(1)
setopt EXTENDED_GLOB \
MULTIOS \
AUTO_REMOVE_SLASH \
COMPLETE_IN_WORD
} #}}}
# Configure oh-my-zsh
function configure_omz #{{{
{
if [[ ! -d ~/.oh-my-zsh ]]; then
print_error -l 2 "No ~/.oh-my-zsh directory; skipping"
return
fi
print_info -l 2 'Configuring Oh My ZSH!'
ZSH=$HOME/.oh-my-zsh
DISABLE_AUTO_UPDATE="true"
COMPLETION_WAITING_DOTS="true"
plugins=(autojump brew encode64 fasd git gnu-utils history osx python)
source $ZSH/oh-my-zsh.sh
alias v='f -t -e vim -b viminfo'
} #}}}
function configure_zle #{{{
{
2012-11-29 15:18:57 -08:00
print_info -l 2 'Configuring ZLE'
2012-11-29 15:18:57 -08:00
print_info_sub -l 5 "Using $ZLE_MODE command line editing mode"
[[ -z "$ZLE_MODE" ]] && ZLE_MODE='vim'
if [[ $ZLE_MODE == 'vim' ]]; then
bindkey -v
elif [[ $ZLE_MODE == 'emacs' ]]; then
bindkey -e
fi
2011-05-03 21:53:50 -07:00
# Allow deleting over the start of insert mode
zle -A .backward-delete-char vi-backward-delete-char
2011-05-03 21:53:50 -07:00
# Edit commands in $EDITOR on 'v' in command mode
autoload -Uz edit-command-line
zle -N edit-command-line
bindkey -M vicmd v edit-command-line
} #}}}
function configure_modules_and_functions #{{{
{
2012-11-29 15:18:57 -08:00
print_info -l 2 'Loading modules'
local myfpath="$HOME/.zsh/func"
2012-11-29 15:18:57 -08:00
print_info_sub -l 2 "Adding $myfpath to \$fpath"
fpath=($myfpath/makers $myfpath $fpath)
2011-05-03 21:53:50 -07:00
2012-11-29 15:18:57 -08:00
print_info -l 3 'Loading vcs_info'
autoload -Uz vcs_info
zstyle ':vcs_info:*' enable git
load_module 'makers'
2011-05-03 21:53:50 -07:00
2012-11-29 15:18:57 -08:00
print_info -l 3 "Loading pw module"
autoload pw
} #}}}
2011-05-03 21:53:50 -07:00
function configure_prompt #{{{
{
2012-11-29 15:18:57 -08:00
print_info -l 2 "Configuring prompt: $PROMPT_THEME"
autoload -U promptinit
promptinit
prompt $PROMPT_THEME
} #}}}
2011-05-03 21:53:50 -07:00
function configure_zsh_aliases #{{{
{
2012-11-29 15:18:57 -08:00
print_info -l 3 'Creating ZSH-specific aliases'
alias pd='pushd'
alias pod='popd'
2011-05-03 21:53:50 -07:00
#alias -g nc='netcat'
alias -g lessnw='less -S'
# suffix aliases
alias -s c='vim'
alias -s tex='vim'
alias -s txt='vim'
alias -s xml='vim'
alias -s jar='java -jar'
} #}}}
function configure_history #{{{
{
2012-11-29 15:18:57 -08:00
print_info -l 2 'Setting up history'
setopt \
APPEND_HISTORY \
EXTENDED_HISTORY \
INC_APPEND_HISTORY \
HIST_FIND_NO_DUPS \
HIST_IGNORE_SPACE \
HIST_NO_STORE \
HIST_IGNORE_DUPS \
HIST_REDUCE_BLANKS
HISTSIZE=1000000
SAVEHIST=1000000
HISTFILE="$HOME/.zhistory"
} #}}}
function configure_completion #{{{
{
2012-11-29 15:18:57 -08:00
print_info -l 2 'Initializing completion system'
autoload -U compinit
compinit
# Cache completions
zstyle ':completion::complete:*' use-cache 1
zstyle ':completion::complete:*' cache-path ~/.zsh/cache
# For rm, cp, and mv don't complete if file is on the line already
zstyle ':completion:*:rm:*' ignore-line yes
zstyle ':completion:*:cp:*' ignore-line yes
zstyle ':completion:*:mv:*' ignore-line yes
# Remove trailing slashes in directory arguments
zstyle ':completion:*' squeeze-slashes true
# Never select parent directory
zstyle ':completion:*:cd:*' ignore-parents parent pwd
# Expand partial paths
zstyle ':completion:*' expand 'yes'
# Show a pretty menu of killable processes
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
zstyle ':completion:*:*:kill:*' menu yes select
} #}}}
2011-05-03 21:53:50 -07:00
2012-11-28 09:44:56 -08:00
configure_general
configure_omz
configure_zle
configure_modules_and_functions
configure_zsh_aliases
configure_history
configure_completion
configure_prompt
2012-11-29 13:28:42 -08:00
if [ -e $HOME/.zshrc.$SYS ]; then
2012-11-29 15:18:57 -08:00
print_info -l 3 "Sourcing ${SYS}-specific Z Shell settings"
source $HOME/.zshrc.$SYS
fi
if [ -e $HOME/.zshrc.local ]; then
2012-11-29 15:18:57 -08:00
print_info -l 3 "Sourcing local Z Shell settings"
source $HOME/.zshrc.local
fi