The first thing I do on any bash terminal is `set -o vi`. This changes the default keybindings from emacs-like to vi-like. I find it to be a huge booster to my speed in navigating the command line.<p>edit: Actually, something cool I learned recently is that if you put the line "set editing-mode vi" in your ~/.inputrc then vi-like editing keys are available in any program that uses readline. This includes bash and the python repl. Presumably, a bunch of other repls and interactive command lines too.
Very true. I have difficulties in training new recruits with UNIX. For some reason, beginners have developed an aversion to UNIX/shell scripting. I myself have started more and more of Ruby/AWK/Python, but it is always SHELL that blows me off with the sort of impact it has on the daily work.<p>I ended up highly optimizing my work environment to replace long ssh connections with `conn prod` (will use my RSA key and connect). File tranfers with `go get prod filename` or `go send prod filename`. Another script that can remember directory paths (I have to go over lot of them every day, and typing long lengthy ones does not help).<p>To me, UNIX shell scripting is a lazy men's most effective tool, only if you know how to use that rightly.<p>Loved the post. And thanks much.
My most used bash command is probably "sudo !!", which runs the previous command with "sudo" prepended.<p>The book "Unix Power Tools" showed me that higher-level programming languages (Perl, Python, Ruby, etc) are not needed to accomplish most administrative tasks. Awk is incredibly useful (but also very confusing, imo).
Two very basic tips for vi:<p>You can use slash(/) and question mark(?) to search for text (forward and backward) in vi. It's useful to know these, because they also work with less(1).<p>If you are Windows user and used to press Ctrl+S to save the file and you accidentally do that in Vi, your terminal would get stuck. But you can use Ctrl+Q to unfreeze it.
<i>"Fact of life is, as you spend time in the terminal, you're probably going to launch Vim at some point, whether willingly or not...</i>
<i>For all other intents and purposes, just friggin use nano. Or sublime."</i><p>Words to live by.
Tip: I recently looked up the man page for "which" and found out about the -a flag which will list all instances of the executable found (instead of just the first one). Incredibly useful when you have multiple installations of the same software and it's causing problems. e.g.:<p><pre><code> $ which -a ruby
/Users/olalonde/.rbenv/shims/ruby
/usr/local/bin/ruby
/usr/bin/ruby</code></pre>
To exit vim use <ESC> :wq, not just :wq - most of the problem is it getting stuck in insert mode, and not knowing how to escape into normal mode.
I love playing around in bash. Most of the scripts I have right now are just for setting up project templates, adding common packages etc.<p>Actually, I think most people who use computers at work, be they writers, designers, whatever, not just programmers, would benefit from learning some bash (or batch). You can automate a lot of useful processes with a few simple scripts.
1. I like tab-completion, but I can't personally stand bash's completion feature. Be aware of differences.<p>2. If you want to save your command without running it... comment it out with a '#'. Bang, it's in your history.