@@ -89,24 +89,31 @@ __FUNC__() {
8989 echo "No worktrees to pick from. Create one with: git gtr new <branch>" >&2
9090 return 0
9191 fi
92- local _gtr_selection _gtr_key _gtr_line
92+ local _gtr_selection _gtr_key _gtr_line _gtr_branch
9393 _gtr_selection="$(printf '%s\n' "$_gtr_porcelain" | fzf \
9494 --delimiter=$'\t' \
9595 --with-nth=2 \
9696 --ansi \
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,ctrl-a,ctrl-e \
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% \
103- --expect=ctrl-a,ctrl-e \
104104 --bind='ctrl-d:execute(git gtr rm {2} > /dev/tty 2>&1 < /dev/tty)+reload(git gtr list --porcelain)' \
105105 --bind='ctrl-y:execute(git gtr copy {2} > /dev/tty 2>&1 < /dev/tty)' \
106106 --bind='ctrl-r:reload(git gtr list --porcelain)')" || return 0
107107 [ -z "$_gtr_selection" ] && return 0
108108 _gtr_key="$(head -1 <<< "$_gtr_selection")"
109109 _gtr_line="$(sed -n '2p' <<< "$_gtr_selection")"
110+ if [ "$_gtr_key" = "ctrl-n" ]; then
111+ printf "Branch name: " >&2
112+ read -r _gtr_branch
113+ [ -z "$_gtr_branch" ] && return 0
114+ command git gtr new "$_gtr_branch"
115+ return $?
116+ fi
110117 [ -z "$_gtr_line" ] && return 0
111118 # ctrl-a/ctrl-e: run after fzf exits (needs full terminal for TUI apps)
112119 if [ "$_gtr_key" = "ctrl-a" ]; then
@@ -205,24 +212,31 @@ __FUNC__() {
205212 echo "No worktrees to pick from. Create one with: git gtr new <branch>" >&2
206213 return 0
207214 fi
208- local _gtr_selection _gtr_key _gtr_line
215+ local _gtr_selection _gtr_key _gtr_line _gtr_branch
209216 _gtr_selection="$(printf '%s\n' "$_gtr_porcelain" | fzf \
210217 --delimiter=$'\t' \
211218 --with-nth=2 \
212219 --ansi \
213220 --layout=reverse \
214221 --border \
215222 --prompt='Worktree> ' \
216- --header='enter:cd │ ctrl-e:editor │ ctrl-a:ai │ ctrl-d:delete │ ctrl-y:copy │ ctrl-r:refresh' \
223+ --header='enter:cd │ ctrl-n:new │ ctrl-e:editor │ ctrl-a:ai │ ctrl-d:delete │ ctrl-y:copy │ ctrl-r:refresh' \
224+ --expect=ctrl-n,ctrl-a,ctrl-e \
217225 --preview='git -C {1} log --oneline --graph --color=always -15 2>/dev/null; echo "---"; git -C {1} status --short 2>/dev/null' \
218226 --preview-window=right:50% \
219- --expect=ctrl-a,ctrl-e \
220227 --bind='ctrl-d:execute(git gtr rm {2} > /dev/tty 2>&1 < /dev/tty)+reload(git gtr list --porcelain)' \
221228 --bind='ctrl-y:execute(git gtr copy {2} > /dev/tty 2>&1 < /dev/tty)' \
222229 --bind='ctrl-r:reload(git gtr list --porcelain)')" || return 0
223230 [ -z "$_gtr_selection" ] && return 0
224231 _gtr_key="$(head -1 <<< "$_gtr_selection")"
225232 _gtr_line="$(sed -n '2p' <<< "$_gtr_selection")"
233+ if [ "$_gtr_key" = "ctrl-n" ]; then
234+ printf "Branch name: " >&2
235+ read -r _gtr_branch
236+ [ -z "$_gtr_branch" ] && return 0
237+ command git gtr new "$_gtr_branch"
238+ return $?
239+ fi
226240 [ -z "$_gtr_line" ] && return 0
227241 # ctrl-a/ctrl-e: run after fzf exits (needs full terminal for TUI apps)
228242 if [ "$_gtr_key" = "ctrl-a" ]; then
@@ -331,10 +345,10 @@ function __FUNC__
331345 --layout=reverse \
332346 --border \
333347 --prompt='Worktree> ' \
334- --header='enter:cd │ ctrl-e:editor │ ctrl-a:ai │ ctrl-d:delete │ ctrl-y:copy │ ctrl-r:refresh' \
348+ --header='enter:cd │ ctrl-n:new │ ctrl-e:editor │ ctrl-a:ai │ ctrl-d:delete │ ctrl-y:copy │ ctrl-r:refresh' \
349+ --expect=ctrl-n,ctrl-a,ctrl-e \
335350 --preview='git -C {1} log --oneline --graph --color=always -15 2>/dev/null; echo "---"; git -C {1} status --short 2>/dev/null' \
336351 --preview-window=right:50% \
337- --expect=ctrl-a,ctrl-e \
338352 --bind='ctrl-d:execute(git gtr rm {2} > /dev/tty 2>&1 < /dev/tty)+reload(git gtr list --porcelain)' \
339353 --bind='ctrl-y:execute(git gtr copy {2} > /dev/tty 2>&1 < /dev/tty)' \
340354 --bind='ctrl-r:reload(git gtr list --porcelain)')
@@ -350,6 +364,12 @@ function __FUNC__
350364 set -l _gtr_key "$_gtr_selection[1]"
351365 set -l _gtr_line "$_gtr_selection[2]"
352366 end
367+ if test "$_gtr_key" = "ctrl-n"
368+ read -P "Branch name: " _gtr_branch
369+ test -z "$_gtr_branch"; and return 0
370+ command git gtr new "$_gtr_branch"
371+ return $status
372+ end
353373 test -z "$_gtr_line"; and return 0
354374 # ctrl-a/ctrl-e: run after fzf exits (needs full terminal for TUI apps)
355375 if test "$_gtr_key" = "ctrl-a"
0 commit comments