find . -iname '*.php' -print0 | xargs -0 -n1 php -l
Am I missing something?
Create a file ~/bin/phplint
Type out the shebang
Copy the command from the terminal into the file
Save the file
chmod +x the file
I observe that people vary a lot in how hard they lean on their history. I live and die by mine; it serves as a combination of replacement short-term memory and treasury of tricks. Some of my colleagues don't really use it at all, using scripts or aliases, or even just retyping commands every time, like savages. If you're not a heavy user of history, then this idea won't help you. If you are, it might.
Create a new shell script called `empty` somewhere on your PATH:
chmod +x "$1"
history -p "$1" | empty ~/bin/"$2" bash
save-history '!!' phplint
Having said that, if you're happy (I'm speaking generically here, not specifically to twic) relying on your history, then more power to you. It doesn't work for me because I haven't worked out yet how to keep my shell history straight between several shell sessions on the same PC, let alone syncing it between different PCs.
So, tagging a command line with "#save:scriptname" will save the command to ~/scripts/saved/scriptname.sh That way you can get the history search token and a script on disk in one fell swoop.
It's just a keystroke away (`C-x C-e` in bash and zsh, in emacs-like line editing mode) if you have $EDITOR set properly.
Personally, I would use the hashtags, and also use something like inotify to automatically add any hashtagged commands to seperate scripts and store them in something like ~/usr/bin/custom/
Caching a name for a command, as you issue it, makes it easier to retrieve later if you decide you want it as a proper script or alias. Among other things.
1) Create a generic shell script as others have stated.
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:
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.
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.