I didn't see Ctrl-r, but I've found that to be the most insanely useful shortcut. Ctrl-r = reverse history search. Type a partial command after Ctrl-r and it'll find the most recent executed command with that substring in it. Press Ctrl-r again, jump to the next oldest command containing your substring. Did you accidentally press too many Ctrl-r? Press backspace to move forward in history.
A complementary tip for Ctr+R is to tag long reusable commands with a comment in the end, e.g., find . -name "*.png" -print0 | xargs -0 -P8 pngquant --ext .png --force 256 #optimizepng (if you’re using zsh, you have to enable INTERACTIVE_COMMENTS option first; just run set -k)
Level Up Your Shell Game
31–40 of 50 posts
Re: Level Up Your Shell Game
#32I didn't see Ctrl-r, but I've found that to be the most insanely useful shortcut. Ctrl-r = reverse history search. Type a partial command after Ctrl-r and it'll find the most recent executed command with that substring in it. Press Ctrl-r again, jump to the next oldest command containing your substring. Did you accidentally press too many Ctrl-r? Press backspace to move forward in history.
Since I've switched to zshell, I've found that I haven't used Ctrl-r much at all. The intelligent history feature does it for me. For example: If earlier I had a long command like `mvn clean test && mvn deploy -P release`, I can just type `mvn v` and press up on the arrows. zsh will present only history entries that start with what I've typed. Insanely useful!
## arrow up
"\e[A":history-search-backward
## arrow down
"\e[B":history-search-forward
(in .inputrc)
Re: Level Up Your Shell Game
#33Re: Level Up Your Shell Game
#34They should really mention which shell and terminal emulator they are using. Not everyone is using the same "Unix command line".
Fair point. FWIW, we're all on OS X, running bash, zsh, or fish on either Terminal.app or iTerm2.
Re: Level Up Your Shell Game
#35Ctrl-t will flip two words. Not very useful but pretty cool.
Re: Level Up Your Shell Game
#36ctrl + z
then, to send it to the background:
bg
and, to get it back from the background:
fg
Also, I really like to use "for", like:
// get the size of each file or directory in the current directory
for i in `ls -1`; do du -hs $i; done;
Re: Level Up Your Shell Game
#37to clear the screen, instead of typing "clear" is pretty useful too.
Re: Level Up Your Shell Game
#38Here is a rule for how to level up your shell/editing game. If you ever touch your arrow keys, you are doing something wrong. > ctrl + left arrow Moves the cursor to the left by one word > ctrl + right arrow Moves the cursor to the right by one word Alt + b and Alt + f are also aliases for the same action.
Re: Level Up Your Shell Game
#39Earlier quoted context omitted.
Since I've switched to zshell, I've found that I haven't used Ctrl-r much at all. The intelligent history feature does it for me. For example: If earlier I had a long command like `mvn clean test && mvn deploy -P release`, I can just type `mvn v` and press up on the arrows. zsh will present only history entries that start with what I've typed. Insanely useful!
The same thing can be done in bash: ## arrow up "\e[A":history-search-backward ## arrow down "\e[B":history-search-forward (in .inputrc)
Re: Level Up Your Shell Game
#40Earlier quoted context omitted.
Fair point. FWIW, we're all on OS X, running bash, zsh, or fish on either Terminal.app or iTerm2.
Control-Left and Right switch workspaces for me. A giant pain in the ass, because the normal word-jump shortcut, Option-Left/Right, just drops a [C/[D into the shell on iTerm. The stupid thing is, if I shell into an Ubuntu machine, it works fine.
Alternatively, you could change your workspace bindings to Control+[some other modifier].