Hashtags for commands

Wednesday 3 July 2013This is more than ten years old. Be careful.

I was working on creating a command today to run Pylint on only the files I had changed:

pylint $(git diff --name-only $(git merge-base HEAD origin/master))

This works pretty well, but I’m not sure it’s ready yet. I want to come back to it, and fiddle with it some. Eventually it might go into a bash alias, but for now, I just want to get it back from history.

Rather than remember some detail from the command, I had an idea to make the command findable again. I could give it a hashtag!

pylint $(git diff --name-only $(git merge-base HEAD origin/master)) #lintdiff

The hash is conveniently a comment character for bash, so I can use any hashtag I like, and later come back to it with ^Rlintdiff.

I’m not sure this is really that useful, since I can make a bash alias right off the bat, but this will let me tweak the command until I like it.

Update: Of course, the right name for this idea is “bashtag”!


Hi Ned. This just shows you that your history mechanism isn't so useful. The basic BASH history tends to get cluttered with duplicates, simple changing and managing files, and the like. Have you considered alternatives?
@Charles: I haven't considered alternatives. Do you mean other shells?
Sir, your idea is really good.

I even modified HISTCONTROL parser to make it keep the lines ending in #[a-Z]*

btw, you removed a previous comment from me calling you a genius :P

Add a comment:

Ignore this:
Leave this empty:
Name is required. Either email or web are required. Email won't be displayed and I won't spam you. Your web site won't be indexed by search engines.
Don't put anything here:
Leave this empty:
Comment text is Markdown.