[zsh] Do a bunch of profiling and clean up all my init functions -- shell init is so much faster now!
This commit is contained in:
parent
7e126fe703
commit
1c2e9025cf
11 changed files with 135 additions and 185 deletions
|
@ -1,8 +1,7 @@
|
||||||
#!/usr/bin/env zsh
|
#!/usr/bin/env zsh
|
||||||
# Eryn Wells <eryn@erynwells.me>
|
# Eryn Wells <eryn@erynwells.me>
|
||||||
|
|
||||||
function g
|
function g {
|
||||||
{
|
|
||||||
if [[ $# -gt 0 ]]; then
|
if [[ $# -gt 0 ]]; then
|
||||||
git $@
|
git $@
|
||||||
else
|
else
|
||||||
|
@ -11,4 +10,7 @@ function g
|
||||||
return $?
|
return $?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Use git completion for the g function
|
||||||
|
compdef g='git'
|
||||||
|
|
||||||
g "$@"
|
g "$@"
|
||||||
|
|
|
@ -1,19 +1,13 @@
|
||||||
#!/usr/bin/env zsh
|
#!/usr/bin/env zsh
|
||||||
# vim:ft=zsh:
|
|
||||||
# Eryn Wells <eryn@erynwells.me>
|
# Eryn Wells <eryn@erynwells.me>
|
||||||
|
|
||||||
function init_env
|
export PAGER="less"
|
||||||
{
|
export MANPAGER=$PAGER
|
||||||
export PAGER="less"
|
export EDITOR="vim"
|
||||||
export MANPAGER=$PAGER
|
export VISUAL=$EDITOR
|
||||||
export EDITOR="vim"
|
export LESSHISTFILE="-"
|
||||||
export VISUAL=$EDITOR
|
export GREP_OPTIONS="--color=auto"
|
||||||
export LESSHISTFILE="-"
|
export GREP_COLOR="1;32"
|
||||||
export GREP_OPTIONS="--color=auto"
|
|
||||||
export GREP_COLOR="1;32"
|
|
||||||
|
|
||||||
# Make sure gpg2 knows what to do with the curses-based smartcard PIN prompt.
|
# Make sure gpg2 knows what to do with the curses-based smartcard PIN prompt.
|
||||||
export GPG_TTY=`tty`
|
export GPG_TTY=`tty`
|
||||||
}
|
|
||||||
|
|
||||||
init_env "$@"
|
|
||||||
|
|
|
@ -5,32 +5,27 @@
|
||||||
autoload append_to_path
|
autoload append_to_path
|
||||||
autoload prepend_to_path
|
autoload prepend_to_path
|
||||||
|
|
||||||
function init_env_darwin
|
export OSBUILD=`sysctl -n kern.osversion`
|
||||||
{
|
export OSVERSION=`sysctl -n kern.osproductversion`
|
||||||
export OSBUILD=`sysctl -n kern.osversion`
|
export HWMODEL=`sysctl -n hw.model`
|
||||||
export OSVERSION=`sysctl -n kern.osproductversion`
|
|
||||||
export HWMODEL=`sysctl -n hw.model`
|
|
||||||
|
|
||||||
local pythonRoot
|
local pythonRoot
|
||||||
local python27SitePackages
|
local python27SitePackages
|
||||||
|
|
||||||
pythonRoot="$HOME/Library/Python"
|
pythonRoot="$HOME/Library/Python"
|
||||||
if [[ -d "$pythonRoot" ]]; then
|
if [[ -d "$pythonRoot" ]]; then
|
||||||
for f in `ls "$pythonRoot"`; do
|
for f in `ls "$pythonRoot"`; do
|
||||||
prepend_to_path "$pythonRoot/$f/bin"
|
prepend_to_path "$pythonRoot/$f/bin"
|
||||||
done
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
python27SitePackages="$pythonroot/2.7/lib/python/site-packages"
|
||||||
|
if [[ -d "$python27SitePackages" ]]; then
|
||||||
|
if [[ ! -z $PYTHONPATH ]]; then
|
||||||
|
PYTHONPATH=$python27SitePackages:$PYTHONPATH
|
||||||
|
else
|
||||||
|
PYTHONPATH=$python27SitePackages
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
python27SitePackages="$pythonroot/2.7/lib/python/site-packages"
|
export PYTHONPATH
|
||||||
if [[ -d "$python27SitePackages" ]]; then
|
|
||||||
if [[ ! -z $PYTHONPATH ]]; then
|
|
||||||
PYTHONPATH=$python27SitePackages:$PYTHONPATH
|
|
||||||
else
|
|
||||||
PYTHONPATH=$python27SitePackages
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
export PYTHONPATH
|
|
||||||
}
|
|
||||||
|
|
||||||
init_env_darwin "$@"
|
|
||||||
|
|
|
@ -1,34 +1,28 @@
|
||||||
#!/usr/bin/env zsh
|
#!/usr/bin/env zsh
|
||||||
# vim:ft=zsh:
|
|
||||||
# Eryn Wells <eryn@erynwells.me>
|
# Eryn Wells <eryn@erynwells.me>
|
||||||
|
|
||||||
function init_env_python
|
local pythonRoot
|
||||||
{
|
local python27SitePackages
|
||||||
local pythonRoot
|
|
||||||
local python27SitePackages
|
|
||||||
|
|
||||||
pythonRoot="$HOME/Library/Python"
|
pythonRoot="$HOME/Library/Python"
|
||||||
if [[ -d "$pythonRoot" ]]; then
|
if [[ -d "$pythonRoot" ]]; then
|
||||||
for f in `ls "$pythonRoot"`; do
|
for f in `ls "$pythonRoot"`; do
|
||||||
prepend_to_path "$pythonRoot/$f/bin"
|
prepend_to_path "$pythonRoot/$f/bin"
|
||||||
done
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
python27SitePackages="$pythonroot/2.7/lib/python/site-packages"
|
||||||
|
if [[ -d "$python27SitePackages" ]]; then
|
||||||
|
if [[ ! -z $PYTHONPATH ]]; then
|
||||||
|
PYTHONPATH=$python27SitePackages:$PYTHONPATH
|
||||||
|
else
|
||||||
|
PYTHONPATH=$python27SitePackages
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
python27SitePackages="$pythonroot/2.7/lib/python/site-packages"
|
export PYTHONPATH
|
||||||
if [[ -d "$python27SitePackages" ]]; then
|
|
||||||
if [[ ! -z $PYTHONPATH ]]; then
|
|
||||||
PYTHONPATH=$python27SitePackages:$PYTHONPATH
|
|
||||||
else
|
|
||||||
PYTHONPATH=$python27SitePackages
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
export PYTHONPATH
|
if which virtualenvwrapper.sh 1>/dev/null 2>&1; then
|
||||||
|
export WORKON_HOME="$HOME/src/py/.envs"
|
||||||
if which virtualenvwrapper.sh 1>/dev/null 2>&1; then
|
source `which virtualenvwrapper.sh`
|
||||||
export WORKON_HOME="$HOME/src/py/.envs"
|
fi
|
||||||
source `which virtualenvwrapper.sh`
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
init_env_python "$@"
|
|
||||||
|
|
|
@ -1,41 +1,33 @@
|
||||||
#!/usr/bin/env zsh
|
#!/usr/bin/env zsh
|
||||||
# Eryn Wells <eryn@erynwells.me>
|
# Eryn Wells <eryn@erynwells.me>
|
||||||
|
|
||||||
function init_rc_configure_completion
|
autoload -U compinit
|
||||||
{
|
compinit
|
||||||
autoload -U compinit
|
|
||||||
compinit
|
|
||||||
|
|
||||||
# Cache completions
|
# Cache completions
|
||||||
zstyle ':completion::complete:*' use-cache 1
|
zstyle ':completion::complete:*' use-cache 1
|
||||||
zstyle ':completion::complete:*' cache-path ~/.zsh/cache
|
zstyle ':completion::complete:*' cache-path ~/.zsh/cache
|
||||||
|
|
||||||
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
|
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
|
||||||
|
|
||||||
# For rm, cp, and mv don't complete if file is on the line already
|
# For rm, cp, and mv don't complete if file is on the line already
|
||||||
zstyle ':completion:*:rm:*' ignore-line yes
|
zstyle ':completion:*:rm:*' ignore-line yes
|
||||||
zstyle ':completion:*:cp:*' ignore-line yes
|
zstyle ':completion:*:cp:*' ignore-line yes
|
||||||
zstyle ':completion:*:mv:*' ignore-line yes
|
zstyle ':completion:*:mv:*' ignore-line yes
|
||||||
|
|
||||||
# Remove trailing slashes in directory arguments
|
# Remove trailing slashes in directory arguments
|
||||||
zstyle ':completion:*' squeeze-slashes true
|
zstyle ':completion:*' squeeze-slashes true
|
||||||
|
|
||||||
# Never select parent directory
|
# Never select parent directory
|
||||||
zstyle ':completion:*:cd:*' ignore-parents parent pwd
|
zstyle ':completion:*:cd:*' ignore-parents parent pwd
|
||||||
|
|
||||||
# Expand partial paths
|
# Expand partial paths
|
||||||
zstyle ':completion:*' expand 'yes'
|
zstyle ':completion:*' expand 'yes'
|
||||||
|
|
||||||
# Show a pretty menu of killable processes
|
# Show a pretty menu of killable processes
|
||||||
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
|
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
|
||||||
zstyle ':completion:*:*:kill:*' menu yes select
|
zstyle ':completion:*:*:kill:*' menu yes select
|
||||||
|
|
||||||
# Complete man pages by section
|
# Complete man pages by section
|
||||||
zstyle ':completion:*:manuals' separate-sections true
|
zstyle ':completion:*:manuals' separate-sections true
|
||||||
zstyle ':completion:*:manuals.*' insert-sections true
|
zstyle ':completion:*:manuals.*' insert-sections true
|
||||||
|
|
||||||
# Use git completion for the g function
|
|
||||||
compdef g='git'
|
|
||||||
}
|
|
||||||
|
|
||||||
init_rc_configure_completion "$@"
|
|
||||||
|
|
|
@ -1,34 +1,26 @@
|
||||||
#!/usr/bin/env zsh
|
#!/usr/bin/env zsh
|
||||||
# Eryn Wells <eryn@erynwells.me>
|
# Eryn Wells <eryn@erynwells.me>
|
||||||
|
|
||||||
function init_rc_configure_prompt
|
local theme=$1
|
||||||
{
|
if [[ -z "$1" ]]; then
|
||||||
local theme=$1
|
theme=loquacious
|
||||||
if [[ -z "$1" ]]; then
|
fi
|
||||||
theme=loquacious
|
|
||||||
fi
|
|
||||||
|
|
||||||
autoload -U add-zsh-hook
|
autoload -U add-zsh-hook
|
||||||
autoload -Uz vcs_info
|
autoload -Uz vcs_info
|
||||||
|
|
||||||
zstyle ':vcs_info:*' disable p4 bzr cdv darcs mtn svk tla cvs svn
|
zstyle ':vcs_info:*' disable p4 bzr cdv darcs mtn svk tla cvs svn
|
||||||
zstyle ':vcs_info:*' enable git
|
zstyle ':vcs_info:*' enable git
|
||||||
zstyle ':vcs_info:git:general:*' formats '%b'
|
zstyle ':vcs_info:git:general:*' formats '%b'
|
||||||
|
|
||||||
# Export the current Git branch before every prompt.
|
# Export the current Git branch before every prompt.
|
||||||
function export_gitbranch {
|
function export_gitbranch {
|
||||||
vcs_info general
|
vcs_info general
|
||||||
if [[ "$gitbranches[1]" != "${vcs_info_msg_0_}" ]]; then
|
export gitbranch=${vcs_info_msg_0_}
|
||||||
export gitbranches=(${vcs_info_msg_0_} $gitbranches[1,4])
|
|
||||||
fi
|
|
||||||
export gitbranch=${vcs_info_msg_0_}
|
|
||||||
}
|
|
||||||
|
|
||||||
add-zsh-hook precmd export_gitbranch
|
|
||||||
|
|
||||||
autoload -U promptinit
|
|
||||||
promptinit
|
|
||||||
prompt $theme
|
|
||||||
}
|
}
|
||||||
|
|
||||||
init_rc_configure_prompt "$@"
|
add-zsh-hook precmd export_gitbranch
|
||||||
|
|
||||||
|
autoload -U promptinit
|
||||||
|
promptinit
|
||||||
|
prompt $theme
|
||||||
|
|
|
@ -1,36 +1,37 @@
|
||||||
#!/usr/bin/env zsh
|
#!/usr/bin/env zsh
|
||||||
# Eryn Wells <eryn@erynwells.me>
|
# Eryn Wells <eryn@erynwells.me>
|
||||||
|
|
||||||
autoload binary_exists
|
autoload -Uz binary_exists
|
||||||
|
|
||||||
function init_rc_darwin
|
alias acls='command ls -le'
|
||||||
{
|
|
||||||
alias acls='command ls -le'
|
|
||||||
|
|
||||||
# These things might have been installed by Homebrew, and I like the GNU
|
# These things might have been installed by Homebrew, and I like the GNU
|
||||||
# versions better.
|
# versions better.
|
||||||
binary_exists gdircolors && alias dircolors='gdircolors'
|
binary_exists gdircolors && alias dircolors='gdircolors'
|
||||||
binary_exists gfind && alias find='gfind'
|
binary_exists gfind && alias find='gfind'
|
||||||
binary_exists gnuindent && alias indent='gnuindent'
|
binary_exists gnuindent && alias indent='gnuindent'
|
||||||
|
|
||||||
binary_exists gls && init_rc_configure_ls `which gls`
|
binary_exists gls && init_rc_configure_ls `which gls`
|
||||||
|
|
||||||
# ldd doesn't exist on OS X, but otool -L does the same thing.
|
# ldd doesn't exist on OS X, but otool -L does the same thing.
|
||||||
alias ldd='otool -L'
|
alias ldd='otool -L'
|
||||||
|
|
||||||
local sounds=/System/Library/Sounds
|
local sounds=/System/Library/Sounds
|
||||||
alias glass="afplay $sounds/Glass.aiff"
|
alias glass="afplay $sounds/Glass.aiff"
|
||||||
alias funk="afplay $sounds/Funk.aiff"
|
alias funk="afplay $sounds/Funk.aiff"
|
||||||
|
|
||||||
autoload +X darwin_init_once
|
autoload -Uz darwin_init_once
|
||||||
autoload +X darwin_icloud_drive_path
|
autoload -Uz darwin_icloud_drive_path
|
||||||
autoload +X darwin_configure_screenshots_directory
|
autoload -Uz darwin_configure_screenshots_directory
|
||||||
|
|
||||||
# Open a file/folder in Finder
|
# Open a file or folder in Finder.
|
||||||
alias reveal='open -R'
|
function finder {
|
||||||
|
if [[ -z "$1" ]]; then
|
||||||
|
open -R .
|
||||||
|
fi
|
||||||
|
|
||||||
alias -s app='open'
|
open -R "$1"
|
||||||
alias -s xcodeproj='open -a Xcode'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
init_rc_darwin "$@"
|
alias -s app='open'
|
||||||
|
alias -s xcodeproj='open -a Xcode'
|
||||||
|
|
|
@ -3,19 +3,14 @@
|
||||||
|
|
||||||
autoload load_module
|
autoload load_module
|
||||||
|
|
||||||
function init_zsh_functions
|
local myfpath="$HOME/.zsh/func"
|
||||||
{
|
|
||||||
local myfpath="$HOME/.zsh/func"
|
|
||||||
|
|
||||||
for func in $myfpath/*; do
|
for func in $myfpath/*; do
|
||||||
[[ ! -e "$func" || -d "$func" ]] && continue
|
[[ ! -e "$func" || -d "$func" ]] && continue
|
||||||
|
|
||||||
local functionName=`basename $func`
|
local functionName=`basename $func`
|
||||||
[[ "$functionName" =~ "prompt_*" ]] && continue
|
[[ "$functionName" =~ "prompt_*" ]] && continue
|
||||||
[[ "$functionName" =~ "init_*" ]] && continue
|
[[ "$functionName" =~ "init_*" ]] && continue
|
||||||
|
|
||||||
autoload +X $functionName
|
autoload -Uz $functionName
|
||||||
done
|
done
|
||||||
}
|
|
||||||
|
|
||||||
init_zsh_functions "$@"
|
|
||||||
|
|
|
@ -1,11 +1,6 @@
|
||||||
#!/usr/bin/zsh
|
#!/usr/bin/env zsh
|
||||||
# vim:sw=4:sts=4:
|
|
||||||
#
|
|
||||||
# A wordy prompt theme.
|
|
||||||
#
|
|
||||||
# Eryn Wells <eryn@erynwells.me>
|
# Eryn Wells <eryn@erynwells.me>
|
||||||
|
|
||||||
|
|
||||||
function prompt_loquacious_help
|
function prompt_loquacious_help
|
||||||
{
|
{
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
|
@ -21,7 +16,6 @@ current directory is in a repo.
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function prompt_loquacious_setup
|
function prompt_loquacious_setup
|
||||||
{
|
{
|
||||||
typeset -ga precmd_functions
|
typeset -ga precmd_functions
|
||||||
|
@ -41,10 +35,8 @@ function prompt_loquacious_setup
|
||||||
prompt_opts=(cr subst percent)
|
prompt_opts=(cr subst percent)
|
||||||
|
|
||||||
# Set up vcs_info
|
# Set up vcs_info
|
||||||
zstyle ':vcs_info:git:loquacious_chpwd:*' formats \
|
zstyle ':vcs_info:git:loquacious_chpwd:*' formats '%F{cyan}%r%f'
|
||||||
'%F{cyan}%r%f'
|
zstyle ':vcs_info:git:loquacious_precmd:*' formats '(%F{blue}%b%f)'
|
||||||
zstyle ':vcs_info:git:loquacious_precmd:*' formats \
|
|
||||||
'(%F{blue}%b%f)'
|
|
||||||
|
|
||||||
PS1='${PS1_NAME}${PS1_HOST}${PS1_CWD}${PS1_REPO}${PS1_BRANCH}${PS1_STATUS}${PS1_ZLE_MODE}
|
PS1='${PS1_NAME}${PS1_HOST}${PS1_CWD}${PS1_REPO}${PS1_BRANCH}${PS1_STATUS}${PS1_ZLE_MODE}
|
||||||
$PS1_LINE'
|
$PS1_LINE'
|
||||||
|
@ -52,13 +44,11 @@ $PS1_LINE'
|
||||||
zle -N zle-keymap-select on_keymap_select
|
zle -N zle-keymap-select on_keymap_select
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function prompt_loquacious_preview
|
function prompt_loquacious_preview
|
||||||
{
|
{
|
||||||
# TODO: Implement prompt preview.
|
# TODO: Implement prompt preview.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# HELPER FUNCTIONS
|
# HELPER FUNCTIONS
|
||||||
#
|
#
|
||||||
|
@ -76,7 +66,6 @@ function print_newline
|
||||||
echo
|
echo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function set_repo_name
|
function set_repo_name
|
||||||
{
|
{
|
||||||
vcs_info loquacious_chpwd
|
vcs_info loquacious_chpwd
|
||||||
|
@ -87,7 +76,6 @@ function set_repo_name
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function set_prompt_info
|
function set_prompt_info
|
||||||
{
|
{
|
||||||
PS1_HISTORY="`prompt_colorize -b -f 'green' '%h'`"
|
PS1_HISTORY="`prompt_colorize -b -f 'green' '%h'`"
|
||||||
|
@ -121,7 +109,6 @@ function set_prompt_info
|
||||||
PS1_LINE='%# '
|
PS1_LINE='%# '
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function set_xterm_title
|
function set_xterm_title
|
||||||
{
|
{
|
||||||
local title=''
|
local title=''
|
||||||
|
@ -141,7 +128,6 @@ function set_xterm_title
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function set_zle_mode_info
|
function set_zle_mode_info
|
||||||
{
|
{
|
||||||
if [[ -z "$1" || "$1" == 'viins' || "$1" == 'main' ]]; then
|
if [[ -z "$1" || "$1" == 'viins' || "$1" == 'main' ]]; then
|
||||||
|
@ -153,7 +139,6 @@ function set_zle_mode_info
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function on_keymap_select
|
function on_keymap_select
|
||||||
{
|
{
|
||||||
# Regenerate the prompt with the new mode
|
# Regenerate the prompt with the new mode
|
||||||
|
@ -163,6 +148,5 @@ function on_keymap_select
|
||||||
zle reset-prompt
|
zle reset-prompt
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Finally, run setup to get everything going
|
# Finally, run setup to get everything going
|
||||||
prompt_loquacious_setup "$@"
|
prompt_loquacious_setup "$@"
|
||||||
|
|
3
zshenv
3
zshenv
|
@ -18,7 +18,6 @@ init_path
|
||||||
init_env
|
init_env
|
||||||
init_env_python
|
init_env_python
|
||||||
|
|
||||||
autoload +X init_env_$SYS
|
if autoload +X init_env_$SYS; then
|
||||||
if [[ $? ]]; then
|
|
||||||
init_env_$SYS
|
init_env_$SYS
|
||||||
fi
|
fi
|
||||||
|
|
8
zshrc
8
zshrc
|
@ -17,7 +17,6 @@ init_rc_configure_zle emacs
|
||||||
init_rc_configure_completion
|
init_rc_configure_completion
|
||||||
init_zsh_options
|
init_zsh_options
|
||||||
init_zsh_history
|
init_zsh_history
|
||||||
init_zsh_functions
|
|
||||||
init_app_environments
|
init_app_environments
|
||||||
|
|
||||||
autoload +X init_rc_$SYS
|
autoload +X init_rc_$SYS
|
||||||
|
@ -28,5 +27,8 @@ if ! alias ls 2>&1 1>/dev/null; then
|
||||||
init_configure_ls `which ls`
|
init_configure_ls `which ls`
|
||||||
fi
|
fi
|
||||||
|
|
||||||
autoload g
|
autoload -Uz g
|
||||||
autoload vi
|
autoload -Uz nethack
|
||||||
|
autoload -Uz pw
|
||||||
|
autoload -Uz up
|
||||||
|
autoload -Uz vi
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue