This is a growing (but eventually, hopefully, shrinking) collection of shell commands I periodically need but have to look up every time.

Grepping from the standard error

whatever_you_want_to_grep_on 2>&1 >/dev/null | grep whatever_you_want_to_grep

Scheduling a shutdown

At a specific time

shutdown hh:mm

After n minutes

shutdown +n

Sending desktop notifications

At a specific time

echo 'notify-send "notification text"' | at hh:mm

After n minutes, hours, days, or weeks

echo 'notify-send "notification text"' | at now + n unit

Making the notification more (or less) annoying

Use the -u flag:

notify-send "notification text" -u level # level: critical|normal|low

Spring cleaning

Cleaning the Yay package cache

yay -Scc

Cleaning up the pip package cache

pip cache purge

Removing unused Python virtualenvs

Use Herb’s heroic interactive one-liner:

for filename in $(find . -path '*/bin/activate.csh'); do filepath=$(echo $filename | sed 's/\/bin\/activate.csh//g'); echo "Remove $filepath? (y/n)" ; read result; if [[ $result = "y" ]]; then rm -R $filepath; fi; done

Copying files via ssh

Use scp, which is just like cp but can take path to remote machines as well. For example, to copy a local file to a remote host:

scp scp -r loxal/path hostname:remote/path

Text processing

Removing the diabolical non-unix newline characters

tr -d '\r'

Audio processing

Splitting a flac file into tracks based on a cue file

shnsplit -f path/to.cue -t %n-%t -o flac path/to.flac

This particular command assumes that the flac is an album and that the cue file contains the names of its tracks, which will be written to files named n-title.flac.

Configuring the i3 window manager

These are commands I only use when I edit the config file for my window manager, i3, but they definitely have other use cases as well.

Figuring out the ID of a key (aka keysym)

Run

xev | grep keysym

and then type something in the event window that will open. Every time you press a key, you will get some output like

state 0x2, keycode 133 (keysym 0xffeb, Super_L), same_screen YES,

(when you release the key, you will see a similar line with the same keysym again because xev detects two separate events, a KeyPress and a KeyRelease).

In this example, the keysym to use in the i3 config is Super_L (my left Windows key).

Figuring out the class of a desktop application

Open the application, run

xprop | grep WM_CLASS

and then click on the application window. The output will be something like

WM_CLASS(STRING) = "vscodium", "VSCodium"

where the class to be used in the i3 config is the second one, VSCodium.