mirror of
https://github.com/acedanger/shell.git
synced 2025-12-06 01:10:12 -08:00
Update setup.sh to generate aliases dynamically without tracking
This commit is contained in:
@@ -311,11 +311,46 @@ ZSH_CUSTOM="$HOME/.oh-my-zsh/custom"
|
|||||||
ALIASES_FILE="$ZSH_CUSTOM/aliases.zsh"
|
ALIASES_FILE="$ZSH_CUSTOM/aliases.zsh"
|
||||||
mkdir -p "$ZSH_CUSTOM"
|
mkdir -p "$ZSH_CUSTOM"
|
||||||
|
|
||||||
# Create a copy of the original aliases file for backup
|
# Create the aliases file from template if it exists, otherwise create a basic one
|
||||||
cp "$DOTFILES_SUBDIR/my-aliases.zsh" "$ALIASES_FILE.bak"
|
if [ -f "$DOTFILES_SUBDIR/my-aliases.zsh.original" ]; then
|
||||||
|
# Use the original template as the base
|
||||||
|
cp "$DOTFILES_SUBDIR/my-aliases.zsh.original" "$ALIASES_FILE.bak"
|
||||||
|
# Filter out dynamic aliases that will be added based on system
|
||||||
|
grep -v "^alias cat=" "$DOTFILES_SUBDIR/my-aliases.zsh.original" | \
|
||||||
|
grep -v "^alias fd=" | \
|
||||||
|
grep -v "^alias fzf=" | \
|
||||||
|
grep -v "^alias ls=" | \
|
||||||
|
grep -v "^alias ll=" | \
|
||||||
|
grep -v "^alias la=" | \
|
||||||
|
grep -v "^alias l=" > "$ALIASES_FILE"
|
||||||
|
else
|
||||||
|
# Create a basic aliases file with common aliases
|
||||||
|
cat > "$ALIASES_FILE" << 'EOF'
|
||||||
|
# Generated aliases file - system specific
|
||||||
|
alias py=python3
|
||||||
|
alias gpull="git pull"
|
||||||
|
alias gpush="git push"
|
||||||
|
alias gc="git commit"
|
||||||
|
alias gcm="git commit -m"
|
||||||
|
alias findzombie="ps -A -ostat,pid,ppid | grep -e '[zZ]'"
|
||||||
|
|
||||||
# First, copy all general aliases except those we'll modify based on OS
|
# Plex Media Server Management
|
||||||
grep -v "alias cat=" "$DOTFILES_SUBDIR/my-aliases.zsh" | grep -v "alias fd=" | grep -v "alias fzf=" > "$ALIASES_FILE"
|
alias plex="/home/acedanger/shell/plex/plex.sh"
|
||||||
|
alias px="/home/acedanger/shell/plex/plex.sh"
|
||||||
|
alias plex-start="/home/acedanger/shell/plex/plex.sh start"
|
||||||
|
alias plex-stop="/home/acedanger/shell/plex/plex.sh stop"
|
||||||
|
alias plex-restart="/home/acedanger/shell/plex/plex.sh restart"
|
||||||
|
alias plex-status="/home/acedanger/shell/plex/plex.sh status"
|
||||||
|
alias plex-web="xdg-open http://localhost:32400/web"
|
||||||
|
|
||||||
|
# System aliases
|
||||||
|
alias update="/home/acedanger/shell/update.sh"
|
||||||
|
alias dcdn="docker compose down"
|
||||||
|
alias dcupd="docker compose up -d"
|
||||||
|
alias dcpull="docker compose pull"
|
||||||
|
alias lzd="lazydocker"
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
|
||||||
# Function to check for command existence and add appropriate alias
|
# Function to check for command existence and add appropriate alias
|
||||||
add_conditional_alias() {
|
add_conditional_alias() {
|
||||||
@@ -360,15 +395,8 @@ if command -v fzf &> /dev/null; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Also create a symlink from the custom aliases file back to the dotfiles directory for persistence
|
# Note: my-aliases.zsh is now generated dynamically and not tracked in git
|
||||||
# This allows changes made to aliases.zsh to be tracked in the dotfiles repo
|
# The generated aliases.zsh file in ~/.oh-my-zsh/custom/ contains the system-specific aliases
|
||||||
echo -e "${YELLOW}Creating symlink to save customized aliases back to dotfiles...${NC}"
|
|
||||||
if [ -f "$ALIASES_FILE" ]; then
|
|
||||||
# Save a copy of the original for reference
|
|
||||||
cp "$DOTFILES_SUBDIR/my-aliases.zsh" "$DOTFILES_SUBDIR/my-aliases.zsh.original" 2>/dev/null || true
|
|
||||||
# Replace the my-aliases.zsh with the new customized one
|
|
||||||
cp "$ALIASES_FILE" "$DOTFILES_SUBDIR/my-aliases.zsh"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Make sure the aliases file gets sourced immediately in the current shell
|
# Make sure the aliases file gets sourced immediately in the current shell
|
||||||
echo -e "${GREEN}Custom aliases configured for $OS_NAME.${NC}"
|
echo -e "${GREEN}Custom aliases configured for $OS_NAME.${NC}"
|
||||||
|
|||||||
Reference in New Issue
Block a user