Shell text substitution

I learned a neat shell trick this week. In both bash and zsh you can use the circumflex / caret (^) symbol to find & replace a word from the previous command. Usage: ^prev^next. It’s best illustrated with examples: ...

April 7, 2024 · 104 words · Thiago Perrotta

★ Tools you should know about: moreutils

moreutils has previously been covered elsewhere, multiple times. It’s a collection of small unix tools that follow the unix philosophy1 very strongly. Here are some of my favorites with example usages. Obviously this post isn’t a manual which would have been a disservice to the community; refer to the upstream man pages for detailed instructions. ...

May 1, 2022 · 683 words · Thiago Perrotta

Linux: US International keyboard layout

I use QWERTY keyboards with a US layout. Sometimes I need to type accents or cedillas, and I keep forgetting how to do so, this post summarizes how to do it. ...

February 27, 2022 · 249 words · Thiago Perrotta

★ Wayland: from i3 to sway

I’ve been giving Wayland a try. My window manager of choice in X11/Xorg is i3, so the natural choice in Wayland is sway. ...

February 19, 2022 · 1200 words · Thiago Perrotta

★ nix-env in a nutshell for basic usage in macOS

I am currently evaluating Nix as a replacement for Homebrew CLI apps in macOS1. Others have previously written about this. My goal is to keep a sane learning curve and learn things on-the-fly, only as needed. Nix is a massive ecosystem and has so many batteries included and components (NixOS, NixPkgs, NixOps, Nix programming language, nix-shell, nix-env, nix-darwin, home-manager, …). The good news is that those components are for the most part modular, there’s no need to adopt them all in order to reap the benefits that Nix provides. For now, I am only adopting nix-env and nix-shell, with no *.nix config files. This post covers nix-env. ...

February 16, 2022 · 733 words · Thiago Perrotta

★ SSH plus tmux automatically

One of the most classic sysadmin/DevOps tasks is to use secure shell to connect to remote machines. To persist those connections, a terminal multiplexer is often used, tmux and screen being the two most popular ones. In this post I will cover a few different client-side and server-side ways to have ssh automatically spawn tmux upon connection. ...

February 13, 2022 · 624 words · Thiago Perrotta

nix-shell in a nutshell

As soon as we finish installing Nix on Darwin, we’re greeted with a call to action: Alright! We're done! Try it! Open a new terminal, and type: $ nix-shell -p nix-info --run "nix-info -m" Thank you for using this installer. If you have any feedback or need help, don't hesitate: You can open an issue at https://github.com/nixos/nix/issues ...

February 10, 2022 · 395 words · Thiago Perrotta

Doas: bridging the sudo gap

doas is a lightweight and safer replacement for sudo. In most occasions you invoke it exactly like sudo: $ sudo apt install <foo> $ doas apt install <foo> doas has gained popularity recently. Besides being the default in OpenBSD, Alpine Linux 3.15 (released last year) has also switched to it: doas is the default temporary privilege escalation tool. You are advised to migrate from sudo to doas as 3.15 will be the last release to support sudo throughout its full lifecycle, in 3.16 sudo will be moved from main to community. It’s not very difficult to get used to it, however you may still find yourself writing sudo occasionally. This post highlights a few ways to bridge that gap. ...

February 7, 2022 · 412 words · Thiago Perrotta

Transfer bash history to zsh

After years of using bash as my default interactive shell at $DAYJOB, I decided to switch to zsh. I didn’t want to start from scratch and lose all my history though: $ wc -l ~/.bash_history | cut -f1 -d' ' 64002 Thus my goal was to first migrate all my history from bash to zsh. ...

February 4, 2022 · 208 words · Thiago Perrotta

Linux swap shenanigans

In this post we will cover a few linux swap recipes. ...

February 1, 2022 · 544 words · Thiago Perrotta