brock
9/16/2014 - 1:48 AM

Alias checker

Alias checker

#!/bin/zsh

# add this line to your .zshrc or zsh profile
preexec() { zsh $(which aliascheck) $1}
#!/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