1

I just had an idea, I'm sure it must exist though I could not find anything on the web. This topic gets close to my idea but not enough: How to quickly store and access often used commands?

I'd like to have a .bookmark.zsh file in which I store commands, not often used (I could create an alias for these), but more those which were a pain in the ass to write down, and that I could use some other times.

Like I just typed:

rake db:drop --trace && echo 'dropped' && \
  rake db:create --trace && echo 'created' && \
  rake db:migrate --trace && echo 'migrated' && \
  rake db:seed --trace && echo 'seed'

And I want to save it, so I type bm -save 'description' and it adds

rake db:drop --trace && echo 'dropped' && \
  rake db:create --trace && echo 'created' && \
  rake db:migrate --trace && echo 'migrated' && \
  rake db:seed --trace && echo 'seed' # description`

in my .bookmark.zsh file.

And then I can do bm -find 'description' (or ideally 'descr' 'desc' etc.) and I find the command back.

Like bookmarks work!

I'm pretty bad at shell so any tip would be super nicely welcomed!

  • 1
    I just posted a zsh version of the 'bashtags' solution found in your link. If that's suitable, it's essentially just typing $_description (with the caveat that spaces are not permitted -- use _ instead) at the end of the command. Then you can just Ctrl+R and type $_description to get it back. This exploits the fact that undefined variables expand to nothing. – kampu May 27 '13 at 11:25

0 Answers0