@@ -97,16 +97,27 @@ __FUNC__() {
9797 --layout=reverse \
9898 --border \
9999 --prompt='Worktree> ' \
100- --header='enter:cd │ ctrl-e:editor │ ctrl-a:ai │ ctrl-d:delete │ ctrl-y:copy │ ctrl-r:refresh' \
100+ --header='enter:cd │ ctrl-n:new │ ctrl-e:editor │ ctrl-a:ai │ ctrl-d:delete │ ctrl-y:copy │ ctrl-r:refresh' \
101+ --expect=ctrl-n \
101102 --preview='git -C {1} log --oneline --graph --color=always -15 2>/dev/null; echo "---"; git -C {1} status --short 2>/dev/null' \
102103 --preview-window=right:50% \
103104 --bind='ctrl-e:execute(git gtr editor {2})' \
104105 --bind='ctrl-a:execute(git gtr ai {2})' \
105106 --bind='ctrl-d:execute(git gtr rm {2})+reload(git gtr list --porcelain)' \
106107 --bind='ctrl-y:execute(git gtr copy {2})' \
107108 --bind='ctrl-r:reload(git gtr list --porcelain)')" || return 0
108- [ -z "$_gtr_selection" ] && return 0
109- dir="$(printf '%s' "$_gtr_selection" | cut -f1)"
109+ local _gtr_key _gtr_line _gtr_branch
110+ _gtr_key="$(head -1 <<< "$_gtr_selection")"
111+ _gtr_line="$(sed -n '2p' <<< "$_gtr_selection")"
112+ if [ "$_gtr_key" = "ctrl-n" ]; then
113+ printf "Branch name: " >&2
114+ read -r _gtr_branch
115+ [ -z "$_gtr_branch" ] && return 0
116+ command git gtr new "$_gtr_branch"
117+ return $?
118+ fi
119+ [ -z "$_gtr_line" ] && return 0
120+ dir="$(printf '%s' "$_gtr_line" | cut -f1)"
110121 elif [ "$#" -eq 0 ]; then
111122 echo "Usage: __FUNC__ cd <branch>" >&2
112123 echo "Tip: Install fzf for an interactive picker (https://github.com/junegunn/fzf)" >&2
@@ -203,16 +214,27 @@ __FUNC__() {
203214 --layout=reverse \
204215 --border \
205216 --prompt='Worktree> ' \
206- --header='enter:cd │ ctrl-e:editor │ ctrl-a:ai │ ctrl-d:delete │ ctrl-y:copy │ ctrl-r:refresh' \
217+ --header='enter:cd │ ctrl-n:new │ ctrl-e:editor │ ctrl-a:ai │ ctrl-d:delete │ ctrl-y:copy │ ctrl-r:refresh' \
218+ --expect=ctrl-n \
207219 --preview='git -C {1} log --oneline --graph --color=always -15 2>/dev/null; echo "---"; git -C {1} status --short 2>/dev/null' \
208220 --preview-window=right:50% \
209221 --bind='ctrl-e:execute(git gtr editor {2})' \
210222 --bind='ctrl-a:execute(git gtr ai {2})' \
211223 --bind='ctrl-d:execute(git gtr rm {2})+reload(git gtr list --porcelain)' \
212224 --bind='ctrl-y:execute(git gtr copy {2})' \
213225 --bind='ctrl-r:reload(git gtr list --porcelain)')" || return 0
214- [ -z "$_gtr_selection" ] && return 0
215- dir="$(printf '%s' "$_gtr_selection" | cut -f1)"
226+ local _gtr_key _gtr_line _gtr_branch
227+ _gtr_key="$(head -1 <<< "$_gtr_selection")"
228+ _gtr_line="$(sed -n '2p' <<< "$_gtr_selection")"
229+ if [ "$_gtr_key" = "ctrl-n" ]; then
230+ printf "Branch name: " >&2
231+ read -r _gtr_branch
232+ [ -z "$_gtr_branch" ] && return 0
233+ command git gtr new "$_gtr_branch"
234+ return $?
235+ fi
236+ [ -z "$_gtr_line" ] && return 0
237+ dir="$(printf '%s' "$_gtr_line" | cut -f1)"
216238 elif [ "$#" -eq 0 ]; then
217239 echo "Usage: __FUNC__ cd <branch>" >&2
218240 echo "Tip: Install fzf for an interactive picker (https://github.com/junegunn/fzf)" >&2
@@ -311,7 +333,8 @@ function __FUNC__
311333 --layout=reverse \
312334 --border \
313335 --prompt='Worktree> ' \
314- --header='enter:cd │ ctrl-e:editor │ ctrl-a:ai │ ctrl-d:delete │ ctrl-y:copy │ ctrl-r:refresh' \
336+ --header='enter:cd │ ctrl-n:new │ ctrl-e:editor │ ctrl-a:ai │ ctrl-d:delete │ ctrl-y:copy │ ctrl-r:refresh' \
337+ --expect=ctrl-n \
315338 --preview='git -C {1} log --oneline --graph --color=always -15 2>/dev/null; echo "---"; git -C {1} status --short 2>/dev/null' \
316339 --preview-window=right:50% \
317340 --bind='ctrl-e:execute(git gtr editor {2})' \
@@ -320,8 +343,16 @@ function __FUNC__
320343 --bind='ctrl-y:execute(git gtr copy {2})' \
321344 --bind='ctrl-r:reload(git gtr list --porcelain)')
322345 or return 0
323- test -z "$_gtr_selection"; and return 0
324- set dir (string split \t -- "$_gtr_selection")[1]
346+ set -l _gtr_key "$_gtr_selection[1]"
347+ set -l _gtr_line "$_gtr_selection[2]"
348+ if test "$_gtr_key" = "ctrl-n"
349+ read -P "Branch name: " _gtr_branch
350+ test -z "$_gtr_branch"; and return 0
351+ command git gtr new "$_gtr_branch"
352+ return $status
353+ end
354+ test -z "$_gtr_line"; and return 0
355+ set dir (string split \t -- "$_gtr_line")[1]
325356 else if test (count $argv) -eq 1
326357 echo "Usage: __FUNC__ cd <branch>" >&2
327358 echo "Tip: Install fzf for an interactive picker (https://github.com/junegunn/fzf)" >&2
0 commit comments