Tuesday, November 30, 2010

Suprising Unix Feature: Bash Macros

Even on my Windows boxes, I spend a good part of my day at a bash prompt. And I do so, most of the time, taking it totally for granted. It's this awesome user interface which is so good it's essentially invisible. So invisible in fact, that even after years and years I learn new tricks it can pull off.

Today's trick: emacs style macros:

bash has support for recording and executing macros. You can start recording a macro with the keybinding C-x ( and stop it with C-x ). You can then execute the recorded macro with C-x e

And sure enough, on both my Windows and Linux environments, the above tip works perfectly.

You can even use the same repeat mechanism that emacs offers. Type: ESC <some number> C-x e and the macro will be repeated some number times.

I'm not exactly sure what I'm going to use this behavior for yet - but I know I like it.

1 comment:

  1. LOL i just found out about this too, but have no idea why i would need this feature.

    ReplyDelete