Tux

...making Linux just a little more fun!

[2-cent Tip] typing command in bash shell with comfort

Mulyadi Santosa [mulyadi.santosa at gmail.com]


Sat, 7 Aug 2010 16:00:38 +0700

OK, sounds a bit confusing. Let's just say you are a kind of man (or woman, of course) who thinks that typing something like: sudo find / -xdev -type f -perm /06000 -mmin -60 | xargs ls -lt -c will be so much comfortable if it is done inside an editor...let's say...uhm...vim.

How to do that? simply press Ctrl-X, followed by Ctrl-E. And depending of the content of your EDITOR environment variable, bash will fire up that editor. Start typing, edit as neccessary, and save. And kazaaammm, that command is executed right away.

PS: Tribute to commandlinefu.com and http://www.catonmat.net/blog for this neat piece of trick!

-- regards,

Mulyadi Santosa Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com training: mulyaditraining.blogspot.com


Top    Back


Thomas Adam [thomas at xteddy.org]


Sat, 7 Aug 2010 10:18:14 +0100

On Sat, Aug 07, 2010 at 04:00:38PM +0700, Mulyadi Santosa wrote:

> OK, sounds a bit confusing. Let's just say you are a kind of man (or
> woman, of course) who thinks that typing something like:
> sudo find / -xdev -type f -perm /06000 -mmin -60 | xargs ls -lt -c
> will be so much comfortable if it is done inside an editor...let's
> say...uhm...vim.
> 
> How to do that? simply press Ctrl-X, followed by Ctrl-E. And depending
> of the content of your EDITOR environment variable, bash will fire up

This is completely dependant on having:

set -o emacs

... which is the default, but completely fails if it's set to:

set -o vi

Which any sane person (ahem) would do, anyway. :) In which case, that binding is then:

alt-v

To achieve the same effect.

And for extra points (and for people using a sane shell. :P), Zsh users just need to see:

edit-command-line

with:

bindkey -M vicmd v edit-command-line

Very Ksh-like, this tip.

Thanks for it, it dragged up a lot of this from my mind. :)

-- Thomas Adam

-- 
"Deep in my heart I wish I was wrong.  But deep in my heart I know I am
not." -- Morrissey ("Girl Least Likely To" -- off of Viva Hate.)


Top    Back


Mulyadi Santosa [mulyadi.santosa at gmail.com]


Sun, 8 Aug 2010 06:18:56 +0700

On Sat, Aug 7, 2010 at 16:18, Thomas Adam <thomas at xteddy.org> wrote:

> ... which is the default, but completely fails if it's set to:
>
> ``
> set -o vi
> ''

Hail down to Thomas :) Thanks for pointing that out :)

> Thanks for it, it dragged up a lot of this from my mind. ?:)
>

You welcome :)

-- regards,

Mulyadi Santosa Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com training: mulyaditraining.blogspot.com


Top    Back


Henry Grebler [henrygrebler at optusnet.com.au]


Thu, 19 Aug 2010 18:57:46 +1000

-->OK, sounds a bit confusing. Let's just say you are a kind of man (or -->woman, of course) who thinks that typing something like: -->sudo find / -xdev -type f -perm /06000 -mmin -60 | xargs ls -lt -c -->will be so much comfortable if it is done inside an editor...let's -->say...uhm...vim. --> -->How to do that? simply press Ctrl-X, followed by Ctrl-E. And depending -->of the content of your EDITOR environment variable, bash will fire up -->that editor. Start typing, edit as neccessary, and save. And -->kazaaammm, that command is executed right away.

And I thought I knew everything worth knowing in bash! I'm gobsmacked!

Wonderful tip!


Top    Back


Mulyadi Santosa [mulyadi.santosa at gmail.com]


Thu, 19 Aug 2010 18:25:18 +0700

On Thu, Aug 19, 2010 at 15:57, Henry Grebler <henrygrebler at optusnet.com.au> wrote:

> And I thought I knew everything worth knowing in bash! I'm gobsmacked!
>
> Wonderful tip!
>

Thanks! :) It smacked me right in the face when first time I learnt about it...after...uhm...12 years of Linux experience :D

-- regards,

Mulyadi Santosa Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com training: mulyaditraining.blogspot.com


Top    Back