I didn't see Ctrl-r, but I've found that to be the most insanely useful shortcut.<p>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.<p>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.
IMO the aliases for git should be in ~/.gitconfig instead. I have a bunch of these, like:<p><pre><code> [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)
</code></pre>
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:<p><pre><code> if [ -f ~/.functions ]; then . ~/.functions; fi
</code></pre>
This will source your .functions file if it exists when your .bashrc is run.<p>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":<p><pre><code> alias vif='vi ~/.functions; . ~/.functions'
</code></pre>
Note that the second command (after the semicolon) sources the modified .functions file.<p>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'".
My favorite shell trick (not in the link) is this: ~-<p>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.<p>Here's an example workflow (with a fake PS1):<p><pre><code> 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$
</code></pre>
Now I can continue working on my app.<p><disclaimer><p>That's bit of a contrived example above. Here's a more
realistic way to do a symlink for pow:<p><pre><code> mac:/Users/me/Projects/my_new_app$ ln -s `pwd` ~/.pow/
</code></pre>
</disclaimer>
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.<p>What do you mean you've never used Emacs? <i>mumble whippersnappers mumble</i>
Everything you ever wanted to know about SSH keys but were afraid to ask:<p><a href="http://www.ibm.com/developerworks/opensource/library/l-keyc/index.html" rel="nofollow">http://www.ibm.com/developerworks/opensource/library/l-keyc/...</a><p><a href="http://webcache.googleusercontent.com/search?q=cache:n5M47jV8tSkJ:www.ibm.com/developerworks/library/l-keyc2/+&cd=1&hl=en&ct=clnk&gl=us" rel="nofollow">http://webcache.googleusercontent.com/search?q=cache:n5M47jV...</a><p><a href="http://webcache.googleusercontent.com/search?q=cache:BzFiI_7zLoMJ:www.ibm.com/developerworks/library/l-keyc3/+&cd=1&hl=en&ct=clnk&gl=us" rel="nofollow">http://webcache.googleusercontent.com/search?q=cache:BzFiI_7...</a><p>(pt2/pt3 borked on IBMs site)
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
> Note: you’ll need to open a new Terminal window for changes in ~/.bash_profile to take place.<p>Alternatively, you can just do '. ~/.bash_profile' or 'source ~./bash_profile'.
When you execute a command that takes a long time to run and you want to send it to the background you can do:<p>ctrl + z<p>then, to send it to the background:<p>bg<p>and, to get it back from the background:<p>fg<p>Also, I really like to use "for", like:<p>// get the size of each file or directory in the current directory<p>for i in `ls -1`; do du -hs $i; done;
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.<p><a href="http://irreal.org/blog/?p=2063" rel="nofollow">http://irreal.org/blog/?p=2063</a>
aliasing git shortcuts seems more appropriate for git config:<p><a href="https://git.wiki.kernel.org/index.php/Aliases" rel="nofollow">https://git.wiki.kernel.org/index.php/Aliases</a><p>...after aliasing git to 'g' in your shell config, of course :)<p><pre><code> alias g='git'</code></pre>
I prefer to use inputrc instead of aliases. Put the following into your .inputrc<p><pre><code> "\C-gs": "git status -sb "
</code></pre>
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 - <a href="https://github.com/grn/dotfiles/blob/master/inputrc" rel="nofollow">https://github.com/grn/dotfiles/blob/master/inputrc</a>
Here is a rule for how to level up your shell/editing game. If you ever touch your arrow keys, you are doing something wrong.<p>> ctrl + left arrow Moves the cursor to the left by one word
> ctrl + right arrow Moves the cursor to the right by one word<p>Alt + b and Alt + f are also aliases for the same action.
I like the commands, especially the ssh one, which I didn't know before and will certainly use in the future.<p>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.