maggit

  • Archive
  • RSS
  • Ask me anything

Fix Command

onethingwell:

fc is a shell builtin command that lets you do some cool stuff with your shell history.

Run it without any arguments, and you can edit the previous shell command in your text editor of choice1. To run your freshly-edited command, just save and quit.

fc -l returns a numbered list of recent commands (just like history).

fc followed by one of those numbers will open that command in your editor.

If you follow fc with a string, it’ll open up the last command starting with that string—eg. fc mpl will open the last mplayer command.

That’s just the basics—you can do all sorts of crazy command editing gymnastics with fc, but the details vary from shell to shell. For details, see: bash, ksh and zsh.

Thanks, @gummo!

See also:

  • Correcting Command Line Mistakes
  • sudo !!

  1. As in $EDITOR. If you’d rather use something else, you can set $FCEDIT in your shell profile. If neither one is set, fc defaults to ed, which doesn’t stand for ‘extremely difficult’, but probably should. ↩

Source: onethingwell

  • 1 year ago > onethingwell
  • 22
  • Permalink
  • Share
    Tweet

22 Notes/ Hide

  1. gioielli liked this
  2. maggit reblogged this from onethingwell
  3. tipsformyfutureself reblogged this from onethingwell
  4. hint liked this
  5. svnlto liked this
  6. cafetouba liked this
  7. onethingwell posted this
← Previous • Next →

About

  • RSS
  • Random
  • Archive
  • Ask me anything
  • Mobile

Effector Theme by Carlo Franco.

Powered by Tumblr