Or you could stick the command in a shell script.<p><pre><code> #!/bin/sh
find . -iname '*.php' -print0 | xargs -0 -n1 php -l
</code></pre>
Save it to ~/bin/phplint (you do have ~/bin in your PATH, right?), chmod +x it, check it in, and you have a new phplint command. No need to mess about with hashtags in your shell history.<p>Am I missing something?
The phplint example isn't a great one. If you use phplint enough you should either:<p>1) Create a generic shell script as others have stated.<p>2) Create a Makefile for your projects with a 'lint' target. If you create many different PHP projects, consider a project template directory with a Makefile that already has this, so that every new project automatically has the functionality:<p><pre><code> make lint
</code></pre>
This idea has been around though. I can't recall if I've seen tagging used before, but saving an unexecuted commandline in the shell history by commenting it out is another useful hack that's been around a while.
For stuff like the example where you know you will be reusing the command, it's better to use an alias or script. Even if it's just a command you plan to run in a couple times in a row you can add a temporay alias with: alias foo = "!!" - that way you don't have to hit ctrl+r each time.<p>Still, it's a good tip in terms of adding comments to unusual/confusing commands so when you go through your history you're not like "wtf was I doing here?" or if you unexpectedly need to recall it.
This response explains how I use Acme to store (and later modify) commands in files in each directory.<p><a href="https://news.ycombinator.com/item?id=5566567" rel="nofollow">https://news.ycombinator.com/item?id=5566567</a><p>In addition, I wrote a generic tag-indexing tool (in Plan 9's rc and Inferno's sh) to find random bits of information (including commands) without caring where they live in my file hierarchy.<p><a href="https://github.com/catenate/notabene" rel="nofollow">https://github.com/catenate/notabene</a><p><a href="http://swtools.wordpress.com/2010/03/05/nb%E2%80%94search-and-index-notes-in-files-by-keyword/" rel="nofollow">http://swtools.wordpress.com/2010/03/05/nb%E2%80%94search-an...</a>
This is neat! I appreciate using something like hashtags in an unexpected, but useful way. And as for the comments saying the example should just be put in a shell script, that's not really relevant at all. The article has nothing to do with the merits of simple shell scripts versus a fun and useful hack.