mirror of
https://github.com/lordmathis/dotfiles.git
synced 2025-11-05 17:24:22 +00:00
Refactor .zshrc and .aliases: consolidate distro-specific aliases, enhance config function for dotfiles updates, and restore open function.
This commit is contained in:
12
.aliases
12
.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
|
||||
|
||||
63
.zshrc
63
.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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user