Neat Bash Trick: Open Last Command for Editing in the Default Editor and then Execute on Saving/Exiting

This is pretty slick: enter "fc" in the shell and your last command opens up for editing in your default editor (as given by "$EDITOR"). Works perfectly with vi. The"$EDITOR" variable approach does not seem to work with BBEdit though, and you have to:
$ fc -e '/usr/bin/bbedit --wait'
With vi, ":cq" aborts execution of the command.

One thought on “Neat Bash Trick: Open Last Command for Editing in the Default Editor and then Execute on Saving/Exiting

  1. Set your $EDITOR to point at a shell script containing:


    if [ -f "`which bbedit`" ]; then
    bbedit --wait --resume "$@"
    else
    echo "ERROR: Can't find bbedit. Did you install the command line tools?"
    fi

Leave a Reply

Your email address will not be published. Required fields are marked *