Hint output for a Makefile
The problem:
You remember the opcodes of old processors, you remember register names that have long since vanished from every textbook — but you do not remember the name of the Makefile target you were editing by hand yesterday. Memory is selective, and there was no room in it for target names. Common sense is powerless here, and no certificate will help: you will have to look under the layers yourself.
The solution:
Add the following command to the ~/.bashrc file :
complete -W "\`grep -oE '^[a-zA-Z0-9_.-]+:([^=]|$)' ?akefile | sed 's/[^a-zA-Z0-9_.-]*$//'\`" make
or using fzf (if it is not installed : sudo apt install fzf)
Grep, sed, completion — three little cogs that work while somewhere an "intelligent shell" is sold by subscription. A bit more complex, but more honest: you pick the target with your finger, not your memory.
complete -W "\`grep -oE '^[a-zA-Z0-9_.-]+[\\:]*[a-zA-Z0-9_.-]+:([^=]|$)' ?akefile | sort | uniq | sed 's/[^a-zA-Z0-9_.-]*$//' | sed 's/[\]//g' | fzf\`" make
The machine suggests, you choose. The tool changes — the habit remains.