6 ms·
Here are some of my other favorites: ^foo^bar replaces the foo in the last command with bar example: less setup.conf, ^less^vim alt+. recalls the last argume
by cmurphycode 16y ago
Here are some of my other favorites:
^foo^bar replaces the foo in the last command with bar
example: less setup.conf, ^less^vim
alt+. recalls the last argument of the last command (in emacs mode, anyway)
example: less setup.conf, vim alt+.
As mentioned, Ctrl+R is great for history searching. Repeatedly pressing Ctrl+R goes to the next result, and you can use the arrow keys to edit.
cd - goes to the last directory. It handles most of the use cases for pushd and popd.
- koeselitz 16y agoAs far as these little shorthands go, you've left out the one I use most all day long; the ever-handy !:-, which means 'the last command minus the final argument': $ cat ~/my_huge_dataset.csv | tr '\|' ',' >> testing.csv $ !:- for_real_this_time.csv >> cat ~/my_huge_dataset.csv | tr '\|' ',' >> for_real_this_time.csv $ This is really, really handy for me - particularly in two situations: first, when (like above) I'm testing a command by outputting to a random off-server file first; and second (the more often) when I'm running the exact same process on a dozen different files, just pasting the filenames onto the command line. It's really handy to be able to use !:- all the way down for every one. Oh, and theres's also this: !! - which means 'the last command exactly.' That can be handy, too: $ rm /usr/lib/libutil.so >> m: cannot remove `libutil.so': Permission denied $ sudo !! $
- cmurphycode 16y agoI like the !:-, even though it's super ugly. It's the perfect complement to alt+. !! is a classic, but the article mentions it.