Skip to content

Instantly share code, notes, and snippets.

@armw4
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save armw4/8876291 to your computer and use it in GitHub Desktop.
Save armw4/8876291 to your computer and use it in GitHub Desktop.
A handy bash/zsh/shell trick shot I picked up a few weeks back.

by Antwan Wimberly

I'm a huge fan and heavy user of Vim (I do all my ruby and open source development there...anything that' not Microsoft basically). I happen to use what I like to refer to as a "Vim bootstrap" in Steve Francia's awesome spf13.

It has sane defaults and comes equipped with the latest and greatest Vim plugins on the market.

After installing the bootstrap, you'll want to ensure you keep it update to date just like Homebrew formulas, ruby gems, and npm packages. It's prett easy to upgrade your bootstrap, but who really has enough RAM in their brain to store that curl command? Sure you could drop it into a script, make it executable via chmod, and put it into some folder that's attached to your $PATH variable, but I've yet to cross that bridge. I do know however that I've executed that command numerous times and that it should be stashed somewhere in my zsh history. I know it contains the string "curl", so I whipped out a little grep kung fu (clearly hyperbole):

history | grep curl

514  curl https://j.mp/spf13-vim3 -L -o - | sh
1142  curl https://j.mp/spf13-vim3 -L -o - | sh
1208  curl https://j.mp/spf13-vim3 -L -o - | sh
1243  curl https://j.mp/spf13-vim3 -L -o | sh
1244  curl https://j.mp/spf13-vim3 -L -o - | sh
1246  curl https://j.mp/spf13-vim3 -L -o - | sh
1253  curl https://j.mp/spf13-vim3 -L -o - | sh
1255  curl https://j.mp/spf13-vim3 -L -o - | sh
1555  curl https://j.mp/spf13-vim3 -L -o - | sh
1762  curl https://j.mp/spf13-vim3 -L -o - | sh
2002  curl https://j.mp/spf13-vim3 -L -o - | sh
2281  curl https://j.mp/spf13-vim3/ -L -o - | sh
2491  curl https://j.mp/spf13-vim3 -L -o - | sh
2722  curl https://j.mp/spf13-vim3 -L -o - | sh

This outputs all entries in your history file containing curl, accompanied by their sequence number. Wanna replay one of those bad boys? All it takes is a bang(!) and the sequeunce number. Upon pressing Tab or Enter, your shell will expand the expression into the underlying command:

➜  neat git:(master) !2722                                                 
➜  neat git:(master) curl https://j.mp/spf13-vim3 -L -o - | sh

And of course the aesthetic result of me executing the command (the error is a lie):

.vimrc.before |  3 +++
 2 files changed, 40 insertions(+), 26 deletions(-)
[✔] Successfully updated spf13-vim
[✔] Setting up vim symlinks
trying to update vundle
From https://github.com/gmarik/vundle
 * branch            master     -> FETCH_HEAD
Already up-to-date.
[✔] Successfully updated vundle
[✔] Successfully cloned vundle
Vim: Warning: Input is not from a terminal
Vim: Error reading input, exiting...

Vim: Finished.
[✔] Now updating/installing plugins using Vundle

And voila!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment