Zsh
Welcome to my Zshrc. This configuration does not use any package managers or frameworks. This literate configuration is available online on my GitHub Pages. If you appreciate my work, please consider making a donation.
Table of Contents
Theme
This first block of code sets the $PATH
environment variable, and sources my $LS_COLORS
script from this project. I have a cross-compiler installed, and
that’s what those other variables are for.
# __ # ____ _____/ /_ __________ # /_ / / ___/ __ \/ ___/ ___/ # / /_(__ ) / / / / / /__ # /___/____/_/ /_/_/ \___/ export PATH=/sbin:$HOME/bin:$HOME/.emacs.d/bin:/usr/local/bin:$HOME/.local/bin:$HOME/.cargo/bin:/usr/local/go/bin:/usr/local/i386elfgcc/bin:$PATH export PREFIX="/usr/local/i386elfgcc" export TARGET=i386-elf #LSCOLORS=$LS_COLORS #ZLS_COLORS=$LS_COLORS if [ -v $TERM ]; then if [[ ${TERM} = "st-256color" || ${TERM} = "rxvt-unicode" || ${TERM} = "xterm-256color" || ${TERM} = "foot" || ${TERM} = "kitty" || ${TERM} = "alacritty" ]]; then export LS_COLORS="$(vivid generate snazzy)" else export LS_COLORS="$(vivid -m 8-bit generate snazzy)" fi else export LS_COLORS="$(vivid -m 8-bit generate snazzy)" fi export LSCOLORS=$LS_COLORS
Completion Styles
These are my styles for the various TAB-completion menus that appear in ZSH themes.
zstyle ':completion:*:*:kill:*' list-colors '=(#b) #([0-9]#)*( *[a-z])*=34=31=33' zstyle ':completion:*' use-cache on zstyle ':completion:' cache-path "$HOME/.cache/zsh/.zcompcache" zstyle ':completion:*:parameters' list-colors '=*=1;35' zstyle ':completion:*:builtins' list-colors '=*=1;34' zstyle ':completion:*:aliases' list-colors '=*=1;33' zstyle ':completion:*:*:*:*:descriptions' format '%F{yellow} %d %f' zstyle ':completion:*:warnings' format ' %F{red}no matches found %f' zstyle ':completion:*:options' list-colors '=^(-- *)=34' zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS} "ma=5;241;1" zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}'
Preferences
Set some preferences. Auto CD, and no duplicates in history.
export LANG=en_US.UTF-8 setopt auto_cd setopt appendhistory setopt hist_ignore_all_dups setopt hist_save_no_dups setopt hist_find_no_dups setopt hist_ignore_dups
Conditional Aliases
Determine if the shell is being loaded locally, or over SSH, and set aliases accordingly. The reason I do this is so I don’t strain the SSH connection with too many colors or icons. The shell should behave and feel differently.
SSH
# Preferred editor for local and remote sessions if [[ -n $SSH_CONNECTION ]]; then alias d="fd" alias c="/usr/bin/cat" alias cat="/usr/bin/cat" alias grep="/usr/bin/grep --color=auto" alias g="/usr/bin/grep --color=auto" alias gh="/usr/bin/grep --color=auto --context=4" else alias c="bat" alias cat="bat" alias d="fd" alias grep="rg" alias g="rg" alias gh="rg --context=4" alias reboot="loginctl reboot" alias xx="loginctl reboot" fi
Terminal
Here is where I check if the Zsh shell is being loaded in a graphical terminal, or an actual tty. If I change my terminal away from st, then I will have to modify this part. Nerd Font icons do not render in the tty, so we should use the standard versions of fancy programs in that context.
All of these ls
commands have flags to show directories first, show human-readable file sizes, and show file symbols. All of the exa
commands show icons and group directories first, also.
Command | In Terminal | In TTY |
---|---|---|
ls |
Regular LSD listing | Regular LS listing |
l |
Regular LSD listing | Regular LS listing |
la |
Long listing with total directory sizes, all files | LS long listing, all files |
ll |
LSD Long listing with total sizes, all files | LS long listing, all files |
lc |
LSD Long listing with total sizes | N/A |
lct |
LSD Long listing with total sizes and tree | N/A |
lctl |
LSD Long listing with total sizes and tree | N/A |
lsl |
Long listing, all files | LS long listing, all files |
lsa |
Long listing, all files | LS long listing, all files |
lsla |
Long listing with total sizes, all files | LS long listing, all files |
lst |
LSD listing with tree | N/A |
lstl |
LSD long listing with tree | N/A |
ltl |
LSD long listing with total sizes and tree | N/A |
a |
Regular Exa listing | Same, without icons |
al |
Exa long listing, all files | Same, without icons |
aa |
Exa long listing, all files | Same, without icons |
at |
Exa listing with tree | Same |
atl |
Exa long listing with tree | Same |
alt |
Exa long listing with tree | Same |
ac |
Exa listing sorted by time modified | Same |
acl |
Exa long listing sorted by time | Same |
aca |
Exa long listing sorted by time | Same |
act |
Exa listing with tree, sorted by time | Same |
atc |
Exa listing with tree, sorted by time | Same |
aclt |
Exa long listing with tree, by time | Same |
atlc |
Exa long listing with tree, by time | Same |
e |
Opens new Emacs window | Opens Emacs in Console |
ez |
Edit zsh.org in new Emacs window | Edit zsh.org in Console |
eb |
Edit bspwm.org in new Emacs window | Edit bspwm.org in Console |
ep |
Edit Polybar config in new Emacs window | Edit Polybar in Console |
eq |
Edit Qutebrowser config in new Emacs window | Edit Qutebrowser in Console |
ec |
Edit init.org in new Emacs window | Edit init.org in Console |
ed |
Edit config.org in new Emacs window | Edit config.org in Console |
ew |
Edit Waybar config in new Emacs window | Edit Waybar in Console |
es |
Edit Waybar style.org in new Emacs window | Edit style.org in Console |
ef |
Edit foot.org in new Emacs window | Edit foot.org in Console |
egp |
Run Magit Push on repository inside Emacs | Run Magit Push in Console |
egs |
Run Magit Status on repository inside Emacs | Run Magit Status in Console |
ei |
Run Magit Log on repository inside Emacs | Run Magit Log in Console |
egl |
Run Magit Log on repository inside Emacs | Run Magit Log in Console |
ee |
Open current directory in Dired in Emacs | Open current directory in Console |
er |
Open Elfeed in Emacs | N/A |
j |
Open NNN file browser | N/A |
me |
Open webcam image in MPV in Wayland | N/A |
mx |
Open webcam image in MPV in X.org | N/A |
if [ -v TERM ]; then if [[ ${TERM} = "st-256color" || ${TERM} = "rxvt-unicode" || ${TERM} = "xterm-256color" || ${TERM} = "foot" || ${TERM} = "alacritty" || ${TERM} = "kitty" ]]; then alias ls="lsd --config-file=\"$HOME/.config/lsd/config.yml\"" alias l="lsd --config-file=\"$HOME/.config/lsd/config.yml\"" alias lsla="lsd --config-file=\"$HOME/.config/lsd/config.yml\" -l -A -t" alias la="lsd --config-file=\"$HOME/.config/lsd/config.yml\" -l -A -t" alias ll="lsd --config-file=\"$HOME/.config/lsd/config.yml\" -l -A -t" alias lsl="lsd --config-file=\"$HOME/.config/lsd/config.yml\" -l -A" alias lsa="lsd --config-file=\"$HOME/.config/lsd/config.yml\" -l -A" alias lst="lsd --config-file=\"$HOME/.config/lsd/config.yml\" --tree" alias lstl="lsd --config-file=\"$HOME/.config/lsd/config.yml\" -l -A --tree" alias ltl="lsd --config-file=\"$HOME/.config/lsd/config.yml\" -l -A -t --tree" alias lc="lsd --config-file=\"$HOME/.config/lsd/config.yml\" -l -A --total-size" alias lct="lsd --config-file=\"$HOME/.config/lsd/config.yml\" -l -A --total-size --tree" alias lctl="lsd --config-file=\"$HOME/.config/lsd/config.yml\" -l -A --total-size --tree -t" alias a="exa --icons --group-directories-first -F" alias al="exa --icons --group-directories-first --git --color-scale -F -h -l -a" alias aa="exa --icons --group-directories-first --git --color-scale -F -h -l -a" alias at="exa --icons --group-directories-first -F --tree -L 3" alias atl="exa --icons --group-directories-first --git --color-scale -F --tree -L 3 -h -l -a" alias alt="exa --icons --group-directories-first --git --color-scale -F --tree -L 3 -h -l -a" alias ac="exa --icons --group-directories-first -F -s time -r" alias acl="exa --icons --group-directories-first --git --color-scale -F -h -l -a -s time -r" alias aca="exa --icons --group-directories-first --git --color-scale -F -h -l -a -s time -r" alias act="exa --icons --group-directories-first -F --tree -L 3 -s time -r" alias atc="exa --icons --group-directories-first -F --tree -L 3 -s time -r" alias aclt="exa --icons --group-directories-first --git --color-scale -F -h -l -a --tree -L 3 -s time -r" alias atlc="exa --icons --group-directories-first --git --color-scale -F -h -l -a --tree -L 3 -s time -r" alias e="riverctl set-focused-tags 8 2> /dev/null; hyprctl dispatch workspace 4 2> /dev/null; emacsclient -c -a 'emacs' -q" alias ee="riverctl set-focused-tags 8 2> /dev/null; hyprctl dispatch workspace 4 2> /dev/null; emacsclient -c -a 'emacs' -q ." alias ez="riverctl set-focused-tags 8 2> /dev/null; hyprctl dispatch workspace 4 2> /dev/null; emacsclient -c -a 'emacs' -q \"$HOME/.zsh.org\"" alias eb="riverctl set-focused-tags 8 2> /dev/null; hyprctl dispatch workspace 4 2> /dev/null; emacsclient -c -a 'emacs' -q \"$HOME/.config/bspwm/bspwm.org\"" alias ep="riverctl set-focused-tags 8 2> /dev/null; hyprctl dispatch workspace 4 2> /dev/null; emacsclient -c -a 'emacs' -q \"$HOME/.config/polybar/config.org\"" alias eq="riverctl set-focused-tags 8 2> /dev/null; hyprctl dispatch workspace 4 2> /dev/null; emacsclient -c -a 'emacs' -q \"$HOME/.config/qutebrowser/config.org\"" alias ec="riverctl set-focused-tags 8 2> /dev/null; hyprctl dispatch workspace 4 2> /dev/null; emacsclient -c -a 'emacs' -q \"$HOME/.doom.d/init.org\"" alias ed="riverctl set-focused-tags 8 2> /dev/null; hyprctl dispatch workspace 4 2> /dev/null; emacsclient -c -a 'emacs' -q \"$HOME/.doom.d/config.org\"" alias ew="riverctl set-focused-tags 8 2> /dev/null; hyprctl dispatch workspace 4 2> /dev/null; emacsclient -c -a 'emacs' -q \"$HOME/.config/waybar/config.org\"" alias es="riverctl set-focused-tags 8 2> /dev/null; hyprctl dispatch workspace 4 2> /dev/null; emacsclient -c -a 'emacs' -q \"$HOME/.config/waybar/style.org\"" alias ef="riverctl set-focused-tags 8 2> /dev/null; hyprctl dispatch workspace 4 2> /dev/null; emacsclient -c -a 'emacs' -q \"$HOME/.config/foot/foot.org\"" alias egp="riverctl set-focused-tags 8 2> /dev/null; hyprctl dispatch workspace 4 2> /dev/null; emacsclient -c -a 'emacs' -q --eval \"(magit-push)\" > /dev/null" alias egs="riverctl set-focused-tags 8 2> /dev/null; hyprctl dispatch workspace 4 2> /dev/null; emacsclient -c -a 'emacs' -q --eval \"(magit-status)\" > /dev/null" alias ei="riverctl set-focused-tags 8 2> /dev/null; hyprctl dispatch workspace 4 2> /dev/null; emacsclient -c -a 'emacs' -q --eval \"(magit-log-all)\" > /dev/null" alias egl="riverctl set-focused-tags 8 2> /dev/null; hyprctl dispatch workspace 4 2> /dev/null; emacsclient -c -a 'emacs' -q --eval \"(magit-log-all)\" > /dev/null" alias er="riverctl set-focused-tags 8 2> /dev/null; hyprctl dispatch workspace 4 2> /dev/null; emacsclient -c -a 'emacs' -q --eval \"(elfeed)\" > /dev/null" alias mx="mpv av://v4l2:/dev/video0 --vo=gpu --hwdec=vaapi --untimed --profile=low-latency --no-osc" alias mo="mpv av://v4l2:/dev/video2 --vo=gpu --hwdec=vaapi --untimed --profile=low-latency --no-osc" alias me="mpv av://v4l2:/dev/video2 --untimed --profile=low-latency --no-osc" alias mj="mpv av://v4l2:/dev/video0 --untimed --profile=low-latency --no-osc" alias jt="tmux new-session \"export NNN_FIFO=/tmp/nnn.fifo; export NNN_PLUG='p:preview-tui'; nnn -d -i -l 2 -H -G -U -R -Q -D -P preview-tui\"" elif [[ ${TERM} = "screen-256color" ]]; then alias j="nnn -d -i -l 2 -H -G -U -R -Q -D -P preview-tui & ~/.config/nnn/plugins/preview-tui; fg" else alias ls="ls --group-directories-first -F --color=auto" alias lsla="ls -l -A -h --group-directories-first -F --color=auto" alias l="ls --group-directories-first -F --color=auto" alias lsl="ls -l -A -h --group-directories-first -F --color=auto" alias la="ls -l -A -h --group-directories-first -F --color=auto" alias ll="ls -l -A -h --group-directories-first -F --color=auto" alias a="exa --group-directories-first -F" alias al="exa --group-directories-first --git -F -h -l -a" alias aa="exa --group-directories-first --git -F -h -l -a" alias at="exa --group-directories-first -F --tree -L 3" alias atl="exa --group-directories-first --git -F --tree -L 3 -h -l -a" alias alt="exa --group-directories-first --git -F --tree -L 3 -h -l -a" alias ac="exa --group-directories-first -F -s time -r" alias acl="exa --group-directories-first --git -F -h -l -a -s time -r" alias aca="exa --group-directories-first --git -F -h -l -a -s time -r" alias act="exa --group-directories-first -F --tree -L 3 -s time -r" alias atc="exa --group-directories-first -F --tree -L 3 -s time -r" alias aclt="exa --group-directories-first --git -F -h -l -a --tree -L 3 -s time -r" alias atlc="exa --group-directories-first --git -F -h -l -a --tree -L 3 -s time -r" alias e="emacsclient -c -a 'emacs' -nw" alias ee="emacsclient -c -a 'emacs' -nw ." alias ez="emacsclient -c -a 'emacs' -nw \"$HOME/.zsh.org\"" alias eb="emacsclient -c -a 'emacs' -nw \"$HOME/.config/bspwm/bspwm.org\"" alias ep="emacsclient -c -a 'emacs' -nw \"$HOME/.config/polybar/config.org\"" alias eq="emacsclient -c -a 'emacs' -nw \"$HOME/.config/qutebrowser/config.org\"" alias ec="emacsclient -c -a 'emacs' -nw \"$HOME/.doom.d/init.org\"" alias ed="emacsclient -c -a 'emacs' -nw \"$HOME/.doom.d/config.org\"" alias ew="emacsclient -c -a 'emacs' -nw \"$HOME/.config/waybar/config.org\"" alias es="emacsclient -c -a 'emacs' -nw \"$HOME/.config/waybar/style.org\"" alias ef="emacsclient -c -a 'emacs' -nw \"$HOME/.config/foot/foot.org\"" alias egp="emacsclient -c -a 'emacs' -nw --eval \"(magit-push)\"" alias egs="emacsclient -c -a 'emacs' -nw --eval \"(magit-status)\"" alias ei="emacsclient -c -a 'emacs' -nw --eval \"(magit-log-all)\"" alias egl="emacsclient -c -a 'emacs' -nw --eval \"(magit-log-all)\"" fi fi
Functions
picp
I used to use this function to send files to my Raspberry Pi.
function picp() { if [ -z "$1" ]; then printf "picp needs an argument\n" false else scp -i ~/.ssh/laptop2pi "$1" pi@192.168.0.24:~ true fi }
pf
This function searches the list of running processes provided with ps
and returns a match.
function pf() { if [ -z "$1" ]; then printf "pf needs a process name to search for\n" false else ps -aux | rg "$1" fi }
t
This function, when given no arguments, simply starts the tremc
Transmission client. If it is given a single argument, it is assumed it is a torrent file: it gives it to Transmission, then deletes it, and starts tremc
.
If it is given a second argument, it interprets that as the preferred download speed in kB/s.
function t() { if [ -z "$1" ]; then tremc true elif [ -z "$2" ]; then printf "Starting %s...\n" "$1" tremc "$1" > /dev/null rm "$1" 2> /dev/null tremc true elif [ -z "$3" ]; then printf "Starting %s with speed %s kbps...\n" "$1" "$2" tremc "$1" > /dev/null transmission-remote -asd "$2" rm "$1" 2> /dev/null tremc true else printf "Too many arguments\n" > /dev/stderr false fi }
y
Open a file with mupdf.
function y() { if [ -z "$1" ]; then printf "Please specify file to read\n" false else mupdf -I "$1" fi }
scr
Take a screenshot with the given name.
function scr() { if [ -z "$1" ]; then printf "Please specify output filename\n" > /dev/stderr false else scrot -z -p -q 90 "$1" notify-send "Screenshot saved" "$1" fi }
xs
Compile a project with xbps-src
from within the build directory. This is useful, and easier than typing “make”, or changing directory to run the
build script. It requires the package name (therefore, part of the current directory’s name) as an argument.
function xs() { cd ../../.. ./xbps-src build -C -f "$1" cd $OLDPWD }
j
A wrapper function for nnn that changes CD when it exits.
j() { # Block nesting of nnn in subshells if [[ "${NNNLVL:-0}" -ge 1 ]]; then echo "nnn is already running" return fi export NNN_TMPFILE="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.lastd" \nnn -d -i -l 2 -GUHRQD "$@" if [ -f "$NNN_TMPFILE" ]; then . "$NNN_TMPFILE" rm -f "$NNN_TMPFILE" > /dev/null fi }
wb
Set the wallpaper with two images, one for the left, and one for the right.
function wb() { swaybg -o eDP-1 -i "$1" -o HDMI-A-2 -i "$2" }
Backup Website
This shell function backs up my website. It takes one argument, the output directory to store the backup in.
function backup() { if [ -z "$1" ]; then printf "Please specify directory to store backup in\n" > /dev/stderr false else sudo rsync -Pa -e "ssh -p 2222 -i $HOME/.ssh/tbcom_ssh" tababcock@198.23.51.224:/home/www/tannerbabcock.com "$1" true fi }
Twitch
function twitch() { /home/babkock/git/twitch-chat-cli/cli.js connect babkock }
Mount External Encrypted Drive
My external encrypted hard drive is automatically mounted on boot, but this is how to mount it manually.
function mm() { sudo cryptsetup luksOpen /dev/sda mega sudo mount -o rw,users /dev/mapper/mega /mnt/mega sudo chown -R babkock:babkock /mnt/mega sudo chown babkock:audio /mnt/mega sudo chown -R babkock:audio /mnt/mega/Music echo "sda Mounted" }
Unmount External Encrypted Drive
This is how to unmount that drive.
function um() { sudo umount /mnt/mega sudo cryptsetup luksClose mega echo "sda Unmounted" }
SSH Agent
I have to do this every time I use Git, or log in to my website.
function b() { pkill -x ssh-agent eval $(ssh-agent) > /dev/null 2>&1 ssh-add "$HOME/.ssh/gitlab_rsa" ssh-add "$HOME/.ssh/github_rsa" ssh-add "$HOME/.ssh/tbcom_ssh" }
Aliases
This is my collection of aliases. Each letter of the alphabet should have its own command, to make the overall way of life easier.
This was apparent before, but I use a number of tools written in Rust that serve as faster and better-looking versions of standard
commands, like duf for df
, lsd for ls
, and ripgrep for grep
. These commands look different, but behave exactly the same as
the GNU coreutils they’re modeled after. These projects are worth checking out.
Command | Arguments | What It Does |
---|---|---|
ba |
N/A | Snow 5-day forecast in Denver |
bb |
N/A | Run neofetch with fancy bars |
c |
N/A | Run btm task manager |
ca |
File name | Run Bat on given files |
cd |
Directory | Run Zoxide on given directory |
co |
N/A | Run Conky |
d |
N/A | Run fd Find |
dcr |
File name | Decrypt given file with GNUPG |
df |
N/A | Run duf |
e |
File name or directory | Open given file or directory in Emacs |
f |
N/A | A file picker with preview pane |
g |
Pattern, file name | Run Ripgrep with given pattern on file |
ga |
File name | Add given file to staging area |
gb |
N/A | Run onefetch with fancy colors |
gc |
Branch | Check out branch on Git repository |
gd |
File name | Run Git diff on given file |
ge |
N/A | Git Fetch All |
gf |
File name | Check out given file from HEAD, reverting changes |
ggo |
N/A | Returns URL for repo’s origin |
ggu |
N/A | Returns URL for repo’s upstream |
gh |
Pattern, file name | Run Ripgrep with context with given pattern on file |
gl |
N/A | Run Git log |
gm |
File name, file name | Move or rename file and add to staging area |
gp |
Options | GNUPG |
gpull |
N/A | Git Pull Origin master |
gpulm |
N/A | Git Pull Origin main |
gpush |
N/A | Git Push Origin master |
gpusm |
N/A | Git Push Origin main |
gpash |
N/A | Git Push All master |
gpasm |
N/A | Git Push All main |
gr |
File name | Delete file from staging area |
grc |
File name | Delete file from staging area |
gs |
N/A | Run Git show |
gso |
URL | Set URL for repo’s origin |
gsu |
URL | Set URL for repo’s upstream |
h |
N/A | Run Htop |
i |
N/A | Run Tig Git client |
k |
N/A | Make |
kc |
N/A | Make clean |
m |
File name | Open given file in MPV |
mb |
N/A | Mount Baby blue drive |
md |
N/A | Mount External SSD |
mn |
Man page | Man |
n |
N/A | Run Ncmpcpp |
nb |
N/A | Nix Build |
ncr |
File name | Encrypt given file with GNUPG |
ne |
N/A | Run Ncmpcpp with Ueberzug |
nfi |
N/A | Nix Flake Init |
nfm |
N/A | Nix Flake Metadata |
o |
Process name | Kill the given process |
p |
N/A | Run Flowtop |
po |
N/A | Run Gotop |
q |
File name | Open given file in Feh |
qw |
N/A | Open current directory in SXIV |
r |
Directory | Run Ranger on given or current directory |
s |
N/A | Log in to my website via SSH |
se |
N/A | Restart Emacs Server |
sl |
N/A | Restart Waybar for LabWC |
sp |
N/A | Restart Pulseaudio |
sr |
N/A | Restart Waybar for River |
sw |
N/A | Restart Waybar for Sway |
sy |
N/A | Restart Waybar for Hyprland |
ta |
File name | Extract given Tar archive |
td |
Output file, files | Compress files into given output Tar archive |
ti |
N/A | List Transmission torrents |
tr |
Options | Transmission-remote |
ts |
N/A | Transmission Information |
tt |
N/A | Transmission Statistics |
u |
PID | Kill |
ub |
N/A | Unmount Baby blue drive |
ud |
N/A | Unmount External SSD |
v |
File name | Open given file in Vim |
vm |
N/A | Run Virt-Manager |
wh |
Command, alias, function | Which |
x |
N/A | Start Zsh as Root |
xx |
N/A | Reboot system immediately |
y |
File name | Open given file in MuPDF |
z |
Directory | Run Zoxide on given directory |
alias ba="ansiweather -l \"Denver\" -u imperial -H true -h false -p false -i false -s true -f 4" alias bb="neofetch --disk_display bar --memory_display bar --battery_display bar --bar_length 20 --underline off --bar_colors 30 210" alias co="btm" alias c="bat" alias df="duf" alias f="fzf --preview=\"bat --color=always --style=plain {}\" --preview-window=\"border:rounded\" --border=rounded --prompt=\"$ \" --pointer=\"->\"" alias i="tig" alias h="htop" alias ncr="gpg --encrypt --armor -r Tanner" alias dcr="gpg --decrypt" alias g="rg" alias gh="rg --context=4" alias gb="onefetch --no-color-palette -d head dependencies --text-colors 7 9 1 10 1 4" alias gp="gpg" alias gs="git status -sb" alias ga="git add" alias ge="git fetch --all" alias gf="git checkout HEAD --" alias gcm="git commit -m" alias gc="git checkout" alias gcb="git checkout -b" alias gd="git diff" alias gl="git log --date=relative --graph --pretty=format:'%Cred%h%Creset -%C(auto)%d%Creset %s %C(yellow)(%cr) %C(bold blue) %an%Creset'" alias gw="git show" alias gr="git rm" alias grc="git rm --cached" alias gm="git mv" alias ggo="git remote get-url origin" alias gso="git remote set-url origin" alias ggu="git remote get-url upstream" alias gsu="git remote set-url upstream" alias gpush="git push origin master" alias gpull="git pull origin master" alias gpusm="git push origin main" alias gpulm="git pull origin main" alias gpash="git push all master; git pull origin master; git pull upstream master" alias gpasm="git push all main; git pull origin main; git pull upstream main" alias v="vim" alias vm="virt-manager" alias r="ranger" alias m="mpv" alias mb="sudo mount /dev/sdb1 /mnt/Baby; echo 'sdb Mounted'" alias md="sudo mount /dev/sdb1 /mnt/drive; echo 'sdb Mounted'" alias mn="man" alias tl="tldr" alias n="ncmpcpp" alias ne="$HOME/.ncmpcpp/ncmpcpp-ueberzug/ncmpcpp-ueberzug" alias nb="nix build --extra-experimental-features nix-command --extra-experimental-features flakes" alias nfi="nix flake --extra-experimental-features nix-command --extra-experimental-features flakes init" alias nfm="nix flake --extra-experimental-features nix-command --extra-experimental-features flakes metadata" alias nfc="nix show-config --extra-experimental-features nix-command" alias nsh="nix-shell" alias nr="nix repl" alias o="pkill -x" alias u="kill" alias po="gotop" alias p="sudo flowtop -46UTDISs -t 2" alias q="feh" alias qw="nsxiv ." alias s="ssh tababcock@198.23.51.224 -p 2222" alias se="pkill -x emacs; emacs --daemon" alias sp="pkill -x pulseaudio; pulseaudio --start" alias sr="pkill -x waybar; waybar -c '$HOME/.config/waybar/rconfig.json' -s '$HOME/.config/waybar/river.css' &" alias sw="pkill -x waybar; waybar -c '$HOME/.config/waybar/config.json' &" alias sl="pkill -x waybar; waybar -c '$HOME/.config/waybar/lconfig.json' -s '$HOME/.config/waybar/labwc.css' &" alias sy="pkill -x waybar; waybar -c '$HOME/.config/waybar/hconfig.json' -s '$HOME/.config/waybar/hyprland.css' &" alias ta="tar xvf" alias td="tar czf" alias ti="transmission-remote -l" alias ts="transmission-remote -si" alias tt="transmission-remote -st" alias tr="transmission-remote" alias ub="sudo umount /mnt/Baby; echo Unmounted" alias ud="sudo umount /mnt/drive; echo Unmounted" alias k="make" alias kc="make clean" alias wh="which" alias x="sudo zsh"
Plugins
I use the following shell plug-ins, which are loaded from the ~/.zsh
directory.
- Typewritten theme
- zsh-syntax-highlighting
- zsh-history-substring-search
- zsh-autosuggestions
- zsh-completions
- zsh-fzf-history-search
- zsh-nix-shell
- nix-zsh-completions
- you-should-use
fpath+=$HOME/.zsh/typewritten fpath+=$HOME/.zsh/nix-zsh-completions fpath+=$HOME/.zsh/zsh-completions/src autoload -U compinit; compinit autoload -U promptinit; promptinit prompt typewritten source /home/babkock/.zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh source /home/babkock/.zsh/zsh-history-substring-search/zsh-history-substring-search.zsh export HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND="" export HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND="" source /home/babkock/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh source /home/babkock/.zsh/zsh-autopair/autopair.zsh source /home/babkock/.zsh/zsh-fzf-history-search/zsh-fzf-history-search.zsh source /home/babkock/.zsh/zsh-nix-shell/nix-shell.plugin.zsh source /home/babkock/.zsh/you-should-use/you-should-use.plugin.zsh source /home/babkock/.zsh/completion.zsh source /home/babkock/.zsh/nix-zsh-completions/nix-zsh-completions.plugin.zsh source /home/babkock/.zsh/correction.zsh source /home/babkock/.zsh/history.zsh source /home/babkock/.zsh/colored-man-pages.plugin.zsh
Keybindings
Add more keybindings to the completion menu, history substring search on up and down arrows, and undo/redo functionality.
bindkey -M menuselect '^[[Z' reverse-menu-complete # Shift+Tab bindkey -M menuselect '^[[27;2;13~' accept-and-hold # Shift+Enter bindkey -M menuselect '^{' clear-screen # Escape bindkey -M menuselect '^[[A' vi-up-line-or-history bindkey -M menuselect '^[[B' vi-down-line-or-history bindkey -M menuselect '^[[D' vi-backward-char bindkey -M menuselect '^[[C' vi-forward-char bindkey -M menuselect '^[[1;2D' beginning-of-buffer-or-history # Shift+Left Arrow bindkey -M menuselect '^[[1;2C' end-of-buffer-or-history # Shift+Right Arrow bindkey -M main '^[[A' history-substring-search-up bindkey -M main '^[[B' history-substring-search-down bindkey -M main '^Z' undo # Control+Z bindkey -M main '^Y' redo # Control+Y
Environment Variables
These next lines accomplish a few things. They let me use directory-changers like nnn and Zoxide, and configure the programs bat, fzf, and wob.
export GPG_TTY=$(tty) gpgconf --launch gpg-agent export EDITOR=vim export NNN_FIFO=/tmp/nnn.fifo export NNN_PLUG="p:-preview-tui;v:imgview;g:!tig*;v:!vim" export NNN_COLORS="2365" export BAT_STYLE="header,header-filesize,header-filename,changes" export FZF_DEFAULT_OPTS="--border=horizontal --color=bg+:black,fg+:bright-green:italic,gutter:-1,hl:blue,hl+:bright-blue,query:bright-yellow,prompt:bright-yellow,pointer:black:dim,info:magenta,preview-bg:black,border:black:dim" export WOBSOCK="$HOME/.wob.sock" prompt_nix_shell_setup "$@" colorscript -r