.bashrc improvements

This commit is contained in:
2026-02-24 02:48:52 +00:00
parent af42d1be15
commit e552f45e55
4 changed files with 98 additions and 186 deletions
+44 -6
View File
@@ -4,14 +4,52 @@ set -e
DOTFILES_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Packages to stow
PACKAGES=(bash kitty fastfetch ssh)
echo "Setting up dotfiles from $DOTFILES_DIR"
for pkg in "${PACKAGES[@]}"; do
echo "Stowing $pkg..."
stow_pkg() {
local pkg="$1"
stow -v -d "$DOTFILES_DIR" -t "$HOME" "$pkg"
done
}
ensure_sourced() {
local file="$1"
local bashrc="$HOME/.bashrc"
local source_line="[ -f \"$file\" ] && source \"$file\""
if [ ! -f "$bashrc" ]; then
echo "WARNING: ~/.bashrc not found, skipping source injection for $file"
return
fi
if grep -qF "$file" "$bashrc"; then
echo "OK: $file already sourced in ~/.bashrc"
else
echo "" >> "$bashrc"
echo "# Added by dotfiles setup" >> "$bashrc"
echo "$source_line" >> "$bashrc"
echo "ADDED: source $file to ~/.bashrc"
fi
}
# ssh — always available
stow_pkg ssh
# bash — stow dotfiles, then ensure ~/.bashrc sources them
stow_pkg bash
ensure_sourced "$HOME/.bashrc.omb"
# kitty
if command -v kitty &>/dev/null; then
stow_pkg kitty
else
echo "SKIP: kitty (not installed)"
fi
# fastfetch
if command -v fastfetch &>/dev/null; then
stow_pkg fastfetch
else
echo "SKIP: fastfetch (not installed)"
fi
echo "Done!"