Skip to content

Instantly share code, notes, and snippets.

@brock
Last active March 19, 2020 04:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save brock/feb6280c435cb7d75909 to your computer and use it in GitHub Desktop.
Save brock/feb6280c435cb7d75909 to your computer and use it in GitHub Desktop.
Alias checker
#!/bin/zsh
# aliascheck by @brock
# Description: checks each zsh command and reminds you if you already have an alias for that command
# Instructions:
# copy aliascheck.sh to ~/bin/aliascheck
# chmod +x ~/bin/aliascheck
# uncomment or modify line 14 below to source your aliases
# add the following to your ~/.zshrc or zsh profile:
#
# preexec() { zsh $(which aliascheck) $1}
#
# source your aliases, works best if aliases are separate from your zshrc or profile
# source ~/.zsh_aliases
# you may need to tell zsh to expand aliases, though I didn't need it
# setopt aliases
# zsh preexec passes the entire string in the command as $1 (see the zshrc snippet in the next file)
# echo 'this is dollar one: ' $1
FOUND_ALIAS=`alias | grep "='${1}'"`
if [ ! -z $FOUND_ALIAS ]; then
echo "#########################"
echo "# Alias Check found: $FOUND_ALIAS"
echo "#########################"
fi
#!/bin/zsh
# add this line to your .zshrc or zsh profile
preexec() { zsh $(which aliascheck) $1}
@brock
Copy link
Author

brock commented Sep 16, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment