diff --git a/bin/worktree.sh b/bin/worktree.sh index 8950d8a..4f2ed37 100755 --- a/bin/worktree.sh +++ b/bin/worktree.sh @@ -1,6 +1,7 @@ #!/bin/bash CWD="$PWD" +EDITOR="code" TICKETS=() function ticketloop(){ @@ -29,22 +30,24 @@ function doaction { branch="godb_$label_$ticket" dir="../godb_$ticket" - echo "----------------------------------------" + echo "-----------------------------------------------" echo "Creating workspace with the following details: " echo "Ticket Type : $label" echo "Ticket Id : $ticket" echo "Ticket branch: $branch" echo "Worktree dir : $dir" echo "Branch from : $from" - echo "Prompt : $prompt" - echo "----------------------------------------" + echo "Prompt : $prompt" + echo "-----------------------------------------------" git checkout "$from" git pull origin "$from" git worktree add "$dir" -b "$branch" cd "$dir" - code . + "$EDITOR" . & sleep 1.5 - code chat "$prompt" + if [[ -n "$prompt" && "$EDITOR" == "code" ]]; then + code chat "$prompt" + fi cd "$CWD" git worktree list } @@ -58,11 +61,15 @@ while [[ "$#" -gt 0 ]]; do shift done ;; - "--cwd"|"--dir") + "--cwd"|"-c") CWD="$2" cd "$2" shift 2 ;; + "--edr"|"-e") + EDITOR="$2" + shift 2 + ;; *) echo "unknown argument $1" exit -1