Compare commits

..

3 Commits

Author SHA1 Message Date
f19bf41c63 Improve & rename plugin sourcing function
Rename `plugin-load` to `source-plugin` and add a check for the plugin
directory, a message is displayed if it does not exist.
2018-04-21 17:21:00 +01:00
9e77e83d7f Only add aliases when the target command exists
Previously aliases for commands were added without checking if the
command being aliased existed first, this is now not the case.
2018-04-21 17:18:43 +01:00
5a1ef73524 Fix ccache compiler aliases being first in PATH
Add ccache symlink directory to start of PATH, this must be after
`typeset -U PATH` because on macOS this reorders the list so ccache's
symlinks will no longer be at the start of PATH rendering it unusable.
2018-04-21 16:59:35 +01:00
2 changed files with 31 additions and 12 deletions

3
zshenv
View File

@ -21,9 +21,6 @@ PATH=$HOME/.local/bin:$PATH
MANPATH=$HOME/.local/share/man:$MANPATH MANPATH=$HOME/.local/share/man:$MANPATH
INFOPATH=$HOME/.local/share/info:$INFOPATH INFOPATH=$HOME/.local/share/info:$INFOPATH
# Add ccache to the PATH if present
[ -f /usr/bin/ccache ] && PATH=/usr/lib/ccache:$PATH
# Use ~/.local for pip installs on macOS # Use ~/.local for pip installs on macOS
[ "`uname`" = "Darwin" ] && export PYTHONUSERBASE=$HOME/.local [ "`uname`" = "Darwin" ] && export PYTHONUSERBASE=$HOME/.local

40
zshrc
View File

@ -2,10 +2,14 @@
# executing commands, will be sourced when starting as an interactive shell. # executing commands, will be sourced when starting as an interactive shell.
# Load plugin scripts # Load plugin scripts
plugin-load() { source ~/.config/zsh/$1/$1.plugin.zsh } source-plugin() {
plugin-load zsh-autosuggestions [ -d ~/.config/zsh/$1 ] && \
plugin-load zsh-history-substring-search source ~/.config/zsh/$1/$1.plugin.zsh || \
plugin-load zsh-syntax-highlighting echo "zsh plugin not found: $1"
}
source-plugin zsh-autosuggestions
source-plugin zsh-history-substring-search
source-plugin zsh-syntax-highlighting
# Disable non end-of-line autosuggest accept widgets # Disable non end-of-line autosuggest accept widgets
ZSH_AUTOSUGGEST_ACCEPT_WIDGETS=(end-of-line vi-end-of-line) ZSH_AUTOSUGGEST_ACCEPT_WIDGETS=(end-of-line vi-end-of-line)
@ -117,22 +121,40 @@ typeset -U PATH
typeset -U MANPATH typeset -U MANPATH
typeset -U INFOPATH typeset -U INFOPATH
# Add ccache symlink directory to start of PATH, this must be after
# `typeset -U PATH` because on macOS this reorders the list so ccache's
# symlinks will no longer be at the start of PATH rendering it unusable.
if [ `uname` = Darwin ]; then
[ -f /usr/local/bin/ccache ] && \
PATH=/usr/local/opt/ccache/libexec:$PATH
else
[ -f /usr/bin/ccache ] && \
PATH=/usr/lib/ccache:$PATH
fi
# Aliases # Aliases
alias grep='grep --color=always' alias grep='grep --color=always'
alias cninja='cmake -GNinja -DCMAKE_EXPORT_COMPILE_COMMNADS=ON' which cmake &> /dev/null && \
alias ssh='TERM=xterm-256color ssh' alias cninja='cmake -GNinja -DCMAKE_EXPORT_COMPILE_COMMNADS=ON'
which ssh &> /dev/null && \
alias ssh='TERM=xterm-256color ssh'
case `uname` in case `uname` in
Linux) Linux)
[ "$TMUX" = "" ] && \ [ "$TMUX" = "" ] && \
alias cls="printf '\ec'" || alias cls="clear && printf '\e[3J'" alias cls="printf '\ec'" || \
alias cls="clear && printf '\e[3J'"
alias ls='ls -F --color=auto' alias ls='ls -F --color=auto'
alias debug='cgdb --args' which cgdb &> /dev/null && \
alias debug='cgdb --args' || \
which gdb &> /dev/null && \
alias debug='gdb --args'
;; ;;
Darwin) Darwin)
alias cls="clear && printf '\e[3J'" alias cls="clear && printf '\e[3J'"
alias ls='ls -GFh' alias ls='ls -GFh'
alias debug='lldb --' which lldb &> /dev/null && \
alias debug='lldb --'
;; ;;
esac esac