Hacker News new | past | comments | ask | show | jobs | submit login

Making functions takes substantially more effort (and has some advantages).



Easiest way I know of:

Ctrl+R to start reverse search

Type enough to locate last command

Ctrl+X, Ctrl+E to launch command in $EDITOR

Wrap in fn() {} or alias

Save as, or append to some file, e.g. in Vim `:w >> ~/.aliases`


.. promptly forget that you did this, or where you put the file containing the custom shell function, etc.

Ctrl-R serves a mnemonic purpose as well.. it helps you document your workflow and processes at the shell, and not hidden in some file somewhere.


Yeah if you can't locate code you wrote in your own home directory, I dunno what to tell you mate. I'm not here to tell you not to continue your love affair with reverse history search. Do what works for you. All I did was share the easiest way I know to persist a history item as a fn or alias.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: