mirror of
https://github.com/Matir/skel.git
synced 2026-05-25 21:19:09 -07:00
Cleanup zshrc
This commit is contained in:
@@ -87,11 +87,27 @@ bindkey '^r' history-incremental-search-backward
|
|||||||
# delete really deletes
|
# delete really deletes
|
||||||
bindkey "^[[3~" delete-char
|
bindkey "^[[3~" delete-char
|
||||||
|
|
||||||
|
source_if_existing() {
|
||||||
|
if test -e "${1}" ; then source "${1}" ; else false ; fi
|
||||||
|
}
|
||||||
|
|
||||||
|
source_first_existing() {
|
||||||
|
while (($#)); do
|
||||||
|
if test -e "${1}" ; then
|
||||||
|
source "${1}"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
# Source extras and aliases if interactive
|
# Source extras and aliases if interactive
|
||||||
if [[ $- == *i* ]] ; then
|
if [[ $- == *i* ]] ; then
|
||||||
if [[ -e $HOME/.aliases ]] ; then source $HOME/.aliases ; fi
|
source_if_existing $HOME/.aliases
|
||||||
if [[ -e $HOME/.aliases.local ]] ; then source $HOME/.aliases.local ; fi
|
source_if_existing $HOME/.aliases.local
|
||||||
# zsh-only-ism to avoid error if glob doesn't expand
|
# zsh-only-ism to avoid error if glob doesn't expand
|
||||||
|
# specifically sets NULLGLOB for this one glob
|
||||||
for file in $HOME/.zshrc.d/[a-zA-Z0-9]*.zsh(N) ; do
|
for file in $HOME/.zshrc.d/[a-zA-Z0-9]*.zsh(N) ; do
|
||||||
source "$file"
|
source "$file"
|
||||||
done
|
done
|
||||||
@@ -108,41 +124,30 @@ if [[ $- == *i* ]] ; then
|
|||||||
autoload -Uz compinit && compinit -i
|
autoload -Uz compinit && compinit -i
|
||||||
autoload -Uz promptinit && promptinit
|
autoload -Uz promptinit && promptinit
|
||||||
# Virtualenvwrapper
|
# Virtualenvwrapper
|
||||||
if test -f /usr/share/virtualenvwrapper/virtualenvwrapper_lazy.sh ; then
|
source_first_existing \
|
||||||
source /usr/share/virtualenvwrapper/virtualenvwrapper_lazy.sh
|
/usr/share/virtualenvwrapper/virtualenvwrapper_lazy.sh \
|
||||||
elif test -f /usr/bin/virtualenvwrapper_lazy.sh ; then
|
/usr/bin/virtualenvwrapper_lazy.sh \
|
||||||
source /usr/bin/virtualenvwrapper_lazy.sh
|
/opt/homebrew/bin/virtualenvwrapper_lazy.sh
|
||||||
elif test -f /opt/homebrew/bin/virtualenvwrapper_lazy.sh ; then
|
|
||||||
source /opt/homebrew/bin/virtualenvwrapper_lazy.sh
|
|
||||||
fi
|
|
||||||
if command ls --version >/dev/null 2>&1 ; then
|
if command ls --version >/dev/null 2>&1 ; then
|
||||||
alias ls="$(whence -p ls) --color=auto"
|
alias ls="$(whence -p ls) --color=auto"
|
||||||
fi
|
fi
|
||||||
# Syntax highlighting and substring search
|
# Syntax highlighting and substring search
|
||||||
if test -f /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ; then
|
source_first_existing \
|
||||||
source /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
|
/usr/share/{,zsh/plugins/}zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
|
||||||
elif test -f /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ; then
|
if source_if_existing ${HOME}/.zshrc.d/_zsh-history-substring-search.zsh ; then
|
||||||
source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
|
|
||||||
fi
|
|
||||||
if test -f ${HOME}/.zshrc.d/_zsh-history-substring-search.zsh ; then
|
|
||||||
source ${HOME}/.zshrc.d/_zsh-history-substring-search.zsh
|
|
||||||
bindkey '^[[A' history-substring-search-up
|
bindkey '^[[A' history-substring-search-up
|
||||||
bindkey '^[[B' history-substring-search-down
|
bindkey '^[[B' history-substring-search-down
|
||||||
bindkey -M vicmd 'k' history-substring-search-up
|
bindkey -M vicmd 'k' history-substring-search-up
|
||||||
bindkey -M vicmd 'j' history-substring-search-down
|
bindkey -M vicmd 'j' history-substring-search-down
|
||||||
fi
|
fi
|
||||||
# Suggestions
|
# Suggestions
|
||||||
for sugg_path in /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh /usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh ; do
|
if source_first_existing \
|
||||||
if test -f "${sugg_path}"; then
|
/usr/share/{,zsh/plugins/}zsh-autosuggestions/zsh-autosuggestions.zsh ; then
|
||||||
# Works well for solarized
|
# Works well for solarized
|
||||||
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=10"
|
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=10"
|
||||||
# Strategy -- note that 'completion' is slow AF
|
# Strategy -- note that 'completion' is slow AF
|
||||||
ZSH_AUTOSUGGEST_STRATEGY=(history)
|
ZSH_AUTOSUGGEST_STRATEGY=(history)
|
||||||
source "${sugg_path}"
|
|
||||||
break
|
|
||||||
fi
|
fi
|
||||||
done
|
|
||||||
unset sugg_path
|
|
||||||
# History
|
# History
|
||||||
alias fullhist="history 1"
|
alias fullhist="history 1"
|
||||||
alias longhist="history -1000"
|
alias longhist="history -1000"
|
||||||
@@ -157,12 +162,7 @@ if [ -x /usr/bin/ack-grep ] ; then
|
|||||||
alias ack='/usr/bin/ack-grep'
|
alias ack='/usr/bin/ack-grep'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Got rust?
|
# Pip packages and other local resources
|
||||||
if test -d ${HOME}/.cargo/bin ; then
|
|
||||||
PATH=${PATH}:${HOME}/.cargo/bin
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Pip packages
|
|
||||||
if test -d ${HOME}/.local/bin ; then
|
if test -d ${HOME}/.local/bin ; then
|
||||||
PATH=${PATH}:${HOME}/.local/bin
|
PATH=${PATH}:${HOME}/.local/bin
|
||||||
fi
|
fi
|
||||||
@@ -172,7 +172,7 @@ if test -z "${PAGER}" && command -v less >/dev/null 2>&1; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Load any local settings
|
# Load any local settings
|
||||||
if [ -e $HOME/.zshrc.local ] ; then source $HOME/.zshrc.local ; fi
|
source_if_existing $HOME/.zshrc.local
|
||||||
|
|
||||||
# separate interactive block based on .zshrc.local
|
# separate interactive block based on .zshrc.local
|
||||||
if [[ $- == *i* ]] ; then
|
if [[ $- == *i* ]] ; then
|
||||||
|
|||||||
Reference in New Issue
Block a user