Last Updated: September 27, 2021
· brunogama

Use comments for tagging successful commands on the command line

To make my life easier using the history substring search on my zsh environment I've set the option:

setopt interactivecomments  # enable "#" in the shell

After that on every command that i'll use for a while I'll set the comments on the end of the line like this:

for prompt_name in `prompt -l | tail -1`; do prompt -p "${prompt_name}"; done; #prompt-preview

when i need to call the same command i will type the comment (without the hash) and the history substring search will do the rest. It is possible add multiple comments by separating them just use a semicolon at the end of each comment like this:

echo 'Spam'; #eggs; #ham