Live data from Hacker News

Level Up Your Shell Game

viget.com

21–30 of 50 posts

Re: Level Up Your Shell Game

#21
post #2

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)

Re: Level Up Your Shell Game

#22

IMO the aliases for git should be in ~/.gitconfig instead. I have a bunch of these, like: [alias] br = branch co = checkout ci = commit -v sci = svn dcommit --interactive cp = cherry-pick l = log --pretty=oneline --abbrev-commit l3 = log --pretty=oneline --abbrev-commit -n3 lm = log --pretty=oneline --abbrev-commit master.. rc = rebase --continue st = status -sb squash = !git rebase -i --autosquash $(git merge-base m…

[deleted]

Re: Level Up Your Shell Game

#25
post #18

IMO the aliases for git should be in ~/.gitconfig instead. I have a bunch of these, like: [alias] br = branch co = checkout ci = commit -v sci = svn dcommit --interactive cp = cherry-pick l = log --pretty=oneline --abbrev-commit l3 = log --pretty=oneline --abbrev-commit -n3 lm = log --pretty=oneline --abbrev-commit master.. rc = rebase --continue st = status -sb squash = !git rebase -i --autosquash $(git merge-base m…

Why exactly do you love 'alias psgrep="ps aux | grep"' ? What does it get you that pgrep doesn't (or, if you need more information, 'ps u `pgrep `')?

I've worked on a lot of systems that don't have pgrep.

'ps aux | grep' works everywhere

Re: Level Up Your Shell Game

#26

They 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

#29
post #2

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.

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!

Re: Level Up Your Shell Game

#30
post #9

The command line navigation commands are just what any Emacs user would expect. vi users can set their $EDITOR to 'vi' to get those commands. What do you mean you've never used Emacs? mumble whippersnappers mumble

Use `set -o vi` to get vi navigation commands on the command line. EDIT: In bash, that is. It's `bindkey -v` in zsh.

Do it in .inputrc like this:

set editing-mode vi

Now any executable that uses readline will have vi editing commands on its command line. mysql, psql, etc.

Do as much of your command line editing configuration in .inputrc as possible, and you'll have it everywhere.

EDIT: man readline

Post reply on HN