Cheat sheet

This is a ever growing list of commands that I discovered while searching for quick ways for doing stuff on my computer. I use it as a reference more often then I would like :v.

Terminal

  • Temporarily disable sleep on lid close: systemd-inhibit --what=handle-lid-switch sleep 1d

Printer

  • Print file: lp -d EPSON_L3110_Series file
  • List printers: lpstat -p -d
  • CUPS server address: http://localhost:631/

Image processing

  • Add a few null bytes to the end of af file to change it's MD5 signature:
truncate -s +10 <yourfile>.<ext>
  • Cut black borders out of images:
mogrify -fuzz 4% -define trim:percent-background=0% -trim +repage -format jpg image.jpg
  • Downscale video to 720p:
ffmpeg -y -i "file.mp4" -vf "[in]scale=iw*min(480/iw\,320/ih):ih*min(480/iw\,320/ih)[scaled]; [scaled]pad=480:320:(480-iw*min(480/iw\,320/ih))/2:(320-ih*min(480/iw\,320/ih))/2[padded]; [padded]setsar=1:1[out]" -c:v libx264 -c:a copy "shrink.mp4"

Losseless gif:

  1. Generate pallete:
ffmpeg -y -i image.png -vf palettegen palette.png
  1. Generate lossless gif:
ffmpeg -y -i images.png -i palette.png -filter_complex paletteuse -r 10 file.gif

Emacs

  • Emacs learn on topic
  • M-<TAB> completion-at-point (with corfu)
  • M-y browse through kill ring
  • M-. go to definition

Emacs Repeating commands

  • C-x z repeat
  • C-x <ESC> <ESC> repeat-complex-command
  • C-x ( and C-x ) to record macro, C-x e to run it

Org

  • C-c . For inserting a plain timestamp
  • C-c C-s For inserting a schedule date
  • C-c C-d For inserting a deadline
  • With the cursor on the checkbox, C-c C-c for ticking it. C-c C-x C-b if your cursor is in the line of the tickbox.
  • C-c ' for editing the source code block
  • Insert source code blocks fast with (C-c C-,) (doesn't work for html)
  • org-toggle-link-display for showing literal links in org-mode

Marks

  • M-@ mark word
  • C-M-@ mark balanced expression
  • M-h mark to beginning of paragraph
  • C-M-h mark defun
  • C-x h mark to beginning of the buffer
  • C-u C-<SPC> to pop/move up a previous mark

(Custom) Movement

  • C-; char avy jumps to a word
  • C-: char avy jumps to a char
  • C-M-; char avy jumps to a char in the current line

Dired

  • R to rename single file, or move selected files
  • v for a quick view (read only mode), q to quit