[zsh] Update all init-rc functions
This commit is contained in:
parent
1145ef23e1
commit
be4d690e32
16 changed files with 148 additions and 161 deletions
|
@ -3,7 +3,7 @@
|
|||
|
||||
autoload binary_exists
|
||||
|
||||
function init_rc_aliases
|
||||
function init-rc-aliases
|
||||
{
|
||||
alias j='jobs'
|
||||
alias h='history'
|
||||
|
@ -34,4 +34,4 @@ function init_rc_aliases
|
|||
alias -s jar='java -jar'
|
||||
}
|
||||
|
||||
init_rc_aliases "$@"
|
||||
init-rc-aliases "$@"
|
13
zsh/func/init-rc-app-environments
Normal file
13
zsh/func/init-rc-app-environments
Normal file
|
@ -0,0 +1,13 @@
|
|||
#!/usr/bin/env zsh
|
||||
# Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
autoload binary_exists
|
||||
|
||||
function init-rc-app-environments
|
||||
{
|
||||
# Default ledger file
|
||||
local -r ledger_file="$HOME/Documents/Ledger/personal.ledger"
|
||||
[[ -f "$ledger_file" ]] && export LEDGER_FILE="$ledger_file"
|
||||
}
|
||||
|
||||
init-rc-app-environments "$@"
|
46
zsh/func/init-rc-completion
Normal file
46
zsh/func/init-rc-completion
Normal file
|
@ -0,0 +1,46 @@
|
|||
#!/usr/bin/env zsh
|
||||
# Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
function init-rc-completion
|
||||
{
|
||||
autoload -Uz compinit
|
||||
compinit
|
||||
|
||||
# Cache completions
|
||||
zstyle ':completion::complete:*' use-cache 1
|
||||
zstyle ':completion::complete:*' cache-path ~/.zsh/cache
|
||||
|
||||
# Make ls show completion list in color.
|
||||
# See also: https://github.com/ohmyzsh/ohmyzsh/issues/6060
|
||||
if [[ -n "$LS_COLORS" ]]; then
|
||||
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
|
||||
else
|
||||
zstyle ':completion:*:default' list-colors \
|
||||
'di=34' 'ln=35' 'so=32' 'pi=33' 'ex=31' 'bd=34;46' 'cd=34;43' 'su=30;41' \
|
||||
'sg=30;46' 'tw=30;42' 'ow=30;43'
|
||||
fi
|
||||
|
||||
# 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
|
||||
|
||||
# Complete man pages by section
|
||||
zstyle ':completion:*:manuals' separate-sections true
|
||||
zstyle ':completion:*:manuals.*' insert-sections true
|
||||
}
|
||||
|
||||
init-rc-completion "$@"
|
|
@ -1,11 +1,11 @@
|
|||
#!/usr/bin/env zsh
|
||||
# Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
function init_rc_linux
|
||||
function init-rc-linux
|
||||
{
|
||||
alias iptls='sudo iptables --line-numbers -nv -L'
|
||||
alias ip6tls='sudo ip6tables --line-numbers -nv -L'
|
||||
alias rlx="xrdb $HOME/.Xdefaults"
|
||||
}
|
||||
|
||||
init_rc_linux "$@"
|
||||
init-rc-linux "$@"
|
27
zsh/func/init-rc-ls
Normal file
27
zsh/func/init-rc-ls
Normal file
|
@ -0,0 +1,27 @@
|
|||
#!/usr/bin/env zsh
|
||||
# Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
function init-rc-ls
|
||||
{
|
||||
local ls_options='--color=auto'
|
||||
alias ls="ls $ls_options"
|
||||
alias la="ls -A $ls_options"
|
||||
alias ll="ls -l $ls_options"
|
||||
alias l.="ls -d $ls_options .*"
|
||||
|
||||
local dircolors_bin=$(whence -p dircolors || whence -p gdircolors)
|
||||
if [[ -n "$dircolors_bin" ]]; then
|
||||
local dircolors_config
|
||||
if [[ -f "$HOME/.dircolors/$SYS.cfg" ]]; then
|
||||
dircolors_file="$HOME/.dircolors/$SYS.cfg"
|
||||
else
|
||||
dircolors_file="$HOME/.dircolors/default.cfg"
|
||||
fi
|
||||
|
||||
if [[ -f "$dircolors_config" ]]; then
|
||||
eval $($dircolors_bin $dircolors_config)
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
init-rc-ls "$@"
|
29
zsh/func/init-rc-prompt
Normal file
29
zsh/func/init-rc-prompt
Normal file
|
@ -0,0 +1,29 @@
|
|||
#!/usr/bin/env zsh
|
||||
# Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
function init-rc-prompt
|
||||
{
|
||||
local theme=loquacious
|
||||
|
||||
autoload -U add-zsh-hook
|
||||
autoload -Uz vcs_info
|
||||
|
||||
zstyle ':vcs_info:*' disable p4 bzr cdv darcs mtn svk tla cvs svn
|
||||
zstyle ':vcs_info:*' enable git
|
||||
zstyle ':vcs_info:git:general:*' formats '%b'
|
||||
zstyle ':vcs_info:git-svn:general:*' formats '%b'
|
||||
|
||||
# Export the current Git branch before every prompt.
|
||||
function _export-gitbranch {
|
||||
vcs_info general
|
||||
export gitbranch=${vcs_info_msg_0_}
|
||||
}
|
||||
|
||||
add-zsh-hook precmd _export-gitbranch
|
||||
|
||||
autoload -U promptinit
|
||||
promptinit
|
||||
prompt $theme
|
||||
}
|
||||
|
||||
init-rc-prompt "$@"
|
17
zsh/func/init-rc-zle
Normal file
17
zsh/func/init-rc-zle
Normal file
|
@ -0,0 +1,17 @@
|
|||
#!/usr/bin/env zsh
|
||||
# Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
function init-rc-zle
|
||||
{
|
||||
case "${ERYN_ZLE_MODE:-emacs}" in
|
||||
vim)
|
||||
bindkey -v
|
||||
zle -A .backward-delete-char vi-backward-delete-char
|
||||
;;
|
||||
emacs)
|
||||
bindkey -e
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
init-rc-zle "$@"
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env zsh
|
||||
# Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
function init_zsh_history
|
||||
function init-rc-zsh-history
|
||||
{
|
||||
setopt \
|
||||
APPEND_HISTORY \
|
||||
|
@ -18,4 +18,4 @@ function init_zsh_history
|
|||
HISTFILE="$HOME/.zhistory"
|
||||
}
|
||||
|
||||
init_zsh_history "$@"
|
||||
init-rc-zsh-history "$@"
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env zsh
|
||||
# Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
function init_zsh_options
|
||||
function init-rc-zsh-options
|
||||
{
|
||||
# Report seconds since shell was invoked in milliseconds
|
||||
typeset -F SECONDS
|
||||
|
@ -13,4 +13,4 @@ function init_zsh_options
|
|||
COMPLETE_IN_WORD
|
||||
}
|
||||
|
||||
init_zsh_options "$@"
|
||||
init-rc-zsh-options "$@"
|
|
@ -1,17 +0,0 @@
|
|||
#!/usr/bin/env zsh
|
||||
# Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
autoload binary_exists
|
||||
|
||||
function init_app_environments
|
||||
{
|
||||
# NetHack options
|
||||
# use color in the terminal
|
||||
binary_exists nethack && export NETHACKOPTIONS="color"
|
||||
|
||||
# Default ledger file
|
||||
local ledgerFile="$HOME/Documents/Ledger/personal.ledger"
|
||||
[[ -e "$ledgerFile" ]] && LEDGER_FILE="$ledgerFile"
|
||||
}
|
||||
|
||||
init_app_environments "$@"
|
|
@ -1,30 +0,0 @@
|
|||
#!/usr/bin/env zsh
|
||||
# Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
local system_ls=`which ls`
|
||||
local has_gnu_ls
|
||||
local ls_options
|
||||
|
||||
if $system_ls --version 2>&1 | grep GNU 1>/dev/null; then
|
||||
has_gnu_ls=1
|
||||
ls_options='--color=auto'
|
||||
else
|
||||
has_gnu_ls=0
|
||||
ls_options='-G'
|
||||
fi
|
||||
|
||||
alias ls="$system_ls $ls_options"
|
||||
alias la="$system_ls -A $ls_options"
|
||||
alias ll="$system_ls -l $ls_options"
|
||||
alias l.="$system_ls -d $ls_options .*"
|
||||
|
||||
local dircolors_bin=`whence -p dircolors || whence -p gdircolors`
|
||||
if [[ $has_gnu_ls -eq 1 && -n "$dircolors_bin" ]]; then
|
||||
if [[ -e "$HOME/.dircolors/$SYS.cfg" ]]; then
|
||||
dircolors="$HOME/.dircolors/$SYS.cfg"
|
||||
else
|
||||
dircolors="$HOME/.dircolors/default.cfg"
|
||||
fi
|
||||
|
||||
eval `$dircolors_bin $dircolors`
|
||||
fi
|
|
@ -1,41 +0,0 @@
|
|||
#!/usr/bin/env zsh
|
||||
# Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
autoload -Uz compinit
|
||||
compinit
|
||||
|
||||
# Cache completions
|
||||
zstyle ':completion::complete:*' use-cache 1
|
||||
zstyle ':completion::complete:*' cache-path ~/.zsh/cache
|
||||
|
||||
# Make ls show completion list in color.
|
||||
# See also: https://github.com/ohmyzsh/ohmyzsh/issues/6060
|
||||
if [[ -n "$LS_COLORS" ]]; then
|
||||
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
|
||||
else
|
||||
zstyle ':completion:*:default' list-colors \
|
||||
'di=34' 'ln=35' 'so=32' 'pi=33' 'ex=31' 'bd=34;46' 'cd=34;43' 'su=30;41' \
|
||||
'sg=30;46' 'tw=30;42' 'ow=30;43'
|
||||
fi
|
||||
|
||||
# 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
|
||||
|
||||
# Complete man pages by section
|
||||
zstyle ':completion:*:manuals' separate-sections true
|
||||
zstyle ':completion:*:manuals.*' insert-sections true
|
|
@ -1,24 +0,0 @@
|
|||
#!/usr/bin/env zsh
|
||||
# Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
local theme=loquacious
|
||||
|
||||
autoload -U add-zsh-hook
|
||||
autoload -Uz vcs_info
|
||||
|
||||
zstyle ':vcs_info:*' disable p4 bzr cdv darcs mtn svk tla cvs svn
|
||||
zstyle ':vcs_info:*' enable git
|
||||
zstyle ':vcs_info:git:general:*' formats '%b'
|
||||
zstyle ':vcs_info:git-svn:general:*' formats '%b'
|
||||
|
||||
# Export the current Git branch before every prompt.
|
||||
function export_gitbranch {
|
||||
vcs_info general
|
||||
export gitbranch=${vcs_info_msg_0_}
|
||||
}
|
||||
|
||||
add-zsh-hook precmd export_gitbranch
|
||||
|
||||
autoload -U promptinit
|
||||
promptinit
|
||||
prompt $theme
|
|
@ -1,20 +0,0 @@
|
|||
#!/usr/bin/env zsh
|
||||
# Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
local mode=emacs
|
||||
|
||||
if [[ -z "$mode" ]]; then
|
||||
mode=emacs
|
||||
fi
|
||||
|
||||
function configure_zle_emacs { }
|
||||
function configure_zle_vim { }
|
||||
|
||||
if [[ $mode == 'vim' ]]; then
|
||||
bindkey -v
|
||||
configure_zle_vim
|
||||
zle -A .backward-delete-char vi-backward-delete-char
|
||||
elif [[ $mode == 'emacs' ]]; then
|
||||
bindkey -e
|
||||
configure_zle_emacs
|
||||
fi
|
|
@ -1,12 +0,0 @@
|
|||
#!/usr/bin/env zsh
|
||||
# Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
for x in "$HOME/Code" "$HOME/Documents/Code"; do
|
||||
if [[ ! -d "$x" ]]; then
|
||||
continue
|
||||
fi
|
||||
export c="$x"
|
||||
break
|
||||
done
|
||||
|
||||
export dd="$HOME/Library/Developer/Xcode/DerivedData"
|
17
zshrc
17
zshrc
|
@ -2,15 +2,14 @@
|
|||
|
||||
zsh_init_rc_functions=( \
|
||||
init_rc_fpath_darwin \
|
||||
init_rc_aliases \
|
||||
init_configure_ls \
|
||||
init_rc_tilde_paths \
|
||||
init_rc_configure_prompt \
|
||||
init_rc_configure_zle \
|
||||
init_rc_configure_completion \
|
||||
init_zsh_options \
|
||||
init_zsh_history \
|
||||
init_app_environments \
|
||||
init-rc-aliases \
|
||||
init-rc-ls \
|
||||
init-rc-prompt \
|
||||
init-rc-zle \
|
||||
init-rc-completion \
|
||||
init-rc-zsh-options \
|
||||
init-rc-zsh-history \
|
||||
init-rc-app-environments \
|
||||
init-rc-$SYS \
|
||||
)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue