It is 2013, we (still) don't have flying cars, or hoverboards, AND as developers, we still use terminals to interact with our operating system. So every so often I like to browse through commandlinefu.com and try and pick up any little tidbits which improve my command line efficiency.
Here's a small selection I have picked up recently that I didn't know.
sudo !!
Run the previous command as sudo. This is great when you realise you needed to run something as root.
ctrl-x e
Open up $EDITOR to enter in a long command. In my setup it fires up vim. This is great for some of the long rails commands you need to create controllers or models.
cat /etc/passwd | column -s':' -t
Column, columnates input, the -t argument will format standard input into a table and -s lets you specify an arbitrary field delimiter. For unformatted input this is very handy.
These next few are specific to zsh, and while I do love bash, since switching to zsh I haven't really looked back. It's things like this that when you work with a terminal every single day, you can't give up.
aaron@tempest ~ $ d
0 ~
aaron@tempest ~ $ cd /etc
aaron@tempest /etc $ d
0 /etc
1 ~
aaron@tempest /etc $ 1
~
aaron@tempest ~ $
The 'd' command lists the directory stack, and then entering an integer will switch you directly to the directory index in the stack. It is a killer app.
Moving directories also is very pleasant in zsh. Use '..' to move up a directory, and simply type the name of the directory in, to move into a directory.
aaron@tempest ~ $ ..
aaron@tempest /Users $ aaron
aaron@tempest ~ $
This last one is a trick I've know for a few years, I don't know how much time this has saved me exactly, but I use it every single day.
In vim, if you're editing a file that requires root (or any other user) permissions, you can write the file by doing
:w !sudo tee %
I use it so much that I've set up a leader key binding in my .vimrc
nnoremap <leader>sr :w !sudo tee %<CR>
There's nothing more annoying than making lengthy changes to a config file, go to write it and getting permission denied...
I make all my configs available online at github, if you're interested in seeing how I setup my environment.