UNIX
Dotfiles
I keep my dotfiles organize in a git repository using StreakyCobra’s method
To initialize a new dotfile repository use the following:
git init --bare $HOME/.dotfiles
alias cfg='git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'
cfg cfg --local status.showUntrackedFiles no
echo "alias cfg='git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'" >> $HOME/.bashrc
Now you can access dotfiles git commands from anywhere with:
cfg status
cfg add .vimrc -f
cfg commit -m 'Add vimrc'
cfg push
To restore the dotfiles to a new machine:
git clone --bare <git-repo-url> $HOME/.dotfiles
alias cfg='git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'
cfg checkout
Tips
- Stop a blocked SSH session with:
~.
Watch files for changes
Tail
We can see the output being written to a file by using the tail
command.
tail -f log/development.log
Guard
We can use guard to monitor source code files and compile them when we save the file.
To install it we can use gem:
gem install guard
gem install guard-shell
guard init shell
Then you can edit the Guardfile
to filter the files we want to check and perform any action we want. As an example, the following will check haskell files and compile them on save:
guard :shell do
watch /.*\.l?hs$/ do |m|
`runghc #{m[0]}`
end
end
}
Peat
Peat is an utility created by Steve Losh, and only depends on Python being installed. You can pipe any command to peat
and it will start watching them. If it detects any changes, the argument of peat will be executed:
find . -name hello.c | peat "make hello && ./hello"
Inotify
In Linux, we can use inotify
to watch for system changes and act accordingly. In this script you can watch all directories in the current path and execute whatever you pass it as an argument:
#!/bin/sh
# Depends on 'inotify-tools' package
FORMAT=$(echo -e "\033[1;33m%w%f\033[0m written")
"$@"
while inotifywait -qre close_write --format "$FORMAT" .
do
"$@"
done
Converting images for web performance
I like to rescale and bitcrush images for using on the web to reduce their size. You can always keep a high resolution image available for when you click on them. ImageMagick to the rescue!
convert src_img.jpg -resize 800 -dither FloydSteinberg -depth 3 -colors 5 dst_img.png
Transfering files using tar
We can use tar to copy files between different machines with ssh access without using rsync or scp:
ssh hostname tar -C sources/ -cz linux | pv | tar -xzv
Source: gemini://drewdevault.com/2022/02/17/tar-is-good-actually.gmi
Essential UNIX packages
Some packages necesary for a normal installation using my workflow, should be applicable for Linux, FreeBSD and macOS.
Development tools
- git: version control software
- zsh: my shell of choice
- tmux: terminal multiplexer
- vim/neovim: my text editor of choice
- ripgrep: blazing fast file search
- fzf: improved fuzzy search in command line
- hyperfine: benchmarks (optional)
- hexedit: hex file viewer TUI (optional)
- languagetool: grammar/syntax analysis
- valgrind: instrumentation/dynamic code analysis
- virtualbox/qemu/bhyve/virt-manager: virtualization
- pv (pipe viewer): monitor data progress through a pipeline
Programming languages
- c/c++ (gcc/clang/cmake/make/ninja/ctags/etc.)
- python/pip
- R
- rust
- golang
- haskell
- latex
- java/jdk/jrm/openjdk
- scheme (guile/chez/racket/chicken)
- mono
- nodejs/npm
Linux specific
- alsa
- pulseaudio/pavucontrol
Utilities
- sudo/doas: privilege scalation
- password-store: password manager
- nautilus: file manager
- nnn: file manager
- ranger: file manager
- htop: cpu/memory monitor
- gotop: cpu/memory monitor
- dropbox: cloud sync service
- skype: video calls
- zoom: video calls
- zathura/evince: pdf reader
- mendeley/zotero: pdf manager (want to swap to cmdline tools)
- Mutt/Neomutt/aerc: TUI mail readers.
- newsboat: rss newsreader
- obs: screen recorder/scene manager
- pandoc: text format converter
- rsync: copy/clone/sync utility
- samba: network shares
- sxiv/vimiv: image viewers
- surfraw: multiple search engine browser
- sc-im: NCurses spreadsheet (Chokes on big files)
- visidata: search, summarize, merge and plot csv files
- buku: bookmark manager from the command line
- dunst: Lightweight notification daemon
- pipe-viewer: Search youtube from the command line. Can play the videos using mpv and yt-dlt
Network analysis
- wireshark
- nmap
Web browsers
- Chromium
- Firefox
- Qutebrowser
- Lynx
- w3m
Xorg/Appearance
- xorg: classic graphics server
- nitrogen: background image loader
- freetype2: font rendering engine
- lxrandr: easier resolution change
- lxappearance: easier gtk style change
- iosevka: monospace font
- droid-fonts-ttf: essential fonts
- google-fonts: essential fonts
- font-amsfonts: essential fonts
- sierra-gtk-themes, adapta-gtk-themes, numix-gtk-themes: gtk-themes
- dzen2: custom volume bar increase/decrease
Window manager and related utils
- dwm: My windows manager of choice
- dmenu: Application and utility launcher
- st: My X terminal of choice
- slock: Simple screen lock utility
Other
- epy: CLI eBook reader
- blender
- gimp
- krita
- inkscape
- calibre