Hide

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again.

Delete that bloated snippets file you've been using and share your personal repository with the world. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.


If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/

Get involved!

You can sign-in using OpenID credentials, or register a traditional username and password.

First-time OpenID users will be automatically assigned a username which can be changed after signing in.

Hide

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for:

Hide

News

2011-03-12 - Confoo 2011 presentation
Slides are available from the commandlinefu presentation at Confoo 2011: http://presentations.codeinthehole.com/confoo2011/
2011-01-04 - Moderation now required for new commands
To try and put and end to the spamming, new commands require moderation before they will appear on the site.
2010-12-27 - Apologies for not banning the trolls sooner
Have been away from the interwebs over Christmas. Will be more vigilant henceforth.
2010-09-24 - OAuth and pagination problems fixed
Apologies for the delay in getting Twitter's OAuth supported. Annoying pagination gremlin also fixed.
Hide

Tags

Hide

Functions

Rapidly invoke an editor to write a long, complex, or tricky command

Terminal - Rapidly invoke an editor to write a long, complex, or tricky command
ctrl-x e
2009-03-11 09:26:05
User: fool
404
Rapidly invoke an editor to write a long, complex, or tricky command

Next time you are using your shell, try typing ctrl-x e (that is holding control key press x and then e). The shell will take what you've written on the command line thus far and paste it into the editor specified by $EDITOR. Then you can edit at leisure using all the powerful macros and commands of vi, emacs, nano, or whatever.

Alternatives

There are 6 alternatives - vote for the best!

Terminal - Alternatives
fc
bash-hotkey: <CTRL+x+e>
2009-08-25 09:08:54
User: alvinx
Functions: bash
17

* in bash-shell You can capture the current commandline to a text-editor:

* simply press: CTRL+x+e

* Your current commandline will pe put into Your default text-editor (export EDITOR=vim)

<ESC> v or ctrl-x ctrl-e
2011-04-30 11:08:02
User: pkufranky
Tags: readline
14

Next time you are using your shell, try typing

ctrl-x ctrl-e # in emacs mode

or

<ESC> v # in vi mode

The shell will take what you've written on the command line thus far and paste it into the editor specified by $EDITOR. Then you can edit at leisure using all the powerful macros and commands of vi, emacs, nano, or whatever.

<ESC> v
2011-03-04 19:13:29
User: ormris
11

Allows you to edit your command using your chosen editor. Works in bash with "set -o vi".

Know a better way?

If you can do better, submit your command here.

What others think

use 9term/plan9, pressing escape puts the term in hold mode and nothing is sent until youpress escape again to release it.

Comment by maht 290 weeks ago

Nice. You have my vote on this one. This really is gonna be useful. I would write it 'ctrl-x ctrl-e' tho. First reflex to me was to hit 'ctrl-x' release it and then press 'e' (i'm used to screen like shortcuts)

Comment by skinp 290 weeks ago

Also forgot to say, this is REALLY going to be useful when entering a long command, test it and then want to make a script out of it. no need to 'echo !! > script'. Just command history up, ctrl-x ctrl-e, and save :D

Comment by skinp 290 weeks ago

or just type fc and hit the enter key

Comment by linuxrawkstar 289 weeks and 5 days ago

Didn't work for me. This is presumably as I use vi mode.

Comment by krayon 289 weeks and 5 days ago

In vi mode, it's esc (for command mode) and then v.

Comment by jstrater 288 weeks and 2 days ago

You have to configure the VISUAL enviromnet variable prior to use C-x, C-e

export VISUAL=vi
Comment by vutcovici 286 weeks and 6 days ago

It's C-x C-e.

Comment by kylexlau 280 weeks and 6 days ago

Doesn't work in zsh.

Comment by eolo999 273 weeks and 3 days ago

note: When you save this with its given filename (just :wq), it is executed and then discarded by the shell. If you want to keep it, save it explicitly to a new file first (:w )

Comment by cj_ 253 weeks and 3 days ago

Oops, that should read :w <newfile>

Comment by cj_ 253 weeks and 3 days ago

To enable this on zsh, add

autoload edit-command-line

zle -N edit-command-line

bindkey '^Xe' edit-command-line

to your .zshrc

Comment by Erus 237 weeks and 5 days ago

I agree with linuxrawkstar. fc is simpler, and it's much more flexible.

Comment by chrispix 235 weeks and 1 day ago

Thanks Erus.

Comment by dserodio 155 weeks and 5 days ago

Your point of view

You must be signed in to comment.

Related sites and podcasts