diff --git a/.gitignore b/.gitignore index 11d6db4..d9d43a9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,8 @@ # Created by https://www.toptal.com/developers/gitignore/api/vim,emacs,osx # Edit at https://www.toptal.com/developers/gitignore?templates=vim,emacs,osx +config.yaml + ### Emacs ### # -*- mode: gitignore; -*- *~ diff --git a/bin/install.sh b/bin/install.sh index fa48e6d..d73f599 100644 --- a/bin/install.sh +++ b/bin/install.sh @@ -1,21 +1,50 @@ #!/bin/bash -target="$HOME/.bashrc" +set -e -config_dir="$HOME/.config/prompt-theme" -config_file="$config_dir/config.yaml" -source_line="source $config_dir/bin/prompt-theme.sh" +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" -if ! grep -Fxq "$source_line" "$target"; then - echo "$source_line" >> "$target" - echo "✅ Added prompt-theme to $target" -else - echo "â„šī¸ prompt-theme is already sourced in $target" +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 -# copy default config file if none exists -if [[ ! -f "$config_file" ]]; then - cp "$config_dir/share/_config.yaml" "$config_file" +# 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 "â„šī¸ Existing config.yaml found at $config_file (unchanged)" + 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" diff --git a/config.yaml b/config.yaml deleted file mode 100644 index 189edca..0000000 --- a/config.yaml +++ /dev/null @@ -1,8 +0,0 @@ -default: nature - -prompts: - default: '\[\033[01;34m\]\u@\h \[\033[01;32m\]\w\[\033[00m\] \$ ' - bone: '\[\033[38;5;250m\]\u@\h \[\033[38;5;160m\]\w\[\033[0m\] \$ ' - nature: '\[\033[38;5;100m\]\u@\h \[\033[38;5;65m\]\w\[\033[0m\] \$ ' - ayu-mirage: '\[\033[38;5;179m\]\u@\h \[\033[38;5;110m\]\w\[\033[0m\] \$ ' -