Sometimes airing your code smells can be cathartic, and motivate you to fix it.
Here's possibly the most embarrassing shell pipeline I currently have in my Bash dotfiles:
\grep -Rn "alias ${1}=" ${DOTFILES}/source \
| awk -F: '{print "⍺:\t" $3 "\t--> " $1 ":" $2}' \
| sed "s/${1}=//g"
Yes, I'm combining all the filters, grep
,awk
, and sed
to print out an information of where a shell alias is defined in my files. It's part of my describe
function for handling aliases:
$ describe gdfs
⍺: alias 'cpulimit -l 2 -p $(pgrep -f "crash_handler_token=")&' --> /Users/mjl/.dotfiles/source/40_osx.sh:28
I'm sure all of this can actually be done in awk
alone (especially the sed
part), but I haven't figured a way to make it so.
Noob here. In your first block, what are those backslashes
\
doing at the end of the lines?