Hashtags for commands

Wednesday 3 July 2013

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.

Comments

[gravatar]
Charles Merriam 2:38 AM on 7 Jul 2013

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?

[gravatar]
Ned Batchelder 11:24 AM on 7 Jul 2013

@Charles: I haven't considered alternatives. Do you mean other shells?

[gravatar]
Anonymous 1:51 PM on 12 Jul 2013

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:

name
email
Ignore this:
not displayed and no spam.
Leave this empty:
www
not searched.
 
Name and either email or www are required.
Don't put anything here:
Leave this empty:
URLs auto-link and some tags are allowed: <a><b><i><p><br><pre>.