diff --git a/readme.md b/readme.md index 2e21a4c..1b09ee1 100644 --- a/readme.md +++ b/readme.md @@ -32,6 +32,16 @@ b yazi b nvim,yazi ``` +You can also edit configurations located in your `~/.config/` directory by running: + +```bash +b conf nvim +b conf i3 +``` + +It automatically fuzzy-finds the folder in case there is no exact match. + + ## Uninstallation To completely remove the bootstrap helper tool and clear out the shell configurations (leaving any installed software configs intact), run: diff --git a/routes.sh b/routes.sh index fe9863a..6f17a28 100755 --- a/routes.sh +++ b/routes.sh @@ -40,12 +40,41 @@ for script in "${SCRIPTS[@]}"; do echo "Available bootstrap commands:" # Non-installers first (aligned to 6 chars width) printf " %-6s - %s\n" "all" "List all available commands" + printf " %-6s - %s\n" "conf" "Edit config (e.g. b conf nvim)" printf " %-6s - %s\n" "bye" "Uninstall Bootstrap CLI helper" # Installers second (iterating procedurally) for key in "${INSTALLER_KEYS[@]}"; do printf " %-6s - %s\n" "$key" "${INSTALLERS[$key]}" done ;; + conf) + config_name="${1:-}" + if [ -z "$config_name" ]; then + echo "Usage: b conf [files...]" >&2 + exit 1 + fi + shift + + config_dir="" + if [ -d "$HOME/.config/$config_name" ]; then + config_dir="$HOME/.config/$config_name" + else + config_dir=$(find "$HOME/.config" -mindepth 1 -maxdepth 1 -type d -iname "*$config_name*" 2>/dev/null | head -n1) + fi + + if [ -n "$config_dir" ] && [ -d "$config_dir" ]; then + cd "$config_dir" + editor="${EDITOR:-nvim}" + if [ $# -gt 0 ]; then + $editor "$@" + else + $editor . + fi + else + echo "Could not find that directory" >&2 + exit 1 + fi + ;; bye) echo "Removing bootstrap CLI completely..."