Skip to content

Instantly share code, notes, and snippets.

@jwhitley
Created November 30, 2011 23:11
Show Gist options
  • Save jwhitley/1411729 to your computer and use it in GitHub Desktop.
Save jwhitley/1411729 to your computer and use it in GitHub Desktop.
# alias a command only if the alias name isn't a command
weak_alias () {
if [[ -z "`whence ${1[(ws:=:)1]}`" ]]; then
alias $1
fi
}
# alias a command only if the alias target exists
alias_if_exist () {
if [[ -n "`whence ${1[(ws:=:)2]}`" ]]; then
alias $1
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment