Skip to content

Latest commit

 

History

History
1708 lines (1559 loc) · 71.9 KB

File metadata and controls

1708 lines (1559 loc) · 71.9 KB

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:$HOME/.zsh/forgit/bin:$PATH

export PREFIX="/usr/local/i386elfgcc"
export TARGET=i386-elf
export VOIDPKG="/home/babkock/git/void-packages"

source "$HOME/.ssh/zsh/secrets.zsh"
VIVID_THEME="alabaster_dark"

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 $VIVID_THEME)"
    else
        export LS_COLORS="$(vivid -m 8-bit generate $VIVID_THEME)"
    fi
else
    export LS_COLORS="$(vivid -m 8-bit generate $VIVID_THEME)"
fi

export LSCOLORS=$LS_COLORS
export ZLS_COLORS=$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=4;37"
zstyle ':completion:*:*:-command-:*:*' group-order alias functions builtins commands
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

source <(fzf --zsh)
setopt autocd
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 gy="/usr/bin/grep --color=auto --context=4"
    alias xx="echo Can not reboot from SSH > /dev/stderr"
    alias reboot="echo Can not reboot from SSH > /dev/stderr"
    alias shutdown="echo Can not shutdown from SSH > /dev/stderr"
else
    alias c="bat"
    alias cat="bat"
    alias d="fd"
    alias grep="rg"
    alias g="rg"
    alias gy="rg --context=4"
    alias reboot="loginctl reboot"
    alias shutdown="sudo /usr/bin/shutdown -h now"
    alias xx="loginctl reboot"

Login Shell Functions

These functions are only available when you are logged into the TTY.

Start Tmux Session

# functions only for login shells
if [[ "$TERM" == "linux" ]]; then
    function pu() {
        hydroxide imap &> /dev/null &
        hydroxide smtp &> /dev/null &
        tmux new-session "neomutt -F $HOME/.muttrc" \; split-window -v "BROWSER='lynx -accept_all_cookies -nomargins -nostatus' newsraft -c $HOME/.config/newsraft/config"
        fg
        pkill -x hydroxide
        true
    }
    function pn() {
        pkill -x pipewire
        env PULSE_LATENCY_MSEC=60 pipewire &> /dev/null &
        sleep 1
        tmux new-session "/usr/bin/zsh -c \"EDITOR=vim lf -command 'set icons false; set drawbox false;'\"" \; split-window -v "ncmpcpp --host '$MPD_PASS' --port 6602"
        fg
        pkill -x pipewire
        true
    }

Hyprland

function shy() {
    #export WLR_RENDERER="vulkan"
    export WLR_DRM_NO_ATOMIC=1
    export GTK_THEME="Vimix-dark-ruby"
    export GDK_BACKEND="wayland"
    export SDL_VIDEODRIVER="wayland"
    export XDG_CURRENT_DESKTOP="Hyprland"
    export XDG_SESSION_DESKTOP="Hyprland"
    export XDG_SESSION_TYPE="wayland"
    export QT_QPA_PLATFORM="wayland-egl"
    export QT_QPA_PLATFORMTHEME="qt6ct"
    export QT_WAYLAND_DISABLE_WINDOWDECORATION=1
    export XCURSOR_THEME="Adwaita"
    export XCURSOR_SIZE=32
    export MOZ_ENABLE_WAYLAND=1
    export MOZ_WEBRENDER=1
    export WLR_DRM_NO_MODIFIERS=1
    export AQ_DRM_DEVICES="/dev/dri/card0:/dev/dri/renderD128"
    export PULSE_LATENCY_MSEC=80
    pgrep mpdas | xargs kill 2> /dev/null
    pgrep pipewire | xargs kill 2> /dev/null
    pgrep pulseaudio | xargs kill 2> /dev/null
    echo -e '\e[1;31m'
    banner "Starting"
    sleep 1
    pkill -x pipewire
    pkill -x pipewire-pul
    echo -e '\e[1;32m'
    figlet -W -f ivrit "dnalrpyH"
    gsettings set org.gnome.desktop.interface color-scheme prefer-dark &> /dev/null
    gsettings set org.gnome.desktop.interface gtk-theme Vimix-dark-ruby &> /dev/null
    gsettings set org.gnome.desktop.interface cursor-theme Adwaita &> /dev/null
    gsettings set org.gnome.desktop.interface cursor-size 32 &> /dev/null
    dbus-launch --exit-with-session Hyprland &> /dev/null
    pgrep hypridle | xargs kill 2> /dev/null
    pgrep stash | xargs kill 2> /dev/null
    pgrep mako | xargs kill 2> /dev/null
    pgrep emacs | xargs kill 2> /dev/null
    pgrep hydroxide | xargs kill 2> /dev/null
    pkill -x hydroxide
    pgrep mpdas | xargs kill 2> /dev/null
    pkill -x mpdas
    true
}

Sway

function swa() {
    export WLR_RENDERER="vulkan"
    export WLR_DRM_NO_ATOMIC=1
    export GTK_THEME="Vimix-dark-ruby"
    export GDK_BACKEND="wayland"
    export SDL_VIDEODRIVER="wayland"
    export XDG_CURRENT_DESKTOP="sway"
    export XDG_SESSION_DESKTOP="sway"
    export XDG_SESSION_TYPE="wayland"
    export QT_QPA_PLATFORM="wayland-egl"
    export QT_QPA_PLATFORMTHEME="qt6ct"
    export QT_WAYLAND_DISABLE_WINDOWDECORATION=1
    export XCURSOR_THEME="Adwaita"
    export XCURSOR_SIZE=32
    export MOZ_ENABLE_WAYLAND=1
    export MOZ_WEBRENDER=1
    export PULSE_LATENCY_MSEC=80
    pgrep mpdas | xargs kill 2> /dev/null
    pgrep pipewire | xargs kill 2> /dev/null
    pgrep pulseaudio | xargs kill 2> /dev/null
    echo -e '\e[1;31m'
    banner "Starting"
    sleep 1
    pkill -x pipewire
    pkill -x pipewire-pul
    echo -e '\e[1;33m'
    figlet -W -f ivrit "yawS"
    gsettings set org.gnome.desktop.interface color-scheme prefer-dark &> /dev/null
    gsettings set org.gnome.desktop.interface gtk-theme Vimix-dark-ruby &> /dev/null
    gsettings set org.gnome.desktop.interface cursor-theme Adwaita &> /dev/null
    gsettings set org.gnome.desktop.interface cursor-size 32 &> /dev/null
    dbus-launch --exit-with-session sway &> /dev/null
    pkill -x eww
    pgrep emacs | xargs kill 2> /dev/null
    pgrep stash | xargs kill 2> /dev/null
    pgrep hydroxide | xargs kill 2> /dev/null
    pkill -x hydroxide
    pgrep mpdas | xargs kill 2> /dev/null
    pkill -x mpdas
    true
}

Wayfire

function swf() {
    export GTK_THEME="Vimix-dark-ruby"
    export GDK_BACKEND="wayland"
    export SDL_VIDEODRIVER="wayland"
    export XDG_CURRENT_DESKTOP="sway"
    export XDG_SESSION_DESKTOP="sway"
    export XDG_SESSION_TYPE="wayland"
    export QT_QPA_PLATFORM="wayland-egl"
    export QT_QPA_PLATFORMTHEME="qt6ct"
    export QT_WAYLAND_DISABLE_WINDOWDECORATION=1
    export XCURSOR_THEME="Adwaita"
    export XCURSOR_SIZE=32
    export MOZ_ENABLE_WAYLAND=1
    export MOZ_WEBRENDER=1
    export PULSE_LATENCY_MSEC=80
    pgrep mpdas | xargs kill 2> /dev/null
    pgrep pipewire | xargs kill 2> /dev/null
    pgrep pulseaudio | xargs kill 2> /dev/null
    echo -e '\e[1;31m'
    banner "Starting"
    sleep 1
    echo -e '\e[1;35m'
    figlet -W -f ivrit "erifyaW"
    gsettings set org.gnome.desktop.interface color-scheme prefer-dark &> /dev/null
    gsettings set org.gnome.desktop.interface gtk-theme Vimix-dark-ruby &> /dev/null
    gsettings set org.gnome.desktop.interface cursor-theme Adwaita &> /dev/null
    gsettings set org.gnome.desktop.interface cursor-size 32 &> /dev/null
    dbus-launch --exit-with-session wayfire &> /dev/null
    pkill -x eww
    pgrep emacs | xargs kill 2> /dev/null
    pgrep stash | xargs kill 2> /dev/null
    pgrep hydroxide | xargs kill 2> /dev/null
    pkill -x hydroxide
    pgrep mpdas | xargs kill 2> /dev/null
    pkill -x mpdas
    true
}

Niri

function sni() {
    export WLR_RENDERER="vulkan"
    export WLR_DRM_NO_ATOMIC=1
    export GTK_THEME="Vimix-dark-ruby"
    export GDK_BACKEND="wayland"
    export SDL_VIDEODRIVER="wayland"
    export XDG_CURRENT_DESKTOP="niri"
    export XDG_SESSION_DESKTOP="niri"
    export XDG_SESSION_TYPE="wayland"
    export QT_QPA_PLATFORM="wayland-egl"
    export QT_QPA_PLATFORMTHEME="qt6ct"
    export QT_WAYLAND_DISABLE_WINDOWDECORATION=1
    export XCURSOR_THEME="Adwaita"
    export XCURSOR_SIZE=32
    export MOZ_ENABLE_WAYLAND=1
    export MOZ_WEBRENDER=1
    export PULSE_LATENCY_MSEC=80
    pgrep mpdas | xargs kill 2> /dev/null
    pgrep pipewire | xargs kill 2> /dev/null
    pgrep pulseaudio | xargs kill 2> /dev/null
    echo -e '\e[1;31m'
    banner "Starting"
    sleep 1
    pkill -x pipewire
    pkill -x pipewire-pul
    echo -e '\e[1;34m'
    figlet -W -f ivrit "iriN"
    dbus-launch --exit-with-session niri --session &> /dev/null
    pkill -x eww
    pgrep emacs | xargs kill 2> /dev/null
    pgrep stash | xargs kill 2> /dev/null
    pgrep hydroxide | xargs kill 2> /dev/null
    pkill -x hydroxide
    pgrep mpdas | xargs kill 2> /dev/null
    true
}

GUI Terminal Functions

These functions will only be available if you are logged in to a GUI terminal.

Edit Doom Emacs init.org

else
    # Doom Emacs init
    function ec() {
        case "$(pidof emacs | wc -w)" in
            0)
                echo -e "\e[1;33mStarting Daemon $(emacs --version | head -1)..."
                emacs --daemon &> /dev/null
                if [ "$?" -ne 0 ]; then
                    echo -e "\e[1;31mCould not start Emacs daemon"
                    exit 1
                fi
                sleep 1
                ;;
            1)
                echo -e "\e[1;33mEditing Doom Emacs init.org with Daemon $(pidof emacs)..."
                ;;
        esac
        swaymsg "workspace 4" &> /dev/null
        hyprctl dispatch workspace 4 &> /dev/null
        emacsclient -c -a 'emacs' -q -r "$HOME/.doom.d/init.org" &
    }

Edit Doom Emacs config.org

# Doom Emacs config
function ed() {
    case "$(pidof emacs | wc -w)" in
        0)
            echo -e "\e[1;33mStarting Daemon $(emacs --version | head -1)..."
            emacs --daemon &> /dev/null
            if [ "$?" -ne 0 ]; then
                echo -e "\e[1;31mCould not start Emacs daemon"
                exit 1
            fi
            sleep 1
            ;;
        1)
            echo -e "\e[1;33mEditing Doom Emacs config.org with Daemon $(pidof emacs)..."
            ;;
    esac
    swaymsg "workspace 4" &> /dev/null
    hyprctl dispatch workspace 4 &> /dev/null
    emacsclient -c -a 'emacs' -q -r "$HOME/.doom.d/config.org" &
}

Edit Foot foot.org

# Foot config
function ef() {
    case "$(pidof emacs | wc -w)" in
        0)
            echo -e "\e[1;33mStarting Daemon $(emacs --version | head -1)..."
            emacs --daemon &> /dev/null
            sleep 1
            ;;
        1)
            echo -e "\e[1;33mEditing Foot foot.org with Daemon $(pidof emacs)..."
            ;;
    esac
    swaymsg "workspace 4" &> /dev/null
    hyprctl dispatch workspace 4 &> /dev/null
    emacsclient -c -a 'emacs' -q -r "$HOME/.config/foot/foot.org" &
}

Edit Qutebrowser config.org

# Qutebrowser config
function eq() {
    case "$(pidof emacs | wc -w)" in
        0)
            echo -e "\e[1;33mStarting Daemon $(emacs --version | head -1)..."
            emacs --daemon &> /dev/null
            if [ "$?" -ne 0 ]; then
                echo -e "\e[1;31mCould not start Emacs daemon"
                exit 1
            fi
            sleep 1
            ;;
        1)
            echo -e "\e[1;33mEditing Qutebrowser config with Daemon $(pidof emacs)..."
            ;;
    esac
    swaymsg "workspace 4" &> /dev/null
    hyprctl dispatch workspace 4 &> /dev/null
    emacsclient -c -a 'emacs' -q -r "$HOME/.config/qutebrowser/config.org" &
}

Edit Waybar style.org

# Waybar style
function es() {
    case "$(pidof emacs | wc -w)" in
        0)
            echo -e "\e[1;33mStarting Daemon $(emacs --version | head -1)..."
            emacs --daemon &> /dev/null
            if [ "$?" -ne 0 ]; then
                echo -e "\e[1;31mCould not start Emacs daemon"
                exit 1
            fi
            sleep 1
            ;;
        1)
            echo -e "\e[1;33mEditing Waybar style with Daemon $(pidof emacs)..."
            ;;
    esac
    swaymsg "workspace 4" &> /dev/null
    hyprctl dispatch workspace 4 &> /dev/null
    emacsclient -c -a 'emacs' -q -r "$HOME/.config/waybar/style.org" &
}

Edit Waybar config.org

# Waybar config
function ew() {
    case "$(pidof emacs | wc -w)" in
        0)
            echo -e "\e[1;33mStarting Daemon $(emacs --version | head -1)..."
            emacs --daemon &> /dev/null
            if [ "$?" -ne 0 ]; then
                echo -e "\e[1;31mCould not start Emacs daemon"
                exit 1
            fi
            sleep 1
            ;;
        1)
            echo -e "\e[1;33mEditing Waybar config with Daemon $(pidof emacs)..."
            ;;
    esac
    swaymsg "workspace 4" &> /dev/null
    hyprctl dispatch workspace 4 &> /dev/null
    emacsclient -c -a 'emacs' -q -r "$HOME/.config/waybar/config.org" &
}

Edit .zsh.org

        # Zshrc
        function ez() {
            case "$(pidof emacs | wc -w)" in
                0)
                    echo -e "\e[1;33mStarting Daemon $(emacs --version | head -1)..."
                    emacs --daemon &> /dev/null
                    if [ "$?" -ne 0 ]; then
                        echo -e "\e[1;31mCould not start Emacs daemon"
                        exit 1
                    fi
                    sleep 1
                    ;;
                1)
                    echo -e "\e[1;33mEditing .Zshrc with Daemon $(pidof emacs)..."
                    ;;
            esac
            swaymsg "workspace 4" &> /dev/null
            hyprctl dispatch workspace 4 &> /dev/null
            emacsclient -c -a 'emacs' -q -r "$HOME/.zsh.org" &
        }
    fi
fi

Aliases

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.

CommandIn TerminalIn TTY
lsRegular Eza listingRegular LS listing
lRegular Eza listingRegular LS listing
laLong listing with total directory sizes, all filesLS long listing, all files
llEza Long listing with total sizes, all filesLS long listing, all files
lcEza Long listing with total sizesN/A
lctEza Long listing with total sizes and treeN/A
lctlEza Long listing with total sizes and treeN/A
lslLong listing, all filesLS long listing, all files
lsaLong listing, all filesLS long listing, all files
lslaLong listing with total sizes, all filesLS long listing, all files
lstEza listing with treeN/A
lstlEza long listing with treeN/A
ltlEza long listing with total sizes and treeN/A
aRun YT-DLP on the given URLN/A
alEza long listing, all filesSame, without icons
eOpens new Emacs windowOpens Emacs in Console
ebEdit bspwm.org in new Emacs windowEdit bspwm.org in Console
epEdit Polybar config in new Emacs windowEdit Polybar in Console
egpRun Magit Push on repository inside EmacsRun Magit Push in Console
egsRun Magit Status on repository inside EmacsRun Magit Status in Console
eiRun Magit Log on repository inside EmacsRun Magit Log in Console
eglRun Magit Log on repository inside EmacsRun Magit Log in Console
eeOpen current directory in Dired in EmacsOpen current directory in Console
erOpen Elfeed in EmacsN/A
jOpen NNN file browserN/A
meOpen webcam image in MPV in WaylandN/A
mxOpen webcam image in MPV in X.orgN/A
if [ -v TERM ]; then
    if [[ ${TERM} = "st-256color" || ${TERM} = "rxvt-unicode" || ${TERM} = "xterm-256color" || ${TERM} = "foot" || ${TERM} = "alacritty" || ${TERM} = "kitty" ]]; then
        # graphical terminal
        alias ls="eza --icons --group-directories-first --no-quotes -X -F"
        #alias l="eza --icons --group-directories-first --no-quotes -X -F"
        alias lsla="eza --icons --group-directories-first --no-quotes -X -F -l -A --git --git-repos --time-style=relative -S"
        alias la="eza --icons --group-directories-first --no-quotes -X -F -A"
        alias ll="eza --icons --group-directories-first --no-quotes -X -F -l --git --git-repos --time-style=relative -S"
        alias lsl="eza --icons --group-directories-first --no-quotes -X -F -l --git --git-repos --time-style=relative -S"
        alias lsa="eza --icons --group-directories-first --no-quotes -X -F -l -A --git --git-repos --time-style=relative -S"
        alias lst="eza --icons --group-directories-first --no-quotes -X -F -l -A --git --git-repos --time-style=relative -S -T --level 3"
        alias lstl="eza --icons --group-directories-first --no-quotes -X -F -l -A --git --git-repos --time-style=relative -S -T --level 3"
        alias ltl="eza --icons --group-directories-first --no-quotes -X -F -l -A --git --git-repos --time-style=relative -S -T --level 3"
        alias lc="eza --icons --group-directories-first --no-quotes -X -F -l -A --total-size --git --git-repos --time-style=relative -S"
        alias lct="eza --icons --group-directories-first --no-quotes -X -F -l -A --total-size --git --git-repos --time-style=relative -S -T --level 3"
        alias lctl="eza --icons --group-directories-first --no-quotes -X -F -l -A --total-size --git --git-repos --time-style=relative -S -T --level 3"
        alias a="yt-dlp -k -f 'bv*[ext=mp4][height<=1080]+ba[ext=m4a]' --remux-video 'mkv' --embed-metadata --embed-subs --embed-chapters --sleep-requests 2 --limit-rate 9M --exec '/home/babkock/bin/ytdone'"
        alias al="eza --icons --group-directories-first --no-quotes -X -F -l --git --git-repos --time-style=relative -S"
        alias e="swaymsg \"workspace 4\" 2> /dev/null; hyprctl dispatch workspace 4 &> /dev/null; emacsclient -c -a 'emacs' -q"
        alias ee="swaymsg \"workspace 4\" 2> /dev/null; hyprctl dispatch workspace 4 &> /dev/null; emacsclient -c -a 'emacs' -q -r . &"
        #alias ea="swaymsg \"workspace 4\" 2> /dev/null; hyprctl dispatch workspace 4 &> /dev/null; emacsclient -c -a 'emacs' -q -r \"$HOME/.config/alacritty/config.org\" &"
        alias egp="swaymsg \"workspace 4\" 2> /dev/null; hyprctl dispatch workspace 4 &> /dev/null; emacsclient -c -a 'emacs' -q -r --eval \"(magit-push)\" > /dev/null &"
        alias egs="swaymsg \"workspace 4\" 2> /dev/null; hyprctl dispatch workspace 4 &> /dev/null; emacsclient -c -a 'emacs' -q -r --eval \"(magit-status)\" > /dev/null &"
        alias ei="swaymsg \"workspace 4\" 2> /dev/null; hyprctl dispatch workspace 4 &> /dev/null; emacsclient -c -a 'emacs' -q -r --eval \"(magit-log-all)\" > /dev/null &"
        alias egl="swaymsg \"workspace 4\" 2> /dev/null; hyprctl dispatch workspace 4 &> /dev/null; emacsclient -c -a 'emacs' -q -r --eval \"(magit-log-all)\" > /dev/null &"
        alias er="swaymsg \"workspace 4\" 2> /dev/null; hyprctl dispatch workspace 4 &> /dev/null; emacsclient -c -a 'emacs' -q -r --eval \"(elfeed)\" > /dev/null &"
        alias eo="swaymsg \"workspace 4\" 2> /dev/null; hyprctl dispatch workspace 4 &> /dev/null; emacsclient -c -a 'emacs' -q -r \"$HOME/.config/eww/eww.org\" &"
        alias mx="mpv av://v4l2:/dev/video0 --vo=gpu --hwdec=vaapi --untimed --profile=low-latency --no-osc --ontop --cache=no"
        alias mo="mpv av://v4l2:/dev/video2 --vo=gpu --hwdec=vaapi --untimed --profile=low-latency --no-osc --ontop --cache=no"
        alias me="mpv av://v4l2:/dev/video2 --untimed --profile=low-latency --no-osc --ontop --cache=no --demuxer-lavf-format=video4linux2 --demuxer-lavf-o=video_size=960x720,input_format=mjpeg,framerate=30 --window-scale=0.5"
        alias mj="mpv av://v4l2:/dev/video0 --untimed --profile=low-latency --no-osc --ontop --cache=no --demuxer-lavf-format=video4linux2 --demuxer-lavf-o=video_size=1920x1080,input_format=mjpeg,framerate=30 --window-scale=0.55"
    else
        # login shell or SSH
        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 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 ea="emacsclient -c -a 'emacs' -nw \"$HOME/.config/alacritty/config.org\""
        alias eo="emacsclient -c -a 'emacs' -nw \"$HOME/.config/eww/eww.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

Global Functions

tbef

“TBcom Edit Film”

function tbef() {
    if [ -z "$1" ]; then
        printf "Must specify the name of a film file to edit\n" > /dev/stderr
        false
    elif [ -z "$2" ]; then
        vim -n -T alacritty "$HOME/TBcom/resources/op/film/$1.html"
        pushd "$HOME/TBcom/resources/op" > /dev/null
        git add film
        popd > /dev/null
        true
    else
        vim -n -T alacritty "$HOME/TBcom/resources/op/film/$1.html"
        vim -n -T alacritty "$HOME/TBcom/resources/op/film/$2.html"
        pushd "$HOME/TBcom/resources/op" > /dev/null
        git add film
        popd > /dev/null
        true
    fi
}

tbem

“TBcom Edit Music”

function tbem() {
    if [ -z "$1" ]; then
        printf "Must specify the name of an artist file to edit\n" > /dev/stderr
        false
    elif [ -z "$2" ]; then
        vim -n -T alacritty "$HOME/TBcom/resources/op/music/$1.html"
        pushd "$HOME/TBcom/resources/op" > /dev/null
        git add music
        popd > /dev/null
        true
    else
        vim -n -T alacritty "$HOME/TBcom/resources/op/music/$1.html"
        vim -n -T alacritty "$HOME/TBcom/resources/op/music/$2.html"
        pushd "$HOME/TBcom/resources/op" > /dev/null
        git add music
        popd > /dev/null
        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" > /dev/stderr
        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 --ssl -X -r -c "$TRANS_CREDENTIALS" 2> /dev/null
        true
     elif [ -z "$2" ]; then
        printf "Starting %s...\n" "$1"
        tremc --ssl -c "$TRANS_CREDENTIALS" "$1" > /dev/null
        rm "$1" 2> /dev/null
        tremc --ssl -X -r -c "$TRANS_CREDENTIALS" 2> /dev/null
        true
    elif [ -z "$3" ]; then
        printf "Starting %s with speed %s kbps...\n" "$1" "$2"
        tremc --ssl -c  "$1" > /dev/null
        transmission-remote --auth="$TRANS_PASS" -asd "$2"
        rm "$1" 2> /dev/null
        tremc --ssl -X -r -c "$TRANS_CREDENTIALS" 2> /dev/null
        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" > /dev/stderr
        false
    else
        mupdf -I "$1"
        true
    fi
}

XBPS-Src Helper Functions

xs

function xs() {
    if [ -z "$1" ]; then
        printf "Please specify package name\n" > /dev/stderr
        false
    else
        pushd $VOIDPKG > /dev/null
        ./xbps-src show "$1"
        popd > /dev/null
        true
    fi
}

xb

function xb() {
    if [ -z "$1" ]; then
        printf "Please specify package name\n" > /dev/stderr
        false
    else
        pushd $VOIDPKG > /dev/null
        ./xbps-src build -C -f -j 4 "$1"
        popd > /dev/null
        true
    fi
}

xp

function xp() {
    if [ -z "$1" ]; then
        printf "Please specify package name\n" > /dev/stderr
        false
    else
        pushd $VOIDPKG > /dev/null
        ./xbps-src pkg -C -f -Q -j 4 "$1"
        popd > /dev/null
        true
    fi
}

xxr

function xxr() {
    if [ -z "$1" ]; then
        printf "Please specify package name\n" > /dev/stderr
        false
    elif [ -z "$2" ]; then
        pushd $VOIDPKG > /dev/null
        ./xbps-src remove "$1"
        popd > /dev/null
        true
    elif [ -z "$3" ]; then
        pushd $VOIDPKG > /dev/null
        ./xbps-src remove "$1" "$2"
        popd > /dev/null
        true
    elif [ -z "$4" ]; then
        pushd $VOIDPKG > /dev/null
        ./xbps-src remove "$1" "$2" "$3"
        popd > /dev/null
        true
    fi
}

j

A wrapper function for nnn that changes the current directory when it exits.

function j()
{
    if [[ ${TERM} = "screen-256color" ]]; then
        \nnn -d -i -l 2 -HGURQD -x -e -P preview-tui & ~/.config/nnn/plugins/preview-tui; fg
        return
    fi
    # 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 -x -e "$@"

    if [ -f "$NNN_TMPFILE" ]; then
        . "$NNN_TMPFILE"
        rm -f "$NNN_TMPFILE" > /dev/null
    fi
}

l

function l()
{
    export EDITOR="vim"
    cd "$(lf -print-last-dir)"
}

trybg

function trybg() {
    swaybg -o eDP-1 -i "$1" -o HDMI-A-2 -i "$2" -o DP-1 -i "$3" &
}

vf

Check it out! Choose a file with fzf, then open it in vim. Works with multiple files (use tab to select).

function vf()
{
    fzf -i --walker=file,dir,follow,hidden --walker-skip=.git,node_modules --header="Select a file to edit" --input-label="Filename" --preview-label="Edit this file:" --preview="bat --color=always --style=plain,changes,numbers {}" --preview-window="border:rounded" --border=double --scroll-off=3 --prompt="$ " --pointer="->" --layout=reverse --multi=3 > /tmp/fzf.txt
    xargs -r -o -a /tmp/fzf.txt vim -n -T alacritty -o
}

yz

function yz()
{
    yazi --cwd-file=/tmp/yazi.txt
    cd "$(cat /tmp/yazi.txt)"
}

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" "$WEBSITE_ADDRESS:$RSYNC_PATH" "$1"
        true
    fi
}

Twitch

function twitch() {
    /home/babkock/git/twitch-chat-cli/cli.js connect babkock
}

Make a Video with Audio

function record() {
    if [[ -z "$1" && -z "$2" ]]; then
        printf "USAGE: %s [display] [output file]\n" "$0" > /dev/stderr
        false
    elif [ -z "$2" ]; then
        wf-recorder --audio=alsa_input.pci-0000_00_1f.3.analog-stereo -o HDMI-A-2 -c libx264rgb -r 60 -f "$1"
        true
    else
        wf-recorder --audio=alsa_input.pci-0000_00_1f.3.analog-stereo -o "$1" -c libx264rgb -r 60 -f "$2"
        true
    fi
}

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
    printf "SSH identities loaded\n"
    ssh-add "$HOME/.ssh/gitlab_new" &> /dev/null
    ssh-add "$HOME/.ssh/github_rsa" &> /dev/null
    ssh-add "$HOME/.ssh/tbcom_ssh" &> /dev/null
    ssh-add "$HOME/.ssh/codeberg" &> /dev/null
}

Raspberry Pi Copy

function pcp() {
    if [[ -z "$1" ]]; then
        printf "No file specified\n" > /dev/stderr
        false
    elif [[ -z "$2" ]]; then
        scp -i "$HOME/.ssh/comp2pinew" "$1" pi@192.168.0.13:~
        true
    else
        scp -i "$HOME/.ssh/comp2pinew" "$1" "$2" pi@192.168.0.13:~
        true
    fi
}

Create GitHub Gist

function gst() {
    if [[ -z "$1" ]]; then
        printf "USAGE: $0 [file to upload] [description]\n" > /dev/stderr
        false
    elif [[ -z "$2" ]]; then
        printf "USAGE: $0 '$1' [description]\n" > /dev/stderr
        false
    else
        gh gist create "$1" -d "$2" -p -w
        true
    fi
}

Create GitHub Issue

function gic() {
    if [[ -z "$1" ]]; then
        printf "USAGE: $0 [title] [body]\n" > /dev/stderr
        false
    elif [[ -z "$2" ]]; then
        gh issue create --title "$1"
        true
    else
        gh issue create --title "$1" --body "$2"
        true
    fi
}

Fork GitHub Repo

function gfk() {
    if [[ -z "$1" ]]; then
        printf "USAGE: $0 'OWNER/REPO'\n" > /dev/stderr
        false
    else
        gh repo fork "$1"
        true
    fi
}

Cheat.sh Lookup

function ch() {
    if [[ -z "$1" ]]; then
        printf "No command to look up\n" > /dev/stderr
        false
    elif [[ -z "$2" ]]; then
        curl "https://cht.sh/$1"
        true
    else
        curl "https://cht.sh/$1/$2"
        true
    fi
}

Cheat.sh Learn

function chp() {
    if [[ -z "$1" ]]; then
        printf "Enter a programming language to learn\n" > /dev/stderr
        false
    else
        curl "https://cht.sh/$1/:learn"
        true
    fi
}
function chl() {
    if [[ -z "$1" ]]; then
        printf "Enter a programming language to list topics for\n" > /dev/stderr
        false
    else
        curl "https://cht.sh/$1/:list"
        true
    fi
}

Fix PulseAudio Sink

function pv() {
    pactl set-default-sink alsa_output.pci-0000_00_1f.3.analog-stereo
    pactl set-default-source alsa_input.pci-0000_00_1f.3.analog-stereo
}
function uu() {
	BROWSER="qutebrowser --qt-arg stylesheet '/home/babkock/.local/share/qutebrowser/fix-tooltips.qss' --qt-wrapper PyQt6 --backend webengine --qt-flag enable-features=WebRTCPipeWireCapturer --qt-flag ozone-platform-hint=wayland --qt-flag enable-accelerated-video --qt-flag enable-gpu --qt-flag enable-native-gpu-memory-buffers --qt-flag enable-zero-copy --qt-flag enable-gpu-rasterization" newsraft
}

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.

CommandArgumentsWhat It Does
baN/ASnow 5-day forecast in Denver
bbN/ARun neofetch with fancy bars
cFile nameRun Bat on given files
caFile nameRun Bat on given files
cbN/ACargo build –release
coN/ARun btm task manager
ctN/ACargo test –release
dN/ARun fd Find
dcrFile nameDecrypt given file with GNUPG
dfN/ARun duf
eFile name or directoryOpen given file or directory in Emacs
fN/AA file picker with preview pane
gPattern, file nameRun Ripgrep with given pattern on file
gaFile nameAdd given file to staging area
gbN/ARun onefetch with fancy colors
gcBranchCheck out branch on Git repository
gdFile nameRun Git diff on given file
geN/AGit Fetch All
gfFile nameCheck out given file from HEAD, reverting changes
ggoN/AReturns URL for repo’s origin
gguN/AReturns URL for repo’s upstream
ghPattern, file nameRun Ripgrep with context with given pattern on file
glN/ARun Git log with nice formatting
gmFile name, file nameMove or rename file and add to staging area
gnRepository URLGit clone
gnnRepository URLGit clone –depth 2
gpOptionsGNUPG
gpullN/AGit Pull Origin master
gpulmN/AGit Pull Origin main
gpushN/AGit Push Origin master
gpusmN/AGit Push Origin main
gpashN/AGit Push All master
gpasmN/AGit Push All main
grFile nameDelete file from staging area
grcFile nameDelete file from staging area
gsN/ARun Git Status
gsoURLSet URL for repo’s origin
gsuURLSet URL for repo’s upstream
hN/ARun Htop
iN/ARun Tig Git client
kN/AMake
kcN/AMake clean
kmN/AMeson Setup Build
knN/ANinja -j4
mFile nameOpen given file in MPV
mbN/AMount Baby blue drive
mdN/AMount External SSD
miFile nameOpen given file in MPV, muted
mnMan pageMan
mtFile nameOpen given file in MPV, with sound sent to TV
nN/ARun Ncmpcpp
nbN/ANix Build
ncrFile nameEncrypt given file with GNUPG
neN/ARun Ncmpcpp with Ueberzug
nfiN/ANix Flake Init
nfmN/ANix Flake Metadata
npiPackage nameNix Profile Install
nplN/ANix Profile List
nprPackage numberNix Profile Remove
oProcess nameKill the given process
oaN/AEww Active Windows
ocEww windowEww Close Window
oiN/AEww Inspector
olN/AEww List Windows
ooEww windowEww Open Window
orN/AEww Reload
pN/ARun Flowtop
poN/ARun Gotop
qFile nameOpen given file in Swayimg
qgFile nameOpen given file in GIMP
qwN/AOpen current directory in Swayimg
rDirectoryRun Ranger on given or current directory
sN/ALog in to my website via SSH
sbN/ARestart Bluetooth Daemons
seN/ARestart Emacs Server
sfN/ARestart Waybar for Wayfire
sknN/ALog in to K’s new Mac
skoN/ALog in to K’s old Mac
spN/ARestart Pipewire
spiN/ALog in to Raspberry Pi via SSH
swN/ARestart Waybar for Sway
syN/ARestart Waybar for Hyprland
szN/AKill wpa_supplicant and restart with Ethernet
taFile nameExtract given Tar archive
tdOutput file, filesCompress files into given output Tar archive
tiN/AList Transmission torrents
trOptionsTransmission-remote
tsN/ATransmission Information
ttN/ATransmission Statistics
uN/AOpen Neomutt
ubN/AUnmount Baby blue drive
udN/AUnmount External SSD
vFile nameOpen given file in Vim
vmN/ARun Virt-Manager
whCommand/alias/functionWhich
xN/AStart Zsh as Root
xlN/AList installed packages
xuN/AUpdate system with XBPS
xxN/AReboot system immediately
yFile nameOpen given file in MuPDF
zN/AStart Bluetoothctl
# show weather in Denver today
alias ba="ansiweather -l '$CITY' -u imperial -H true -h false -p false -i false -s true"
# neofetch
alias bb="fastfetch -s 'Title:OS:Host:Kernel:Packages:Uptime:Break:WM:Shell:Terminal:Break:CPU:GPU:CPUUsage:Memory:Swap:Break:Display:Disk:Break:Colors' --color-keys blue"
alias cb="cargo build --release"
alias co="btm"
alias c="bat" # like cat
alias ci="cargo init"
alias ct="cargo test --release"
alias df="duf -hide-mp \"/run/systemd,/boot/efi,/run,/run/user,/sys/fs/cgroup,/dev/shm\"" # like df
# fzf file picker with preview
alias f="fzf --preview=\"bat --color=always --style=plain {}\" --preview-window=\"border:rounded\" --border=rounded --prompt=\"$ \" --pointer=\"->\""
alias fp="ftp -t -v '$FTP_ADDRESS'"
alias i="tig"
alias h="htop"
# encrypt file with GPG
alias ncr="gpg --encrypt --armor -r Tanner"
# decrypt file and output (use > direct)
alias dcr="gpg --decrypt"
alias g="rg"
alias gz="ug -I --depth=2 --exclude-dir='node_modules' --exclude-dir='vendor' --exclude-dir='.git'"
alias gy="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 gca="git commit --allow-empty-message -m ''"
alias gc="git checkout"
alias gcb="git checkout -b"
alias gd="git diff"
alias gdt="git diff-tree"
alias gdz="git diff HEAD^"
alias gdy="git diff HEAD^^"
# git log with special formatting
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 gn="git clone"
alias gnn="git clone --depth 2"
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"
# use these if branch is 'master'
alias gpush="git push origin master"
alias gpull="git pull origin master"
# use these if branch is 'main'
alias gpusm="git push origin main"
alias gpulm="git pull origin main"
# push 'master' to multiple remotes
alias gpash="git push all master; git pull origin master; git pull upstream master"
# push 'main' to multiple remotes
alias gpasm="git push all main; git pull origin main; git pull upstream main"
alias gstl="gh gist list"
alias gste="gh gist edit"
alias gstd="gh gist delete"
alias gpr="gh pr co"
alias gprc="gh pr create --web"
alias gpu="gh pr update-branch"
alias gpl="gh pr list --limit 20"
alias gil="gh issue list --limit 20"
alias v="vim -n -T alacritty"
alias vh="vim -n -T alacritty -o"
alias vv="vim -n -T alacritty -O"
alias vim="vim -n -T alacritty"
alias vm="virt-manager"
alias lb="lsblk --paths --fs --perms"
alias r="ranger"
alias m="env PULSE_LATENCY_MSEC=60 mpv"
alias mb="mount /mnt/Baby; echo 'sdb Mounted'"
alias md="mount /mnt/drive; echo 'sdb Mounted'"
alias mi="env PULSE_LATENCY_MSEC=60 mpv --mute=yes"
alias mt="mpv --audio-device=alsa/hdmi:CARD=PCH,DEV=1"
alias mn="man"
alias tl="tldr"
alias n="rmpc -c '$HOME/.config/rmpc/config.ron'"
alias npi="nix profile install"
alias npl="nix profile list"
alias npr="nix profile remove"
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 oa="eww active-windows"
alias oc="eww close"
alias of="eww open waymem; eww open waycalendar"
alias oi="eww inspector"
alias ol="eww list-windows"
alias oo="eww open"
alias or="eww reload"
alias ow="eww open mem; eww open calendar"
alias u="neomutt -F '$HOME/.muttrc'"
alias spi="TERM=xterm-256color ssh -i '$HOME/.ssh/comp2pinew' pi@192.168.0.13"
alias sk="ssh -i '$HOME/.ssh/me2newmac' kristinowens@192.168.0.17"
alias po="gotop"
alias p="sudo flowtop -46UTDISs -t 2"
alias q="swayimg"
alias qw="swayimg -g -r -w 1920,1080 -p 0,0"
alias qi="identify"
alias qg="gimp"
alias s="ssh $WEBSITE_ADDRESS -p 2222 -i '$HOME/.ssh/tbcom_ssh'"
alias sb="sudo sv restart bluez-alsa; sudo sv restart bluetoothd"
alias se="pkill -x emacs; emacs --daemon"
alias sw="pkill -x waybar; env PULSE_LATENCY_MSEC=80 waybar -c '$HOME/.config/waybar/sway.json' -s '$HOME/.config/waybar/sway.css' -l off &"
alias sf="pkill -x waybar; env PULSE_LATENCY_MSEC=80 waybar -c '$HOME/.config/waybar/wayfire.json' -s '$HOME/.config/waybar/wayfire.css' -l off &"
alias so="pkill -x eww"
alias sy="pkill -x waybar; env PULSE_LATENCY_MSEC=80 waybar -c '$HOME/.config/waybar/hyprland.json' -s '$HOME/.config/waybar/hyprland.css' -l off &"
alias sn="pkill -x waybar; env PULSE_LATENCY_MSEC=80 waybar -c '$HOME/.config/waybar/niri.json' -s '$HOME/.config/waybar/niri.css' -l off &"
alias sp="pkill -x pipewire; pkill -x pulseaudio; pkill -x pipewire; env PULSE_LATENCY_MSEC=60 pipewire &"
alias sz="sudo pkill -x wpa_supplicant; sudo wpa_supplicant -B -Dwired -ienp0s31f6 -c/etc/wpa_supplicant/wpa_supplicant.conf"
alias svi="sudo vim -n -T alacritty"
alias ta="tar xvf"
alias td="tar czf"
alias ti="transmission-remote --auth='$TRANS_PASS' -l"
alias ts="transmission-remote --auth='$TRANS_PASS' -si"
alias tt="transmission-remote --auth='$TRANS_PASS' -st"
alias tr="transmission-remote --auth='$TRANS_PASS'"
alias ub="sudo umount /mnt/Baby; echo Unmounted"
alias ud="sudo umount /mnt/drive; echo Unmounted"
alias k="make"
alias kc="make clean"
alias ki="sudo make install"
alias km="meson setup build --buildtype=release --prefix=/usr"
alias kn="ninja -j4"
alias wh="which"
alias x="sudo zsh"
alias xxb="cd $VOIDPKG; ./xbps-src binary-bootstrap; cd $OLDPWD"
alias xz="cd $VOIDPKG; ./xbps-src zap; cd $OLDPWD"
alias xi="sudo xbps-install -S"
alias xl="sudo xbps-query -l"
alias xr="sudo xbps-remove"
alias xo="sudo xbps-query -O"
alias xu="sudo xbps-install -Su"
#alias xb="./xbps-src build -C -f -j 4"
#alias xp="./xbps-src pkg -C -f -Q -j 4"
#alias xxr="./xbps-src remove"
alias xxu="cd $VOIDPKG; ./xbps-src update-sys; cd $OLDPWD"
alias xxl="cd $VOIDPKG; ./xbps-src list; cd $OLDPWD"
#alias xs="./xbps-src show"
alias xlu="cd $VOIDPKG; ./xbps-src show-local-updates; cd $OLDPWD"
alias xsu="cd $VOIDPKG; ./xbps-src show-sys-updates; cd $OLDPWD"
#alias yz="yazi"
alias z="bluetoothctl"

Plugins

I use the following shell plug-ins, which are loaded from the ~/.zsh directory.

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/.zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
source $HOME/.zsh/zsh-history-substring-search/zsh-history-substring-search.zsh
export HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND=""
export HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND=""

export GH_BROWSER="qutebrowser --qt-arg stylesheet '/home/babkock/.local/share/qutebrowser/fix-tooltips.qss' --qt-wrapper PyQt6 --backend webengine --qt-flag enable-features=WebRTCPipeWireCapturer --qt-flag enable-features=UseOzonePlatform --qt-flag ozone-platform-hint=wayland --qt-flag enable-accelerated-video --qt-flag enable-gpu --qt-flag enable-accelerated-mjpeg-decode --qt-flag enable-native-gpu-memory-buffers --qt-flag ignore-gpu-blacklist --qt-flag enable-zero-copy --qt-flag enable-gpu-rasterization"
export GH_EDITOR="vim -n -T alacritty"
source $HOME/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh
source $HOME/.zsh/zsh-autopair/autopair.zsh
source $HOME/.zsh/zsh-fzf-history-search/zsh-fzf-history-search.zsh
source $HOME/.zsh/zsh-nix-shell/nix-shell.plugin.zsh
source $HOME/.zsh/you-should-use/you-should-use.plugin.zsh
source $HOME/.zsh/completion.zsh
source $HOME/.zsh/nix-zsh-completions/nix-zsh-completions.plugin.zsh
source $HOME/.zsh/correction.zsh
source $HOME/.zsh/history.zsh
source $HOME/.zsh/colored-man-pages.plugin.zsh
source $HOME/.zsh/niri.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 '^@' reverse-menu-complete
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 GREP_COLORS="fn=bh:ln=gh:mt=rh:cx=y"
export EDITOR=vim
export ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=#555555"
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"

Tricks

prompt_nix_shell_setup "$@"
export PULSE_LATENCY_MSEC=60

random=$(shuf -i 1-3 -n 1)
if [[ ${TERM} = "st-256color" || ${TERM} = "rxvt-unicode" || ${TERM} = "xterm-256color" || ${TERM} = "foot" || ${TERM} = "kitty" || ${TERM} = "alacritty" ]]; then
    if [[ "$random" == "1" ]]; then
        pokemon-colorscripts --no-title -r 1-3
    elif [[ "$random" == "2" ]]; then
        pokemon-colorscripts --no-title -s -r 1-3
    else
        echo -e '\e[5;31m'
        colorscript -r
    fi
else
    colorscript -r
fi
random=$(shuf -i 1-35 -n 1)
if [[ ${TERM} = "st-256color" || ${TERM} = "rxvt-unicode" || ${TERM} = "xterm-256color" || ${TERM} = "foot" || ${TERM} = "kitty" || ${TERM} = "alacritty" ]]; then
    if [[ "$random" == "1" ]]; then
        echo -e '\e[5;30m'
        fortune anarchism | cowsay -w | lolcat --random -b -v 0.2
    elif [[ "$random" == "2" ]]; then
        echo -e '\e[5;30m'
        fortune drugs | cowsay -w | lolcat --random -b -v 0.2
    elif [[ "$random" == "3" ]]; then
        echo -e '\e[5;30m'
        fortune linux | cowsay -w | lolcat --random -b -v 0.2
    elif [[ "$random" == "4" ]]; then
        echo -e '\e[5;30m'
        fortune void | cowsay -w | lolcat --random -b -v 0.2
    elif [[ "$random" == "5" ]]; then
        echo -e '\e[5;30m'
        fortune computers | cowsay -w | lolcat --random -b -v 0.2
    elif [[ "$random" == "6" ]]; then
        echo -e '\e[5;30m'
        fortune paradoxum | cowsay -w | lolcat --random -b -v 0.2
    elif [[ "$random" == "7" ]]; then
        echo -e '\e[5;30m'
        fortune men-women | cowsay -w | lolcat --random -b -v 0.2
    elif [[ "$random" == "8" ]]; then
        echo -e '\e[5;30m'
        fortune linux | cowsay -w | lolcat --random -b -v 0.2
    elif [[ "$random" == "9" ]]; then
        echo -e '\e[5;30m'
        fortune magic | cowsay -w | lolcat --random -b -v 0.2
    elif [[ "$random" == "10" ]]; then
        echo -e '\e[5;30m'
        fortune linuxcookie | cowsay -w | lolcat --random -b -v 0.2
    elif [[ "$random" == "11" ]]; then
        echo -e '\e[5;30m'
        fortune wisdom | cowsay -w | lolcat --random -b -v 0.2
    elif [[ "$random" == "12" ]]; then
        echo -e '\e[5;30m'
        fortune ethnic | cowsay -w | lolcat --random -b -v 0.2
    elif [[ "$random" == "13" ]]; then
        echo -e '\e[5;30m'
        fortune literature | cowsay -w | lolcat --random -b -v 0.2
    elif [[ "$random" == "14" ]]; then
        echo -e '\e[5;30m'
        fortune art | cowsay -w | lolcat --random -b -v 0.2
    elif [[ "$random" == "15" ]]; then
        echo -e '\e[5;30m'
        fortune platitudes | cowsay -w | lolcat --random -b -v 0.2
    elif [[ "$random" == "16" ]]; then
        echo -e '\e[5;30m'
        fortune pets | cowsay -w | lolcat --random -b -v 0.2
    elif [[ "$random" == "17" ]]; then
        echo -e '\e[5;30m'
        fortune computers | cowsay -w | lolcat --random -b -v 0.2
    elif [[ "$random" == "18" ]]; then
        echo -e '\e[5;30m'
        fortune law | cowsay -w | lolcat --random -b -v 0.2
    elif [[ "$random" == "19" ]]; then
        fortune ascii-art | lolcat --random -b -v 0.3
    elif [[ "$random" == "20" ]]; then
        echo -e '\e[5;30m'
        fortune cookie | cowsay -w | lolcat --random -b -v 0.2
    elif [[ "$random" == "21" ]]; then
        echo -e '\e[5;30m'
        fortune definitions | cowsay -w | lolcat --random -b -v 0.2
    elif [[ "$random" == "22" ]]; then
        echo -e '\e[5;30m'
        fortune miscellaneous | cowsay -w | lolcat --random -b -v 0.2
    elif [[ "$random" == "23" ]]; then
        echo -e '\e[5;30m'
        fortune goedel | cowsay -w | lolcat --random -b -v 0.2
    elif [[ "$random" == "24" ]]; then
        echo -e '\e[5;30m'
        fortune news | cowsay -w | lolcat --random -b -v 0.2
    elif [[ "$random" == "25" ]]; then
        echo -e '\e[5;30m'
        fortune people | cowsay -w | lolcat --random -b -v 0.2
    elif [[ "$random" == "26" ]]; then
        echo -e '\e[5;30m'
        fortune science | cowsay -w | lolcat --random -b -v 0.2
    elif [[ "$random" == "27" ]]; then
        echo -e '\e[5;30m'
        fortune art | cowsay -w | lolcat --random -b -v 0.2
    elif [[ "$random" == "28" ]]; then
        echo -e '\e[5;30m'
        fortune perl | cowsay -w | lolcat --random -b -v 0.2
    elif [[ "$random" == "29" ]]; then
        echo -e '\e[5;30m'
        fortune songs-poems | cowsay -w | lolcat --random -b -v 0.2
    elif [[ "$random" == "30" ]]; then
        echo -e '\e[5;30m'
        fortune fortunes | cowsay -w | lolcat --random -b -v 0.2
    elif [[ "$random" == "31" ]]; then
        echo -e '\e[5;30m'
        fortune knghtbrd | cowsay -w | lolcat --random -b -v 0.2
    elif [[ "$random" == "32" ]]; then
        echo -e '\e[5;30m'
        fortune zippy | cowsay -w | lolcat --random -b -v 0.2
    elif [[ "$random" == "33" ]]; then
        echo -e '\e[5;30m'
        fortune love | cowsay -w | lolcat --random -b -v 0.2
    elif [[ "$random" == "34" ]]; then
        echo -e '\e[5;30m'
        fortune work | cowsay -w | lolcat --random -b -v 0.2
    else
        echo -e '\e[5;30m'
        fortune humorists | cowsay -w | lolcat --random -b -v 0.2
    fi
else
    if [[ "$random" == "1" ]]; then
        fortune anarchism | cowsay -w | lolcat --random -x
    elif [[ "$random" == "2" ]]; then
        fortune linux | cowsay -w | lolcat --random -x
    elif [[ "$random" == "3" ]]; then
        fortune drugs | cowsay -w | lolcat --random -x
    elif [[ "$random" == "4" ]]; then
        fortune void | cowsay -w | lolcat --random -x
    elif [[ "$random" == "5" ]]; then
        fortune computers | cowsay -w | lolcat --random -x
    elif [[ "$random" == "6" ]]; then
        fortune linuxcookie | cowsay -w | lolcat --random -x
    elif [[ "$random" == "7" ]]; then
        fortune paradoxum | cowsay -w | lolcat --random -x
    elif [[ "$random" == "8" ]]; then
        fortune men-women | cowsay -w | lolcat --random -x
    elif [[ "$random" == "9" ]]; then
        fortune wisdom | cowsay -w | lolcat --random -x
    elif [[ "$random" == "10" ]]; then
        fortune magic | cowsay -w | lolcat --random -x
    elif [[ "$random" == "11" ]]; then
        fortune humorists | cowsay -w | lolcat --random -x
    elif [[ "$random" == "12" ]]; then
        fortune ethnic | cowsay -w | lolcat --random -x
    elif [[ "$random" == "13" ]]; then
        fortune void | cowsay -w | lolcat --random -x
    elif [[ "$random" == "14" ]]; then
        fortune law | cowsay -w | lolcat --random -x
    elif [[ "$random" == "15" ]]; then
        fortune literature | cowsay -w | lolcat --random -x
    elif [[ "$random" == "16" ]]; then
        fortune cookie | cowsay -w | lolcat --random -x
    elif [[ "$random" == "17" ]]; then
        fortune politics | cowsay -w | lolcat --random -x
    elif [[ "$random" == "18" ]]; then
        fortune linux | cowsay -w | lolcat --random -x
    elif [[ "$random" == "19" ]]; then
        fortune law | cowsay -w | lolcat --random -x
    elif [[ "$random" == "20" ]]; then
        fortune art | cowsay -w | lolcat --random -x
    elif [[ "$random" == "21" ]]; then
        fortune people | cowsay -w | lolcat --random -x
    elif [[ "$random" == "22" ]]; then
        fortune fortunes | cowsay -w | lolcat --random -x
    elif [[ "$random" == "23" ]]; then
        fortune knghtbrd | cowsay -w | lolcat --random -x
    elif [[ "$random" == "24" ]]; then
        fortune zippy | cowsay -w | lolcat --random -x
    elif [[ "$random" == "25" ]]; then
        fortune science | cowsay -w | lolcat --random -x
    elif [[ "$random" == "26" ]]; then
        fortune news | cowsay -w | lolcat --random -x
    elif [[ "$random" == "27" ]]; then
        fortune miscellaneous | cowsay -w | lolcat --random -x
    elif [[ "$random" == "28" ]]; then
        fortune perl | cowsay -w | lolcat --random -x
    elif [[ "$random" == "29" ]]; then
        fortune goedel | cowsay -w | lolcat --random -x
    elif [[ "$random" == "30" ]]; then
        fortune love | cowsay -w | lolcat --random -x
    elif [[ "$random" == "31" ]]; then
        fortune definitions | cowsay -w | lolcat --random -x
    elif [[ "$random" == "32" ]]; then
        fortune platitudes | cowsay -w | lolcat --random -x
    elif [[ "$random" == "33" ]]; then
        fortune work | cowsay -w | lolcat --random -x
    elif [[ "$random" == "34" ]]; then
        fortune pets | cowsay -w | lolcat --random -x
    else
        fortune ascii-art | lolcat --random -x
    fi
fi

>