From 21a8432fd2a37e29a99f9e74c980ed4fac637b19 Mon Sep 17 00:00:00 2001 From: LordMathis Date: Sat, 27 Sep 2025 20:21:09 +0200 Subject: [PATCH] Refactor .zshrc and .aliases: consolidate distro-specific aliases, enhance config function for dotfiles updates, and restore open function. --- .aliases | 12 ++++++++--- .zshrc | 63 +++++++++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 65 insertions(+), 10 deletions(-) diff --git a/.aliases b/.aliases index f0f6d79..95e57aa 100644 --- a/.aliases +++ b/.aliases @@ -11,6 +11,12 @@ alias dol='docker logs -f' alias sudo='sudo ' -open () { - xdg-open "$@" &>/dev/null -} +alias ll='ls -lah' + +# Distro-specific aliases +DISTRO=$(cat /etc/os-release | grep ^ID= | cut -f2 -d'=') +if [ "$DISTRO" = 'arch' ]; then + alias cat='bat' +else + alias cat='batcat' +fi diff --git a/.zshrc b/.zshrc index 4fbc10a..22edaad 100644 --- a/.zshrc +++ b/.zshrc @@ -17,13 +17,62 @@ mkdir -p "$ZSH_CACHE_DIR/completions" export EDITOR=nvim export GIT_EDITOR=nvim -# Distro specific aliases -DISTRO=`cat /etc/os-release | grep ^ID= | cut -f2 -d'='` -if [ "$DISTRO" = 'arch' ]; then - source $HOME/.aliases_arch -else - source $HOME/.aliases_ubuntu -fi +open () { + xdg-open "$@" &>/dev/null +} + + +# Enhanced dotfiles config function +config() { + # Helper function to avoid repetition + local _config_git() { + /usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME "$@" + } + + # Special case for 'update' command + if [[ "$1" == "update" ]]; then + echo "Updating dotfiles repository..." + + # Navigate to home directory + local current_dir=$(pwd) + cd $HOME + + # Fetch latest changes from remote + _config_git fetch origin + + # Get current branch name + local current_branch=$(_config_git branch --show-current) + + if [ -z "$current_branch" ]; then + echo "Error: Could not determine current branch" + cd $current_dir + return 1 + fi + + echo "Current branch: $current_branch" + + # Pull latest changes for current branch + echo "Pulling latest changes..." + _config_git pull origin $current_branch + + # Update all submodules to their latest commits + echo "Updating submodules..." + _config_git submodule update --recursive --remote + + # Show status + echo "Update complete! Current status:" + _config_git status --short + + echo "Submodule status:" + _config_git submodule status + + # Return to original directory + cd $current_dir + else + # Pass through to regular git command + _config_git "$@" + fi +} # Node Version Manager