News for hackers. Stuff that matters.
Re:Using hashtags to organize your bash history by mooism2 on Sunday June 30, 2013 @02:20PM (#5966626)
You're right, the first alternative is disgustingly long-winded. Let's automate it.

Create a new shell script called `empty` somewhere on your PATH:

  #!/bin/bash
  set -e
  exec >"$1"
  printf '#!'
  which "$2"
  chmod +x "$1"
  cat
Next, add a new shell function to your ~/.bashrc:

  save-history() {
    history -p "$1" | empty ~/bin/"$2" bash
  }
To save the most recent command in your history to a shell script called ~/bin/phplint, run

  save-history '!!' phplint
You have to single-quote the '!!'; sorry about that. I'm using bash; maybe zsh has some way of making this easier to use.

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.

Re:Using hashtags to organize your bash history by jpk on Sunday June 30, 2013 @05:13PM (#5967242)
In the spirit of the OP, I did a similar thing, but using a tag to initiate writing the script file. https://github.com/thatjpk/bashtag-save

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.