I’ve recently started developing more in Linux, here is a collection of tools, tips and tricks to get the most out of the box. I’ll expand this list from time to time.

Appearance

Terminal & Editor font: Hack

Here is a test pattern I am using to evaluate fonts:

o0O s5S z2Z !|l1Iij {([|})] .,;: ``''"" 
a@#* vVuUwW <>;^°=-~ öÖüÜäÄßµ \/\/ 
the quick brown fox jumps over the lazy dog
THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG
0123456789 &-+@ for (int i=0; i<j; ++i) { }

This is how the pattern looks like with Hack, my favourite programming font:

font test pattern

All characters are very distinguishable, e.g. 0 and O, 1 and l. Subpixel hinting is also excellent.

colormake

Simple wrapper around make to colorize its output.

sudo apt install colormake

redshift

Install redshift-gtk, which is similar to f.lux but is more robust on my graphics card. I use this config for redshift (geoloc provider has problems).

In file ~/.config/redshift.conf:

; Global settings
[redshift]
location-provider=manual
 
; Linz, Austria
[manual]
lat=48.306940
lon=14.285830

Tools

Terminator

Multi-window terminal with lots of features.

sudo apt install terminator

ripgrep

Extremely fast grep tool, similar to ack but much faster, even faster than silver searcher. It searches through my 48GB subversion folder in 1 second. Also available for Windows! See here for installation instructions.

I’ve also added some aliases in ~/.bash_aliases:

# only sarch for cpp files, smart case handling.
alias rgc='rg -tcpp -S'

# only cpp, and only in test subfolders
alias rgct='rg -tcpp -g "*/test/cpp/**/*" -S'

# only cpp, everything but test subfolders
alias rgcnt='rg -tcpp -g \!"*/test/cpp/**/*" -S'

geany

Replacement for gedit, for basic editing tasks. It’s not excellent but usually does the job. I’m not a vim/emacs guy.

kate

Kate is faster than Visual Studio Code, and has more features than geany:

sudo apt install kate

To get beautiful fonts without installing the rest of kde, create ~/.config/fontconfig/fonts.conf with this content:

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
  <match target="font">
    <edit name="antialias" mode="assign">
      <bool>true</bool>
    </edit>
  </match>
  
  <match target="font">
    <edit name="hinting" mode="assign">
      <bool>true</bool>
    </edit>
  </match>

  <match target="font">
    <edit name="hintstyle" mode="assign">
      <const>hintslight</const>
    </edit>
  </match>

  <match target="font">
    <edit name="rgba" mode="assign">
      <const>rgb</const>
    </edit>
  </match>

  <match target="font">
    <edit mode="assign" name="lcdfilter">
      <const>lcddefault</const>
    </edit>
  </match>
</fontconfig>

Visual Studio Code

Nice and highly configurable editor, also great in Linux. Just open a directory and you are ready to go. Get it here. Essential extensions are:

There are many others, but these are the bare minimum I use.

glances

Glances gives a fantastic overview of what’s going on in the system. Using you can see at a glance if e.g. your memory, disk space, swap is running out. The version you’ll get with apt is unfortunately quite outdate, so I am installing it with pip (see the homepage).

glances

Useful Time Savers

Clear Terminal buffer

In ~/.bash_aliases, put this:

alias cls='printf "\033c"'

While Ctrl+L just clears the screen, cls will now clear the whole buffer. Convenient for a large build job and you want to scroll up to find something without scrolling too far.

Sleep Until

I use this ruby script to sleep until a given time. It’s in ruby so I can also easily use it in Windows:

#!/usr/bin/ruby

# sudo gem install chronic
require 'chronic'

exit(0) if ARGV.empty?

t = Chronic.parse(ARGV.join(" "))
now = Time.now
t += 60*60*24 if t < now
delaySeconds = t - now
puts "Sleeping #{delaySeconds.to_i} seconds until #{t.rfc2822}"
sleep(delaySeconds)

I use this to schedule builds, so that when I arrive at the office everything is already built with the latest version so I can start working right away.

$ sleepuntil monday && svn up && make -j4 build
Sleeping 71605 seconds until Tue, 6 Dec 2016 03:00:00 +0100

bash prompt with runtime and errorcode

See my Linux Bash Prompt post. It’s awesome.

bash prompt

Optimizations

ccache

Use ccache, and use it on an SSD disk. Here are my settings from ~/.ccache/ccache.conf:

max_size = 16G
compression = true
compression_level = 1

I’m using this for a huge C++ project where I build debug, release both in 32bit and 64bit, so a large ccache helps. Using compression_level is only a very minor slowdown, but practically increases cache size by a factor of 3-5 or so.

Use tmpfs for /tmp

Much faster compilation. Add this to /etc/fstab:

tmpfs	/tmp	tmpfs	mode=1777,nosuid,nodev	0	0

Compressed RAM

Especially in virtual machines or low-end machines where memory is constrained, zram provides memory compression.

sudo apt install zram-config

Reboot your machine, and everything is well configured. For more information, see

Disk Cleanup

Remove libreoffice

sudo apt remove --purge libreoffice*
sudo apt clean
sudo apt autoremove

Remove old Kernels

sudo apt install byobu
sudo purge-old-kernels

Source: How to Easily Remove Old Kernels in Ubuntu 16.04

Virtualbox

Dynamic Disk Size

Don’t do it. It’s much slower. If you have to, be aware of this:

Enable TRIM support

Don't do this. I've got file corruptions!

This will shrink the .vdi file, even when it does not have a dynamic size.

  1. In Windows host, list the available VMS. This gives me LinuxMint180GB.
    VBoxManage.exe" list vms
    
  2. In the Windows host, enable SSD and TRIM support for the image (see here):
    VBoxManage storageattach LinuxMint180GB --storagectl "SATA" --port 0 --discard on --nonrotational on
    
  3. In Linux guest, perform TRIM, you’ll see the .vdi disk shrinking while this runs:
    sudo fstrim -va
    
  4. Add a nightly task to crontab with sudo crontab -e, there add this line:
    @midnight fstrim -a
    

I also tried to mount the image with the discard option (see here), but it caused my Linux to hang so I disabled it again

Mount shared folder

Add the user to the vboxsf group:

sudo usermod -G vboxsf -a martinus

Edit /etc/fstab e.g. like this:

Share_VB        /media/sf_Share_VB      vboxsf  defaults,noauto 0       0

GNOME keyring Without Password Prompt

It’s unfortunate when a scheduled svn up asks for password because it has not been entered for a while. To disable the password question, do this:

  1. sudo apt install seahorse
  2. Follow this guide.

Optimize Disk Scheduler: use noop

When using virtualbox, it’s best to use the noop scheduler. See this. From here:

  1. cat /sys/block/sda/queue/scheduler
  2. sudo gedit /etc/default/grub
  3. Change the line
    GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
    

    into

    GRUB_CMDLINE_LINUX_DEFAULT="elevator=noop quiet splash"
    
  4. sudo update-grub