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!
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 master HEAD)
Also, I prefer to set aliases in my ~/.functions instead of in ~/.bash_profile or ~/.bashrc. I find that this makes it easier to move the .functions file from one machine to another, especially on a lab/test machine with a shared account where I shouldn't be modifying things in the shared ~/.bashrc. To make this work, you can add this to your ~/.bashrc or ~/.bash_profile:
if [ -f ~/.functions ]; then . ~/.functions; fi
This will source your .functions file if it exists when your .bashrc is run.
A tweak to the "editbash" suggested alias will make it so that you don't have to reopen your terminal. My equivalent alias is "vif", for "vi .functions":
alias vif='vi ~/.functions; . ~/.functions'
Note that the second command (after the semicolon) sources the modified .functions file.
Lastly: brevity is king. I love 'alias psgrep="ps aux | grep"', since I use it several times a day, but to "level up your shell game", keep it short. My alias for this command is "psg". The other alias that I use all the time is "d" -- "alias d='ls -lFh --color --group-directories -v'".
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 <name>`')?
My favorite shell trick (not in the link) is this: ~-
Tilde-hyphen expands to the previous directory you were in, and of course "cd -" returns you to your previous directory, so I put them together all the time.
Here's an example workflow (with a fake PS1):
mac:/Users/me/Projects/my_new_app$ cd ~/.pow
mac:/Users/me/.pow$ ln -s ~- .
mac:/Users/me/.pow$ cd -
mac:/Users/me/Projects/my_new_app$
Now I can continue working on my app.
<disclaimer>
That's bit of a contrived example above. Here's a more
realistic way to do a symlink for pow:
It's probably worth mentioning that all the delete functions he points out(all of them for that matter, ctrl-k, etc) are actually cut's, so you can paste them back as well.
I find Ctrl-u especially useful when I'm halfway through with a command, then I realize I wanted to do something else before executing said command, so I cut it- then paste it back when I need it.
* Ctrl + y to paste anything back
$ aaa ^U
# now "aaa" is the only thing in the kill ring
$ bbb ^U
# now kill ring is ["aaa", "bbb"]
$ ccc ^U
# now kill ring is ["aaa", "bbb", "ccc"]
$ ^Y
$ ccc
# alt+y cycles through the kill ring
$ bbb Alt+Y
$ aaa Alt+Y
$ ccc Alt+Y
$ bbb
etc. This likely feels completely natural if you're an emacs user. I don't know what the equivalent vi thing is.
Interestingly, relatedly, a lot of the emacs style keybindings (ctrl-a, ctrl-e, ctrl-k, etc) are system-wide in OSX. I prefer vim as my daily editor, but it is often useful. You can also make the bindings even more emacsy if you want.
I prefer to use inputrc instead of aliases. Put the following into your .inputrc
"\C-gs": "git status -sb "
Then, for example, after pressing Ctrl-g, s "git status -sb " will appear in your prompt. Much more readable than lots of two or three letter aliases. You can see the complete list of my shortcuts on my GitHub - https://github.com/grn/dotfiles/blob/master/inputrc
I like the commands, especially the ssh one, which I didn't know before and will certainly use in the future.
I also enjoyed the format of the article. A whole dev team each contributing their own piece to a blog post provides a lot of different voices and styles in a concise way.
[+] [-] agscala|12 years ago|reply
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.
[+] [-] temo4ka|12 years ago|reply
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)
[+] [-] pianoben|12 years ago|reply
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!
[+] [-] barrkel|12 years ago|reply
Backspace normally just deletes the last character in your incremental search string.
And be sure that C-s / C-q aren't set up for terminal flow control with something like:
[+] [-] manojlds|12 years ago|reply
[+] [-] bstpierre|12 years ago|reply
A tweak to the "editbash" suggested alias will make it so that you don't have to reopen your terminal. My equivalent alias is "vif", for "vi .functions":
Note that the second command (after the semicolon) sources the modified .functions file.Lastly: brevity is king. I love 'alias psgrep="ps aux | grep"', since I use it several times a day, but to "level up your shell game", keep it short. My alias for this command is "psg". The other alias that I use all the time is "d" -- "alias d='ls -lFh --color --group-directories -v'".
[+] [-] barrkel|12 years ago|reply
Write a script called git-mycommand, and you can invoke it with 'git mycommand'. Tab completion works too, at least for bash + bash_completion.
[+] [-] jeorgun|12 years ago|reply
[+] [-] unknown|12 years ago|reply
[deleted]
[+] [-] rwl4|12 years ago|reply
Tilde-hyphen expands to the previous directory you were in, and of course "cd -" returns you to your previous directory, so I put them together all the time.
Here's an example workflow (with a fake PS1):
Now I can continue working on my app.<disclaimer>
That's bit of a contrived example above. Here's a more realistic way to do a symlink for pow:
</disclaimer>[+] [-] Scaevolus|12 years ago|reply
[+] [-] patrickmay|12 years ago|reply
What do you mean you've never used Emacs? mumble whippersnappers mumble
[+] [-] yaychris|12 years ago|reply
EDIT: In bash, that is. It's `bindkey -v` in zsh.
[+] [-] dmourati|12 years ago|reply
http://www.ibm.com/developerworks/opensource/library/l-keyc/...
http://webcache.googleusercontent.com/search?q=cache:n5M47jV...
http://webcache.googleusercontent.com/search?q=cache:BzFiI_7...
(pt2/pt3 borked on IBMs site)
[+] [-] yonaguska|12 years ago|reply
[+] [-] philsnow|12 years ago|reply
[+] [-] adamnemecek|12 years ago|reply
Alternatively, you can just do '. ~/.bash_profile' or 'source ~./bash_profile'.
[+] [-] Cyranix|12 years ago|reply
[+] [-] goshx|12 years ago|reply
ctrl + 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;
[+] [-] lotsofcows|12 years ago|reply
[+] [-] deckiedan|12 years ago|reply
http://irreal.org/blog/?p=2063
[+] [-] jacobolus|12 years ago|reply
http://www.hcs.harvard.edu/~jrus/site/cocoa-text.html
Also cf.:
http://www.hcs.harvard.edu/~jrus/site/system-bindings.html
http://www.hcs.harvard.edu/~jrus/site/selectors.html
https://github.com/jrus/cocoa-text-system/tree/master/KeyBin...
[+] [-] molecule|12 years ago|reply
https://git.wiki.kernel.org/index.php/Aliases
...after aliasing git to 'g' in your shell config, of course :)
[+] [-] nbouscal|12 years ago|reply
[+] [-] unknown|12 years ago|reply
[deleted]
[+] [-] grn|12 years ago|reply
[+] [-] barrkel|12 years ago|reply
[+] [-] dbbolton|12 years ago|reply
[+] [-] dce|12 years ago|reply
[+] [-] robrenaud|12 years ago|reply
> 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.
[+] [-] xerophtye|12 years ago|reply
[+] [-] bglazer|12 years ago|reply
I also enjoyed the format of the article. A whole dev team each contributing their own piece to a blog post provides a lot of different voices and styles in a concise way.
[+] [-] enahs|12 years ago|reply
[+] [-] kronbsy|12 years ago|reply
[+] [-] unknown|12 years ago|reply
[deleted]
[+] [-] goshx|12 years ago|reply
to clear the screen, instead of typing "clear" is pretty useful too.