new install script

This commit is contained in:
ronny abraham 2025-05-05 16:52:07 +03:00
parent b5eb0d339d
commit acb09b7f0c
3 changed files with 44 additions and 21 deletions

2
.gitignore vendored
View file

@ -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; -*-
*~

View file

@ -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"

View file

@ -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\] \$ '