Linux is an incredible (and FREE) way to run a powerful, yet low-resource, operating system. For a long time, my personal laptop was running Canonical's Ubuntu. Ubuntu is a great way to get started with Linux— in fact it's one of the more bloated Linux distributions. It comes with a decent amount of built-in utilities and software. Still, the Ubuntu system processes use far less memory and run way faster than Windows 10— especially on my old laptop with 4GB of RAM.
It can be fun (though sometimes stressful) to "distro-hop"— spending time on one OS before installing another. For a long time, I had been using the Regolith distro. Under the hood, this is a pre-configured Ubuntu system with the i3 tiling window manager installed.
Now that I'm an adult with a job, I've delved into the realm of fancy Apple hardware. Though I still miss my Linux setup sometimes, I'm using AeroSpace (an i3 clone) for window tiling on Mac OS.
Terminals
My favorite thing about Mac OS is that it's Unix-based. And my favorite part about Unix-based systems is that they are pretty indistinguishable from Linux when it comes to the command line.
Professionally and recreationally, I spend a lot of time in the terminal. I use it to run scripts, manage servers, write code, and even pick my playlist. I like the immersion of having all my tools in the same, familiar place.
In addition to the desktop tiling, I multi-task in TMux — a terminal "multiplexer". I edit/write in Vim (actually, now Neovim ).
I'll link to my various dotfile setups and resources for setting up a great local development environment in the terminal. If you want to find other cool command line tools and tricks, I recommend checking out the r/commandline subreddit. I'm always finding neat new things to play with there.
BASH
The BASH, or "bourne-again " shell, is a classic and feature-full shell. These days, I'm actually more often using ZSH with Oh My Zsh! . The items below aren't always up-to-date, but I'll try to keep my public dotfiles repository current.
Emacs vs. Vi modes
Two options that can be set using the set command that will be of some interest to the common user are "-o vi" and "-o emacs". As with all of the environment modifying commands these can be typed at the command prompt or inserted into the appropriate file mentioned above.
Emacs Mode
set -o emacs
- This is usually the default editing mode when in the bash environment and means that you are able to use commands like those in Emacs (defined in the Readline library) to move the cursor, cut and paste text, or undo editing.
- Commands to take advantage of bash's Emacs Mode:
ctrl-a
Move cursor to beginning of linectrl-e
Move cursor to end of linemeta-b
Move cursor back one wordmeta-f
Move cursor forward one wordctrl-w
Cut the last wordctrl-u
Cut everything before the cursorctrl-k
Cut everything after the cursorctrl-y
Paste the last thing to be cutctrl-_
Undo
- NOTE:
ctrl-
= hold control,meta-
= hold meta (where meta is usually the alt or escape key). - A combination of
ctrl-u
to cut the line combined withctrl-y
can be very helpful. If you are in middle of typing a command and need to return to the prompt to retrieve more information you can usectrl-u
to save what you have typed in and after you retrieve the needed informationctrl-y
will recover what was cut.
Vi Mode
set -o vi
- Vi mode allows for the use of
vi
like commands when at the bash prompt. When set to this mode initially you will be in insert mode (be able to type at the prompt unlike when you entervi
). Hitting the escape key takes you into command mode. - Commands to take advantage of bash's Vi Mode:
h
Move cursor leftl
Move cursor rightA
Move cursor to end of line and put in insert mode0
(zero) Move cursor to beginning of line (doesn't put in insert mode)i
Put into insert mode at current positiona
Put into insert mode after current positiondd
Delete line (saved for pasting)D
Delete text after current cursor position (saved for pasting)p
Paste text that was deletedj
Move up through history commandsk
Move down through history commandsu
Undo
One thing I like in ZSH, is the zsh-vi-mode plugin. It allows you to use Vi visual mode on the ZSH command line— without bringing up the full-fledged Vi editor.
Pretty Bash Prompts
RCol='\033[0m'
Gre='\033[32m'
Red='\033[31m'
Blu='\033[34m'
Yel='\033[33m'
PS1="${RCol}┌─[\`if [ \$? = 0 ]; then echo "${Gre}"; else echo "${Red}"; fi\`\T\[${Rcol}\] \[${Blu}\]\u@\h\[${RCol}\] \[${Yel}\]\w\[${RCol}\]\$(__git_ps1)]\n└───▶ "
I don't use it personally, but my coworkers love the Starship prompt. It's a cross-shell prompt that works with BASH, ZSH, Fish, and more. It has a lot of features and is highly customizable.
Handy Aliases
Local HTTP Server
For a simple— Node.js-powered— HTTP server, I recommend browser-sync
. It has a watch feature to auto-refresh the browser if it detects changes. Setup a shell alias to run the longer command by simply typing serve
.
npm install -g browser-sync
# If using a virtual environment (or WSL), you can set your local IP address to the "host" argument like so:
export ip4=$(ifdata -pa wlp2s0)
# Set the full command to an alias (in your ~/.bashrc) for ease-of-use:
alias serve="browser-sync start -s -f . --no-notify --extensions 'html' --host $ip4 --port 9000"
For a simple (Python-powered) server, you can alias the python3
command:
# Run the HTTP server on port 80
alias serve="python3 -m http.server"
Terminal Multiplexer
I use TMux for shell session management and organization. Tmux is a "terminal multiplexer"— basically, it allows you to run multiple terminal sessions in resizable panes within a single terminal window. You can also detach and reattach to sessions, useful if you accidentally close a shell! Here are some useful aliases for TMux:
alias td="tmux detach"
alias t0="tmux attach -t 0"
alias t1="tmux attach -t 1"
alias t2="tmux attach -t 2"
alias tmain="tmux attach -t main"
FFMpeg
If you're working with video files, you might want to use FFMpeg . It's a powerful command-line tool for processing video and audio files. Here are some useful aliases for FFMpeg:
# Make a video from a folder of PNG frames
alias mkvid="ffmpeg -r 1 -f image2 -pattern_type glob -i "*.png" -vf scale=720:480 -filter:v "crop=in_w:480" -vcodec libx264 -crf 0 -pix_fmt yuv444p test.mp4"
# Convert an mp4 video to GIF format
alias convgif="ffmpeg -i test.mp4 -vf scale=iw/2:ih/2 -f gif test.gif"
# Make a GIF from a folder of images
function mkgif() {
ffmpeg -pattern_type glob -r 1 -i "$1" -vf "scale='min(640,iw)':'min(480,ih)':force_original_aspect_ratio=decrease,pad=640:480:(ow-iw)/2:(oh-ih)/2" -pix_fmt yuv420p -f gif output.gif
}
export -f mkgif
Another tool I found, gifski , makes it easier to get good results— but it requires Rust to install.
Low-Quality Image Placeholders (LQIP)
- Must install GO
- Uses the primitive command-line utility
function poly() {
if [ ${1##*.} != "gif" ]
then
primitive -i $1 -o lqip/${1%.*}-lqip.${1##*.} -r 64 -s 64 -bg 'avg' -n 150 -v
fi
if [ ${1##*.} = "gif" ]
then
convert "$1[0]" temp.gif
primitive -i temp.gif -o lqip/${1%.*}-lqip.jpg -bg 'avg' -r 64 -s 64 -n 150 -v
rm temp.gif
fi
}
export -f poly
polyAll () {
for image in *;
do
poly "$image"
done
}
export -f polyAll
Rofi Notes (RONO)
I don't use the Rofi launcher now that I'm on Mac OS, but I used to use it a lot on Linux. Rofi is a powerful and flexible application launcher that can be used to quickly access applications, files, and more.
Below is an example of how to customize Rofi for note-taking with Alacritty.
- Customization of Rofi Notes with Alacritty
- Save script as
rofi_notes.sh
to use with the i3 binding:
#!/usr/bin/env bash
while getopts ":a:e:l:o:" opt; do
case $opt in
a) AUTHOR="$OPTARG"
;;
e) EDITOR="$OPTARG"
;;
l) LOOK="$OPTARG"
;;
o) NOTES_FOLDER="$OPTARG"
;;
\?) echo "Invalid option -$OPTARG" >&2
;;
esac
done
if [[ ! -d "${NOTES_FOLDER}" ]]; then
mkdir -p "$NOTES_FOLDER"
fi
get_notes() {
ls "${NOTES_FOLDER}"
}
edit_note() {
note_location=$1
alacritty -t 'alacritty-floating' -e $EDITOR -c "${LOOK}" "$note_location"
}
delete_note() {
local note=$1
local action=$(echo -e "yes\nno" | rofi -dmenu -p "Are you sure you want to delete $note? ")
case $action in
"yes")
rm "$NOTES_FOLDER/$note"
main
;;
"no")
main
esac
}
note_context() {
local note=$1
local note_location="$NOTES_FOLDER/$note"
local action=$(echo -e "edit\ndelete" | rofi -dmenu -p "$note ")
case $action in
"edit")
edit_note "$note_location"
;;
"delete")
delete_note "$note"
esac
}
new_note() {
local title=$(echo -e "cancel" | rofi -dmenu -p "input title ")
case "$title" in
"cancel")
main
;;
*)
local file=$(echo "$title" | sed 's/ /_/g;s/\(.*\)/\L\1/g')
local template=$(cat <<- END
---
title: $title
date: $(date --rfc-3339=seconds)
author: $AUTHOR
---
# $title
END
)
note_location="$NOTES_FOLDER/$file.md"
if [ "$title" != "" ]; then
echo "$template" > "$note_location" | edit_note "$note_location"
fi
;;
esac
}
main() {
local all_notes="$(get_notes)"
local first_menu="NEW"
if [ "$all_notes" ];then
first_menu="NEW\n${all_notes}"
fi
local note=$(echo -e "$first_menu" | rofi -dmenu -p "notes ")
case $note in
"NEW")
new_note
;;
"")
;;
*)
note_context "$note"
esac
}
main
Browsers
Firefox
I've used Firefox as my primary browser, along with Chrome for work. I know its politics and policies have changed over the years, though. I still use it, but I'm also interested in Brave and other privacy-focused browsers.
Disable Keyboard Shortcuts
First, change the Firefox shortcut settings:
- In Firefox, navigate to
about:config
- Read through the disclaimer and click the "Accept the Risk and Continue" button
- Search for
permissions.default.shortcuts
and click the pencil icon to edit the value - Change the "0" to "2" to allow overriding existing shortcuts
Next, install the Shortkeys Firefox plugin:
- After installing, restart Firefox. Quit and re-open.
- Click the add-on puzzle piece icon and find "Manage extensions" at the bottom, click it.
- Click the gear icon to the right of the "Manage Your Extensions" heading.
- In the dropdown, click "Manage Extension Shortcuts"
- Scroll down the list to the Shortkeys extension and setup your shortcuts!
- I like
Cmd+,
andCmd+.
for navigating prev/next tab, respectively.
- I like
Editors
Vim
You can find my full .vimrc
here. However, I am now using Neovim
— it's a modern fork of Vim with many improvements. You can find my Neovim dotfiles here
.
Status lines
This is a configuration example for vim-airline
let g:airline_powerline_fonts=1
let g:airline#extensions#tabline#enabled=1
let g:airline_theme='luna'
You might also try Lightline
let g:lightline = {
\ 'colorscheme' : 'seoul256'
\ }
Other Nice Plugins
call plug#begin('~/.vim/plugged')
Plug 'vimwiki/vimwiki'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'edkolev/tmuxline.vim'
Plug 'junegunn/goyo.vim'
Plug 'scrooloose/nerdtree'
Plug 'inkarkat/vim-SpellCheck'
Plug 'inkarkat/vim-ingo-library'
Plug 'etdev/vim-hexcolor'
Plug 'chrisbra/Colorizer'
Plug 'junegunn/vim-emoji'
Plug 'vim-scripts/AutoComplPop'
call plug#end()
Colorschemes
Take a look at vim-colors for some awesome color schemes that will spruce up your edits.
VimWiki
let g:vimwiki_list = [{'path': '~/vimwiki/',
\ 'syntax': 'markdown',
\ 'template_path': '~/vimwiki/templates/',
\ 'template_default': 'default',
\ 'ext': '.md',
\ 'path_html': '/var/www/l-o-o-s-e-d/html/knowledge-base/',
\ 'custom_wiki2html': 'vimwiki_markdown',
\ 'template_ext': '.tpl'}]
Mobile
You must install scrcpy and connect your Android device to your computer with USB-debugging enabled .
alias android='scrcpy --max-size 1080 --window-x 1920 --window-y 1080 --window-borderless -S'
alias androidF='android --fullscreen'