Auto-detect existing projects directory, default to ~/Projects
Checks ~/Projects, ~/projects, ~/Dev, ~/Workspace, ~/Code, ~/src etc. Uses the first one that exists; falls back to ~/Projects if none found. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
431e5493fc
commit
af065f0def
1 changed files with 15 additions and 1 deletions
16
wizard.sh
16
wizard.sh
|
|
@ -12,6 +12,18 @@ source "$WIZARD_DIR/lib/core.sh"
|
||||||
source "$WIZARD_DIR/lib/project.sh"
|
source "$WIZARD_DIR/lib/project.sh"
|
||||||
source "$WIZARD_DIR/lib/workflow.sh"
|
source "$WIZARD_DIR/lib/workflow.sh"
|
||||||
|
|
||||||
|
# ── Find existing projects base dir ───────────────────────────────────────
|
||||||
|
find_projects_dir() {
|
||||||
|
local candidates=("Projects" "projects" "Project" "project" "Dev" "dev" "Workspace" "workspace" "Code" "code" "src" "Src")
|
||||||
|
for candidate in "${candidates[@]}"; do
|
||||||
|
if [[ -d "$HOME/$candidate" ]]; then
|
||||||
|
echo "$HOME/$candidate"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo "$HOME/Projects"
|
||||||
|
}
|
||||||
|
|
||||||
# ── Project info ───────────────────────────────────────────────────────────
|
# ── Project info ───────────────────────────────────────────────────────────
|
||||||
collect_project_info() {
|
collect_project_info() {
|
||||||
header "Project Details"
|
header "Project Details"
|
||||||
|
|
@ -19,7 +31,9 @@ collect_project_info() {
|
||||||
ask PROJECT_NAME "Project name" ""
|
ask PROJECT_NAME "Project name" ""
|
||||||
if [[ -z "$PROJECT_NAME" ]]; then die "Project name is required."; fi
|
if [[ -z "$PROJECT_NAME" ]]; then die "Project name is required."; fi
|
||||||
|
|
||||||
local default_dir="$HOME/projects/$(slugify "$PROJECT_NAME")"
|
local projects_base
|
||||||
|
projects_base="$(find_projects_dir)"
|
||||||
|
local default_dir="$projects_base/$(slugify "$PROJECT_NAME")"
|
||||||
ask PROJECT_DIR "Project location" "$default_dir"
|
ask PROJECT_DIR "Project location" "$default_dir"
|
||||||
if [[ -z "$PROJECT_DIR" ]]; then die "Project location is required."; fi
|
if [[ -z "$PROJECT_DIR" ]]; then die "Project location is required."; fi
|
||||||
PROJECT_DIR="${PROJECT_DIR/#\~/$HOME}"
|
PROJECT_DIR="${PROJECT_DIR/#\~/$HOME}"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue