In your /Users/user/.profile
add the following:
export HISTCONTROL=erasedups:ignorespace alias cpc=" history | cut -c 8- | tail -n 2 | head -n 1 | qs"
The first line prevents duplicate commands in the bash history, and also keeps any commands starting with a space from showing up in history.
The second line sets an alias of “cpc” which will get the second to last command (cpc being the “last” command), and sends it to quicksilver.
Now, launch a new terminal window and type a command, like “ll -l”, and then type “cpc” and quicksilver should pop up with “ll -l” in the first pane.
I find this most useful when I’ve just executed a long or complicated command and want to easily grab it, either to save it or modify it.
One Response to bash: send last command to quicksilver