The Valuable Dev

Build Your Development Environment For More Productivity

linux shell

Some years ago I was using Ubuntu. It was easy to install and easy to use. I mostly used Windows in my computing life and Unity was feeling similar. At least to me.

It was not perfect:

  • Weird display bugs was popping from time to time.
  • I always felt Unity pretty slow.
  • I had to compile manually a lot of applications not available in the official repositories.
  • I had to compile manually a lot of applications totally outdated in the official repositories.
  • I had to learn a lot of random shortcuts to use my keyboard as much as possible for basically every tools.

I didn’t know better, so I stuck with it for years.

Then something happened. I had to upgrade my LTS version.

Everything crashed. I couldn’t even start Ubuntu anymore. Since I had no clue about Linux in general, I didn’t even try to fix it. I had to reinstall everything.

I began to feel some bitterness filling my heart. Ubuntu wasn’t that great. It didn’t teach me anything about Linux in general and how to solve possible problems.

Luckily enough, some months later, I had the pleasure to work with competent developers who showed me how to build a mouseless, highly effective development environment.

My whole workflow shifted from there. I went from Ubuntu to Arch Linux, from Unity to i3, from PhpStorm to Neovim.

After years of silent struggle, I finally had a personalised, stable, up-to-date and very efficient system. I even wrote a bunch of scripts to install everything I need in one command line. In one command line and some input, everything was installed.

It was one of the best shift I did in my career. No more, no less. Why?

  • I learned a ton how you can configure a Linux distribution thanks to Arch Linux. It’s important to know how things work under the layers of abstraction of your OS, to be able to solve possible problems.
  • I have consistent shortcuts throughout almost every application I’m using.
  • I’m using a lot of keystrokes since I can use 90% of my system with the keyboard only. If I can remember them, it’s because they make sens, much more than the typical GUI shortcuts like ctrl + shift + alt + e

Let’s be clear: I think your development environment is much more important than most developer think. You need to feel at home, comfortably on your couch. You will feel more efficient in a system you built. A system which answers your needs.

Developing will be even more enjoyable.

Interested? Come with me. I will help you build your new home for your future mind-blowing-disrupting-crazy applications.

Your Best Friend, the Terminal

linux shell Simple et efficient shell

In this article I will refer to the unix shell pretty often. There is more than one specific shell for Unix systems though. I personally use zsh, and I would highly recommend it.

So, why using a text-based shell?

  • You have access to many applications. Even if you don’t have the very specific tool you need, you can develop it more easily for the shell: no need to design a GUI on top of it.
  • It’s easier to give a lot of optional possibilities to the end user, letting him do exactly what he wants. You can’t put 20 buttons on a graphical interface? With a command line based application, you can have 20 flags.
  • The unix philosophy allows you to use specific tool for very specifics needs. Using pipelines to throw the output from one tool to the input of another give you endless possibilities!
  • You can automate (boring) common tasks very easily using the shell. Automating is key to increase your productivity and saving your mental energy for what really matter.
  • The applications are often really fast. No heavy graphical interfaces full of 3D menu and whatnot to slow down your computer.
  • CLIs don’t usually take a lot of memory. This can save you when you modify 5 different micro services with Chrome eating 80% of your RAM.

Command-line tools can be 235x faster than your Hadoop cluster.

Adam Drake

I encourage you to use the shell as much as possible. It can be a bit tough at first, but the benefits are insane.

A lot of people will use graphical interface on top of CLI applications. It has serious disadvantages:

  • It adds a layer of abstraction, which can leak. You won’t be able to solve (or even understand) any bug coming from the CLI layer.
  • It can hide a lot of functionalities you would access easily with the CLI.

Things get confusing when you need to:

  • Use the tool on a remote server without your graphical interface (on a remote server, for example).
  • Explain to a less experienced developer how the tool really work. You can explain the GUI, not really the application itself, especially if the terminology between the GUI and the CLI differ a lot. It happens more than not.

I have a real life example: sourcetree, a graphical interface for git. I worked with a junior developer who was using it without knowing how git works. When problems arose, it was difficult to know what the application did, what command it was calling under the hood. Way more frustrating than simply using git via the shell.

Another very important point: with the shell you use mainly your keyboard. It might surprise some of you, but I try to avoid my mouse as much as possible. This is one of most important advice about efficiency I can give: keeping your hands on your keyboard will make you happier and faster. It might sound silly but it has a lot of advantages:

  • Moving your hand from your keyboard to your mouse is tiring. You will see it if you stop doing it.
  • It’s more enjoyable to stay on your keyboard. You don’t have to switch constantly between typing and moving a pointer.
  • You will feel like a hacker even if you only write your shopping list! How cool is that?

A mouseless development environment. That’s what this development environment aims for.

Arch Linux: the Latest, Up-To-Date Software

arch linux screenfetch Arch Linux running smoothly on a VM

Arch Linux has a lot of advantages compare to other Linux distribution.

First of all: Arch Linux use a rolling release system. It means that the whole system is continuously updated by the community. This include the Linux kernel and every applications available in the repositories you have installed.

This is great: no need to ask yourself if you miss great features and bug fixes for your favorite applications. You will have the most up to date system you can find.

What about the applications available? The official repositories of Arch Linux are huge. You will find most of the time what you need there. If you don’t, you can have access as well to the AUR (Arch User Repositories) where you can find everything else. I’m not exaggerating.

Be careful though: the applications from the AUR are not always well tested and can break dependencies. Proceed with cautions. I’m actually using aurman to install applications from the AUR since it uses pacman for everything which is not AUR related. No need to switch between pacman and aurman, using aurman for everything works well.

No, pacman is not a yellow cheese addicts to pills in dark rooms but the package manager of Arch Linux. PACkage MANager. Everything falls into place.

Moreover, when you install Arch Linux from scratch you can choose exactly what application you want to install. Nothing unwanted will pollute your hard disk. No useless applications will run in the background without your consent.

Installing your system from scratch can look tedious but it’s really not that bad. If you know how to use a shell, you’re good to go.

If you want to learn a bit more about Linux, here’s your chance.

I can see you arguing though. Who wants an exotic Linux distribution with a tiny community and therefore no help when you have a problem?

Arch Linux is everything except that. The community is huge, know what they are speaking about and don’t throw random shell commands on stack overflow without explanation whatsoever (I look at you Ubuntu people).

Who needs stack overflow anyway? The Arch Wiki is the best resource you can find on the web about Linux. Every single problem I had was solved in there. I’m still not exaggerating.

Now the question you ask yourself: is Arch Linux stable? Will it crash every two weeks, letting you alone and helpless? You will find people preaching it for sure. My advice? Don’t listen to them. I use it on a daily basis for almost 2 years now and it never crashed.

If you are careful with the AUR you can count on a very robust and lightweight and personalised Linux distribution.

However, I’m still careful. Here’s m workflow: I backup every week my whole SSD on an external hard drive using dd. I wrote a little script (dback for “disk backup”) to make it even simpler.

Then I upgrade my whole system (aurman -Syu or sudo pacman -Syu if you don’t have aurman). Sometimes pacman will ask you to do some manual modifications which is always documented on the official website of Arch Linux. It’s never difficult (like deleting a file or answering a question).

Finally, and for inspiration, I wrote a bunch of scripts which install my whole system from top to bottom with the applications I need. I can run that on a new computer and everything I need will be installed automatically.

I would advise you not to use these scripts without knowing what you’re doing. Try to install manually Arch, learn from it and then you will be able to do your own scripts. Arch Linux is great to have a personalised system. You should build yours according to your specific needs and then automate the process.

i3: How to Have a Bromance With Your Keyboard

i3 windows manager i3 windows

Arch Linux doesn’t come with any type of desktop or windows manager. You will need to install your own. My choice without hesitations: i3 windows manager.

This is a very light, fast and simple-to-use windows manager. There are no fancy 3D effects with i3. Everything is made for you to be efficient and productive without being visually repulsive.

With i3 you can create workspaces. They take a whole screen and can be moved from one screen to another. In these workspaces you can open one or multiple windows. They will embed your favorite applications.

Simple, isn’t it? Now the best part: you can do everything with your keyboard very easily. You can open, move and close workspaces or windows with simple keystrokes. You can resize windows with other keystrokes. You can open your favorite application using keystrokes.

Everything feels logical and easy to learn. I was able to use i3 efficiently two or three days after installing it. Your muscle memory will work for you here very quickly to remember the keystrokes you need to know.

The configuration possibilities are really wide for you to use it according to your specific needs. You can look at mine for inspiration. You don’t have to write all the configuration by yourself: i3 provide you a base configuration you can then modify.

You can even install it on side if you use Ubuntu. You then have the choice between i3 and Unity each time you log in.

Obviously the Arch Linux wiki has a good documentation about i3.

Urxvt, Tmux and Tmuxp: Your Terminal Is Now a Productivity Beast

tmux Tmux in Urxvt with 4 panes open and two windows

I tried a bunch of terminal emulator and Urxvt was the best choice I found.

It’s a very lightweight and fast terminal, especially if your run Urxvtd, Urxvt daemon. Spawning terminals everywhere become easy and painless.

However, I’ve rarely more than two or three terminals open at the same time thanks to Tmux. It’s a powerful terminal multiplexer (like screen on steroids) which allows you to:

  • Create sessions which include windows and pane.
  • Open as many windows in your terminal as you want. Each window take the whole terminal and can be divided into pane. You want 3 windows with 4 pane each (for a total of 12 different shells open)? tmux can handle that easily.
  • You can navigate between windows and pane very easily, again via keystrokes.
  • Detach and attach your session. Imagine you close your terminal by mistake: you can recover your whole tmux session by opening a new terminal and attaching your session to it.
  • Synchronise your pane. You need to run exactly the same command in three different remote server? Open three panes, synchronise them with one command and everything you type in the first pane will be copied in the others.
  • Many more things I don’t even know about yet.

With tmuxp you can even go further to automate your tmux sessions. Indeed, you can write a configuration file to open the windows and panes you want and automatically launching applications in them.

Let say that in order for you to work on your new cool project (which will make you rich) you need to:

  • Run docker compose in a pane.
  • Run npm run dev inside one of your docker container in another pane.
  • Open an ssh connection to your production server in a different window.

tmuxp allows you to do all of that with one command line and a simple configuration file.

Obviously tmux is easy to configure but offer you a lot of options for a maximum of flexibility.

I used terminator for quite some time. I was happy with it but I have to admit: the combo Urxvt, tmux and tmuxp is definitely faster, more practical, automatic and versatile. Without any doubts.

Vim, An IDE Which Fits Exactly Your Needs

This IDE is Neovim, an incredible fork of Vim.

neovim This article was written in Neovim

Don’t run away yet! I know you are afraid. Let me explain why you should really try to rethink everything you know about Vim.

I already wrote about Vim multiple times so I will only summarize here why I use it:

  • Coding with Vim is great. Try to understand seriously how it works and I promise you will be very surprised.
  • You don’t need any mouse with Vim. It’s sound scary but trust me.
  • Vanilla Vim has a lot of functionalities. You always learn something new.
  • Vim has a very good community which maintain a lot of plugins. They should cover 99% of your needs. In any language. JavaScript, Golang, PHP, you name it.
  • Everything is highly configurable. Forget bloated preferences, here you just fine tune everything you want.
  • You are not restricted to any language. You want to code in Rust, Go and C with the same editor with autocompletion, syntax highlighting and so on? Vim is perfect for that.
  • No more notifications appearing out of nowhere to break your flow (I look at you Intellij IDEs). You choose exactly what you want.
  • Instead of having an IDE full of stuff you will never use, you can build your own only with what you need.
  • It’s free.

Suspicious again? I was as well before trying it. A lot. However, since I use it I never looked back.

Making Git Even Better: tig and diff-so-fancy

tig tig: on top the branch hierarchy, on the bottom you can see every change made

diff-so-fancy diff-so-fancy is very nice to see quickly everything you modified

I think git is very easy to use in the shell when you understand how it works. Basically you need on a daily basis to use:

  • git push
  • git pull
  • git branch
  • git checkout
  • git merge
  • git rebase

Do you really need a bloated GUI for that? If you use git in the terminal you will know exactly what you are doing.

The first tool I use with Git is tig. It allows you to go through the git branch hierarchy and see the details of each commit you made.

git-so-fancy display git diff in a very readable way in your terminal. I always use it to verify what I commit before actually committing it.

I think with these two tools you can use git efficiently. The best part: they are both available in the official Arch Linux repositories.

Ranger, a Fully Customizable File Manager

diff-so-fancy Ranger with image preview in the terminal

I usually use the shell to do any operations on files. At times, when I need a proper file manager I use Ranger in the shell.

You can configure keystrokes for your favorite folders, execute some command lines on a bunch of files… The possibilities are really huge. You can even configure keystroke to automatically jump to your favorite folders.

Better CLI for MySQL and PostgreSQL

If you need a quick and practical interface in the shell to interact with your database, I would recommend mycli for mysql and pgcli for PostgreSql.

These tools look a lot like MySQL and PostgreSql CLI on steroids:

  • The autocompletion is way, way better.
  • You can use snippets you can configure easily.
  • You can configure different database connections.

I didn’t find a way to use it through ssh. Nevertheless, for my local databases these applications are useful.

In order to install them on Arch Linux you will need to fetch them from the AUR.

I wrote a whole article on how to install and use efficiently mycli if you want to have a quick overview of this fantastic tool.

You’re Now Ready To Enjoy Your New Personalised System

linux shell

Productivity and versatility: they are the two main reasons why I’ve chosen to build and configure my entire development environment.

This set of application is pretty easy to maintain and will evolve very well as your needs change. You won’t have to reinstall everything all the time.

Even better: you can customize everything like crazy!

This kind of environment asks for a bit of time and efforts to setup and understand. Really a bit, a couple of weeks. Then you just have to automatize everything (as a good developer should do) and you will have your own development environment. You will feel in control of it. You will feel at home.

The learning curve is not hard. It can be challenging but more important: it’s fun and it’s interesting. Trust me.

Don’t listen to people who never tried Vim saying that it’s the most complicated thing on Earth. Don’t listen to them arguing that Arch Linux will crash even more than Windows 95. I used both and I’m sure they didn’t. Otherwise, they would know it’s pure fantasy.

Last but not least: here’s the list of every piece of sofware installed on my system.

diff-so-fancy My personalised system

Take part in the discussion