All notes tagged with linux.

June 29, 2024

linux emacs

Sync Fastmail with isync

As an Emacs enthusiast, I’ve found Mu4e to be an excellent email client. While Emacs can send emails, it can’t fetch and sync them efficiently. Enter isync, the perfect companion to fill this gap.

Setting up this duo took some digging, so I’m sharing my configuration to save you time and headaches.

Here’s what my setup accomplishes:

  1. Syncs all mailboxes, excluding junk and notes.
  2. Renames “Sent Items” to “Sent” for simplicity.
  3. Encrypts your password on disk using GPG.

First, I recommend to install the latest version of isync, if you are on the Mac, use brew install isync --HEAD. Then, you’ll need to create an encrypted password file. In Emacs, run the epa-encrypt-file command.

Now, let’s dive into the heart of the setup. Here’s my .mbsyncrc configuration file:

# Petar account on Fastmail.
IMAPAccount petar
Host imap.fastmail.com
Port 993
AuthMechs LOGIN
User [email protected]
PassCmd "gpg -q --for-your-eyes-only --no-tty -d ~/.mbsync-password-petar.gpg"
TLSType IMAPS
TLSVersions +1.2

IMAPStore petar-remote
Account petar

# Petar Local.
MaildirStore petar-local
Path ~/Mail/Petar/
Inbox ~/Mail/Petar/Inbox
Trash ~/Mail/Petar/Trash/
SubFolders Verbatim

# Sync everything besides sent and junk.
Channel sync-petar-all
Far :petar-remote:
Near :petar-local:
Patterns * !"Sent Items" !"Junk Mail" !"Notes"
Expunge None
CopyArrivalDate yes
Sync All
Create Near
SyncState *

# Sync and rename the sent items
Channel sync-petar-sent
Far :petar-remote:"Sent Items"
Near :petar-local:Sent
Expunge None
CopyArrivalDate yes
Sync All
Create Near
SyncState *

Group petar
Channel sync-petar-all
Channel sync-petar-sent

With this setup, you’ll have all your email on disk, ready to use it in Emacs and Mu4e.

Switching between devices with Syncthing

I have a desktop machine running Linux and a Macbook running MacOS, and I often switch between devices while working on a project.

Now, I can sync states using Git, but I often find that doing so makes me create pointless commits just to sync states.

That’s where I started using Syncthing on all my devices. I’ll leave installing Syncthing for you, the reader, but there is one handy trick I think you need to know.

If you create a .stignore file in your project root, and you add:

#include .gitignore

It will take your .gitnore and exclude the items in it from being synced. This is helpful for reducing the size of the sync but also means that you won’t sync build artifacts, which may not be compatible across devices.

Try it out!

August 22, 2023

vim linux

Latest Neovim on Ubuntu

I’m using Ubuntu for my development environment, and Ubuntu does not have the latest Neovim in their repository.

That’s why I choose to install the last version by source. The steps I take are:

wget https://github.com/neovim/neovim/releases/download/v0.9.1/nvim-linux64.tar.gz
tar xfz nvim-linux64.tar.gz
sudo mv nvim-linux64 /opt/nvim

Now you have to make sure that /opt/nvim/bin is part of your path. If you are smart, and using the Fish shell, add this to your Fish config.

fish_add_path -aP /opt/nvim/bin

If you are on Bash:

export PATH=/opt/nvim/bin:$PATH

Enjoy your latest version of Neovim!

July 9, 2023

linux alacritty

Alacritty as default terminal

I’m using Alacritty as my terminal of choice on Ubuntu (Pop!OS). When installed manually, it does not work with the hotkey of Pop!OS because you can’t set it as the default terminal.

For that to work, you have to manually add it as an alternative and set it:

sudo update-alternatives --install /usr/bin/x-terminal-emulator x-terminal-emulator $(which alacritty) 50
sudo update-alternatives --config x-terminal-emulator

February 17, 2023

linux java

Java with Adoptium on Linux

Recently I wrote down how to get Java installed on MacOS with the help of Adoptium. Well, it turns out, I also use Linux (Pop!_OS if you were wondering).

To install Java on Linux, go to the Adoptium page and download the tarball according to the version and your architecture. I downloaded the LTS 19 for x64:

tar xfz OpenJDK19U-jdk_x64_linux_hotspot_19.0.2_7.tar.gz
sudo mv jdk-19.0.2+7 /opt/

And now make sure that your shell can find it, my shell is Fish, so I added this snippet:

# Java installation through Adoptium
set -l java_version "19.0.2+7"
if test -d "/opt/jdk-$java_version"
    set -x JAVA_HOME "/opt/jdk-$java_version"
    fish_add_path -aP "$JAVA_HOME/bin"
end

Now you have Java, quickly go install Clojure :)

February 15, 2023

linux utils

Espanso, text expander for Linux

I love the smart dashes – and I use them heavily – on the Mac and it’s something I missed on PopOS!.

Luck be it, Espanso comes along. Installation on a Debian system is easy.

Configuration of Espanso is done by editing configuration files located in ~/.config/espanso directory. You can also find it by tying espanso path. The files contained in the match directory define what Espanso should do. The files contained in the config directory define how Espanso should perform its expansions.

To replace our double dashes with a long dash we are going to edit $CONFIG/match/base.yml add change it to:

matches:
  - trigger: "--"
    replace: ""

However, now this also happens in our terminal, which is annoying, so we are going to disable Espanso completely in the terminal with an app specific configuration.

We’ll disable it in Alacritty, my terminal of choice by creating a config/alacritty.yml and match on the class name:

filter_class: Alacritty
enable: false

That’s it, Espanso is super powerful and I can recommend reading the docs on what else it can do. Oh, and it also works on MacOS or Windows.