2014-12-14

Little things I would teach to my younger software engineer self - #4 Life in the console

Looking back at the various stages of my career, I realized I could have learned some basic stuff way earlier than I did.
Even if I missed the original opportunity, all those little skills I acquired late served me tremendously well ever since.


1993-me: What a misery! I am telnetting from HPsUX to a Tru64 and once again my backspace doesn't work!
AGAIN, I'll have to spend hours trying to fix that POS console by trying out random bindings... Enough of this crap ! I give up, I am more efficient with my mouse.

2014-me: Hang on in there! Few years down the road it won't be a misery anymore, Linux is coming! This will put the power of the shell at your fingertips without this pain.

Check out my current favorite combo at the moment:
 zsh + oh-my-zsh + tmux.




Start with a plain zsh to master the basics, browse and take the simple stuff from zshtips for example.

The main goal of all those little commands is composability, this is extremely powerful. A tool that sorts, another one that gives you the n first lines and another one that monitor a command all have a limited purpose but suddenly when you combine them it is magical:

# this will monitor the 50 first
# alphabetical entries from a file

$ watch "sort myfile | head -n 50"

But wait until you have setup oh-my-zsh to start tweaking your .zshrc.

oh-my-zsh is a plugin system that considerably simplify the setup of zsh and gives you some bindings to a lot of integrations like git, docker, python, etc.
For example with git, you'll be able to see the branch on which you are from the prompt, tab autocomplete the names of the branches when you git checkout etc.
Try to have your console emulator work with 256 colors, it will look less aged.

The last thing is tmux. This is a terminal multiplexer. It serves 2 main purposes: 

1. make your sessions persistent (you loose your ssh connection, you reconnect and magically your session is still there)

2. be able to use several shells/programs from the same session.

For example I use vim on top of a "pane" (a kind of textual window) that I run in server mode. On the bottom I use zsh and I can type vim file.txt and my alias will open it straight on the vim on top, it is almost like an IDE / shell hybrid. See the screenshot above.

Any tips you would give to your younger self programmer ? Feel free to comment below !