prompt-themes/bin/install.sh
2025-05-05 16:52:07 +03:00

50 lines
1.3 KiB
Bash
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
set -e
REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
CONFIG_DIR="$HOME/.config/prompt-theme"
BIN_DIR="$HOME/bin"
TARGET_SCRIPT="$BIN_DIR/prompt-theme.sh"
DEFAULT_CONFIG_SRC="$REPO_DIR/share/_config.yaml"
DEFAULT_CONFIG_DEST="$CONFIG_DIR/config.yaml"
echo "🔧 Installing prompt-theme..."
# Check for yq
if ! command -v yq >/dev/null 2>&1; then
echo "❌ Error: 'yq' is not installed."
if [[ "$(uname)" == "Darwin" ]]; then
echo "👉 On macOS, run: brew install yq"
else
echo "👉 On Linux, run: sudo apt install yq (or use your distro's package manager)"
fi
exit 1
fi
# Ensure config dir exists
mkdir -p "$CONFIG_DIR"
# Copy default config if not already present
if [[ ! -f "$DEFAULT_CONFIG_DEST" ]]; then
cp "$DEFAULT_CONFIG_SRC" "$DEFAULT_CONFIG_DEST"
echo "✅ Default config.yaml copied to $DEFAULT_CONFIG_DEST"
else
echo " config.yaml already exists at $DEFAULT_CONFIG_DEST, not overwriting."
fi
# Ensure bin dir exists
mkdir -p "$BIN_DIR"
# Create symlink to prompt-theme.sh using absolute path
SCRIPT_PATH="$REPO_DIR/bin/prompt-theme.sh"
if [[ -L "$TARGET_SCRIPT" || -f "$TARGET_SCRIPT" ]]; then
rm "$TARGET_SCRIPT"
fi
ln -s "$SCRIPT_PATH" "$TARGET_SCRIPT"
echo "✅ Symlink created: $TARGET_SCRIPT$SCRIPT_PATH"
echo "🚀 Done! To apply a theme, run:"
echo " source ~/bin/prompt-theme.sh"