I wrote a wrapper around which that would display the file and line number where a function was defined. Is there a way I can do the same for alias? Also, any comments or critiques on the code?
function where() { cmd="$ 1" info=$ (command -V "$ cmd" | head -n 1) #rc="$ PIPESTATUS[0]" case $ info in *function*) extdebug=$ (shopt | grep -q extdebug) ! ((extdebug)) && shopt -s extdebug declare -F "$ cmd" ! ((extdebug)) && shopt -u extdebug ;; *) echo "$ info" ;; esac }
Output looks like:
$ where ls ; where l ; where bad ; where where ls is /bin/ls l is aliased to `ls -Al --color=auto' bash: command: bad: not found where 6 /home/harleypig/projects/dotfiles/.bash_sources.d/tools