Skip to content

Instantly share code, notes, and snippets.

@rfletcher
Created August 14, 2009 18:17
Show Gist options
  • Save rfletcher/167994 to your computer and use it in GitHub Desktop.
Save rfletcher/167994 to your computer and use it in GitHub Desktop.
##
# append a command to the bash history without executing it
#
# scenario: you've typed out a long command and realized you need to do
# something else before running it. ^a and prefix with "savecommand".
#
# usage:
# $ savecommand echo foo
# (do something else)
# $ !echo
function savecommand() {
history -d $(history 1 | awk '{print $1}')
history -a
echo "$@" >> "$HISTFILE"
history -r
}
alias sc='savecommand'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment