The way I work in 2021


Colours

Text based Linux shouldn't stand much back from GUI based Linux IMO. To achieve this, it's paramount that everything supports 24 bit colours so that we get the same amount of colours GUI apps get to play with.

Low latency SSH sessions

Compile mosh from source to get 24 bit colour support.

First, install dependencies:

# apt-get install \
    autoconf \
    protobuf-compiler \
    libncurses-dev \
    libssl-dev \
    pkg-config

Then compile and install mosh from source:

$ git clone https://github.com/mobile-shell/mosh
$ cd mosh
$ ./autogen.sh
$ ./configure
$ make
$ su -
# make install

This gives you mosh with 24 bit colours which lets my use the most colourful editor colour themes, and they're indistinguishable from the GUI version.

Have links in the terminal

The Kitty terminal has this covered out of the box. If a URL is anywhere in the terminal, I can open it by doing Ctrl + Shift + e and selecting which URL by the number Kitty has inserted.

Have remote Emacs links open in the desktop browser

When links are rendered in Emacs, for instance when reading email in mu4e or viewing notes in org-mode, the URL is hidden, like on a web page. When running a GUI Emacs, hitting enter on these links will open them in the desktop browser. However, when Emacs runs on a remote machine, a hack is needed.

First off, I set Emacs to write all links to a file instead of opening them in Firefox:

(setq browse-url-generic-program "/home/torstein/bin/firefox"
      browse-url-browser-function 'browse-url-generic)

Normally, this firefox points to /usr/bin/firefox or similar, but on my server, it's a just a shell script:

#! /bin/bash
echo "$@" >> $HOME/tmp/links.txt

I then use ssh to keep a local copy:

$ ssh ssh.example.com tail -f ~/tmp/links.txt > ~/tmp/links.txt

The final piece of the puzzle is this call to inotify which listens for changes to links.txt and opens the last link written in Firefox.

$ while inotifywait -e modify ~/tmp/links.txt; do firefox $(tail -1 ~/tmp/links.txt); done

Licensed under CC BY Creative Commons License ~ ✉ torstein.k.johansen @ gmail ~ 🐦 @torsteinkrause ~