LucasLarson/dotfiles

`${SHELL##*/}` depends on user configuration; `${0##*[-/]}` does not

LucasLarson opened this issue · 0 comments

The scripts below appear shell-agnostic, but if running them using Bash on a system whose ${SHELL} is Zsh, they don’t work at all.

For example, instead of:

. "${HOME}/.${SHELL##*/}rc" && exec "${SHELL##*/}" --login

we should use:

. "${HOME}/.${0##*[-/]}rc" && exec "${0##*[-/]}" --login

alias aliases='${EDITOR:-vi} ${ZSH:-${HOME}/.oh-my-${SHELL##*/}}/custom/aliases.${SHELL##*/}; . ${HOME}/.${SHELL##*/}rc && exec ${SHELL##*/} --login'
alias ohmyzsh='cd ${ZSH:-${HOME}/.oh-my-${SHELL##*/}}'
alias zshconfig='${EDITOR:-vi} ${HOME}/.${SHELL##*/}rc; . ${HOME}/.${SHELL##*/}rc && exec ${SHELL##*/} --login'
alias zshenv='${EDITOR:-vi} ${HOME}/.${SHELL##*/}env; . ${HOME}/.${SHELL##*/}rc && exec ${SHELL##*/} --login'
alias zshrc='${SHELL##*/}config'