Make various init stages into functions in zshrc
This commit is contained in:
parent
e63cdb9aa7
commit
6184eba778
1 changed files with 127 additions and 96 deletions
223
zshrc
223
zshrc
|
@ -1,137 +1,159 @@
|
||||||
# .zshrc
|
# .zshrc
|
||||||
# vim: ft=zsh
|
# vim: ft=zsh fdm=marker
|
||||||
#
|
#
|
||||||
# ZSH init for interactive shells
|
# ZSH init for interactive shells
|
||||||
#
|
#
|
||||||
# Eryn Wells <eryn@erynwells.me>
|
# Eryn Wells <eryn@erynwells.me>
|
||||||
|
|
||||||
PROMPT_THEME='loquacious'
|
PROMPT_THEME='loquacious'
|
||||||
|
ZLE_MODE='vim'
|
||||||
|
|
||||||
|
|
||||||
# load bash/zsh/ksh agnostic configurations
|
# load bash/zsh/ksh agnostic configurations
|
||||||
[ -e $HOME/.rc ] && source $HOME/.rc
|
[ -e $HOME/.rc ] && source $HOME/.rc
|
||||||
|
|
||||||
|
|
||||||
# Report seconds since shell was invoked in milliseconds
|
|
||||||
typeset -F SECONDS
|
|
||||||
|
|
||||||
print_info_noisy 1 "Initializing interactive Z Shell"
|
print_info_noisy 1 "Initializing interactive Z Shell"
|
||||||
|
|
||||||
# Function path
|
|
||||||
function {
|
|
||||||
local myfpath="$HOME/.zsh/func"
|
|
||||||
fpath=($myfpath/makers $myfpath $fpath)
|
|
||||||
}
|
|
||||||
|
|
||||||
print_info_sub_noisy 2 "Loading vcs_info module"
|
function configure_general #{{{
|
||||||
autoload -Uz vcs_info
|
{
|
||||||
zstyle ':vcs_info:*' enable git
|
print_info_sub_noisy 2 'Configuring general ZSH settings'
|
||||||
|
|
||||||
|
# Report seconds since shell was invoked in milliseconds
|
||||||
|
typeset -F SECONDS
|
||||||
|
|
||||||
|
print_info_sub_noisy 2 'Setting shell options'
|
||||||
|
# See zshoptions(1)
|
||||||
|
setopt EXTENDED_GLOB \
|
||||||
|
MULTIOS \
|
||||||
|
AUTO_REMOVE_SLASH \
|
||||||
|
COMPLETE_IN_WORD
|
||||||
|
} #}}}
|
||||||
|
|
||||||
|
|
||||||
print_info_sub_noisy 2 "Configuring prompt: $PROMPT_THEME"
|
function configure_zle #{{{
|
||||||
autoload -U promptinit
|
{
|
||||||
promptinit
|
print_info_sub_noisy 2 'Configuring ZLE'
|
||||||
prompt $PROMPT_THEME
|
|
||||||
|
|
||||||
|
print_info_sub_noisy 5 "Using $ZLE_MODE command line editing mode"
|
||||||
print_info_sub_noisy 2 'Setting shell options'
|
[[ -z "$ZLE_MODE" ]] && ZLE_MODE='vim'
|
||||||
setopt \
|
if [[ $ZLE_MODE == 'vim' ]]; then
|
||||||
EXTENDED_GLOB \
|
|
||||||
MULTIOS
|
|
||||||
|
|
||||||
|
|
||||||
print_info_sub_noisy 3 'Creating aliases'
|
|
||||||
alias pd='pushd'
|
|
||||||
alias pod='popd'
|
|
||||||
|
|
||||||
#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'
|
|
||||||
|
|
||||||
# History settings
|
|
||||||
print_info_sub_noisy 4 '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"
|
|
||||||
|
|
||||||
# command line editing mode
|
|
||||||
function {
|
|
||||||
local mode='vim'
|
|
||||||
print_info_sub_noisy 5 "Using $mode command line editing mode"
|
|
||||||
if [[ $mode == 'vim' ]]; then
|
|
||||||
bindkey -v
|
bindkey -v
|
||||||
elif [[ $mode == 'emacs' ]]; then
|
elif [[ $ZLE_MODE == 'emacs' ]]; then
|
||||||
bindkey -e
|
bindkey -e
|
||||||
fi
|
fi
|
||||||
}
|
|
||||||
|
# Allow deleting over the start of insert mode
|
||||||
|
zle -A .backward-delete-char vi-backward-delete-char
|
||||||
|
|
||||||
|
# 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 #{{{
|
||||||
# Completion
|
{
|
||||||
###
|
print_info_noisy 2 'Loading modules'
|
||||||
|
|
||||||
print_info_sub_noisy 2 'Initializing completion system'
|
local myfpath="$HOME/.zsh/func"
|
||||||
|
print_info_sub_noisy 2 "Adding $myfpath to \$fpath"
|
||||||
|
fpath=($myfpath/makers $myfpath $fpath)
|
||||||
|
|
||||||
# load completion system
|
print_info_sub_noisy 3 'Loading vcs_info'
|
||||||
autoload -U compinit
|
autoload -Uz vcs_info
|
||||||
compinit
|
zstyle ':vcs_info:*' enable git
|
||||||
|
|
||||||
# Completion options
|
load_module 'makers'
|
||||||
setopt \
|
|
||||||
AUTO_REMOVE_SLASH \
|
|
||||||
COMPLETE_IN_WORD
|
|
||||||
|
|
||||||
# Cache completions
|
print_info_sub_noisy 3 "Loading pw module"
|
||||||
zstyle ':completion::complete:*' use-cache 1
|
autoload pw
|
||||||
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
|
function configure_prompt #{{{
|
||||||
zstyle ':completion:*' squeeze-slashes true
|
{
|
||||||
|
print_info_sub_noisy 2 "Configuring prompt: $PROMPT_THEME"
|
||||||
|
autoload -U promptinit
|
||||||
|
promptinit
|
||||||
|
prompt $PROMPT_THEME
|
||||||
|
} #}}}
|
||||||
|
|
||||||
# Never select parent directory
|
|
||||||
zstyle ':completion:*:cd:*' ignore-parents parent pwd
|
|
||||||
|
|
||||||
# Expand partial paths
|
function configure_zsh_aliases #{{{
|
||||||
zstyle ':completion:*' expand 'yes'
|
{
|
||||||
|
print_info_sub_noisy 3 'Creating ZSH-specific aliases'
|
||||||
|
alias pd='pushd'
|
||||||
|
alias pod='popd'
|
||||||
|
|
||||||
|
#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 #{{{
|
||||||
|
{
|
||||||
|
print_info_sub_noisy 4 '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 #{{{
|
||||||
|
{
|
||||||
|
print_info_sub_noisy 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
|
||||||
|
} #}}}
|
||||||
|
|
||||||
# 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
|
|
||||||
|
|
||||||
###
|
###
|
||||||
# FUNCTIONS
|
# FUNCTIONS
|
||||||
###
|
###
|
||||||
|
|
||||||
# Generate a password
|
# Generate a password
|
||||||
print_info_sub_noisy 3 "Loading pw module"
|
|
||||||
autoload pw
|
|
||||||
|
|
||||||
# Maker module -- various functions for makin' stuff
|
|
||||||
print_info_sub_noisy 3 "Loading makers module"
|
|
||||||
for func in `ls $HOME/.zsh/func/makers`; do
|
|
||||||
autoload $func
|
|
||||||
done
|
|
||||||
|
|
||||||
# Go up $1 directories, where $1 is an integer (saves me from having to type ../
|
# Go up $1 directories, where $1 is an integer (saves me from having to type ../
|
||||||
# ad nauseum)
|
# ad nauseum)
|
||||||
|
@ -148,6 +170,15 @@ function up {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
configure_general
|
||||||
|
configure_zle
|
||||||
|
configure_fpath
|
||||||
|
configure_modules_and_functions
|
||||||
|
configure_zsh_aliases
|
||||||
|
configure_history
|
||||||
|
configure_completion
|
||||||
|
configure_prompt
|
||||||
|
|
||||||
if [ -e $HOME/.zshrc.$SYS ]; then
|
if [ -e $HOME/.zshrc.$SYS ]; then
|
||||||
print_info_noisy 3 "Sourcing ${SYS}-specific Z Shell settings"
|
print_info_noisy 3 "Sourcing ${SYS}-specific Z Shell settings"
|
||||||
source $HOME/.zshrc.$SYS
|
source $HOME/.zshrc.$SYS
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue