Refactored dot-zshrc config (#46)

Added in command checking to the dot-zshrc file to now check if things
are installed before attempting to set aliases or run programs. This
allows easier sharing of this file for other users or even other
devices.

Reviewed-on: #46
This commit was merged in pull request #46.
This commit is contained in:
2026-07-04 12:40:33 -04:00
parent 80c8976c9d
commit 6eec2cd028
+22 -1
View File
@@ -3,25 +3,36 @@
############### ALIASES #################### ############### ALIASES ####################
# Load bottom with the proper color scheme # Load bottom with the proper color scheme
if command -v btm &>/dev/null; then
alias btm="btm --theme=gruvbox" alias btm="btm --theme=gruvbox"
fi
# Remap ls to use lsd # Remap ls to use lsd
if command -v lsd &>/dev/null; then
alias ls="lsd" alias ls="lsd"
# Add alias for la to call lsd -lah # Add alias for la to call lsd -lah
alias la="lsd -lah" alias la="lsd -lah"
fi
# Replace cat with bat # Replace cat with bat
if command -v bat &>/dev/null; then
alias cat="bat" alias cat="bat"
fi
# Alias cd to z for zoxide # Alias cd to z for zoxide
if command -v zoxide &>/dev/null; then
alias cd="z" alias cd="z"
fi
# Alias vim to nvim # Alias vim to nvim
if command -v nvim &>/dev/null; then
alias vim="nvim" alias vim="nvim"
fi
# Alias for stow --dotfiles # Alias for stow --dotfiles
if command -v stow &>/dev/null; then
alias stow.="stow --dotfiles" alias stow.="stow --dotfiles"
fi
############### END ALIASES ############### ############### END ALIASES ###############
@@ -31,7 +42,9 @@ alias stow.="stow --dotfiles"
export PATH=$HOME/.local/bin:$PATH export PATH=$HOME/.local/bin:$PATH
# Export my local-progs directory to find executables # Export my local-progs directory to find executables
if [[ -d "$HOME/local-progs" ]]; then
export PATH=$HOME/local-progs/:$PATH export PATH=$HOME/local-progs/:$PATH
fi
# Pre-configure settings for zsh-vi-mode # Pre-configure settings for zsh-vi-mode
function zvm_config() { function zvm_config() {
@@ -43,17 +56,25 @@ function zvm_config() {
# Add in our fzf integrations for zsh # Add in our fzf integrations for zsh
# Comment if you don't want the fzf integration # Comment if you don't want the fzf integration
if command -v fzf &>/dev/null; then
source <(fzf --zsh) source <(fzf --zsh)
fi
# Enable vi mode for zsh # Enable vi mode for zsh
if [[ -f "$HOME/local-progs/zsh-vi-mode/zsh-vi-mode.plugin.zsh" ]]; then
source $HOME/local-progs/zsh-vi-mode/zsh-vi-mode.plugin.zsh source $HOME/local-progs/zsh-vi-mode/zsh-vi-mode.plugin.zsh
fi
# We want to make sure that autocompletions are loaded # We want to make sure that autocompletions are loaded
autoload -Uz compinit && compinit autoload -Uz compinit && compinit
# Initialize zoxide # Initialize zoxide
if command -v zoxide &>/dev/null; then
eval "$(zoxide init zsh)" eval "$(zoxide init zsh)"
fi
# Finally we want to use starship for our prompt # Finally we want to use starship for our prompt
# (because rust that's why) # (because rust that's why)
if command -v starship &>/dev/null; then
eval "$(starship init zsh)" eval "$(starship init zsh)"
fi