File tree Expand file tree Collapse file tree 3 files changed +20
-8
lines changed
Expand file tree Collapse file tree 3 files changed +20
-8
lines changed Original file line number Diff line number Diff line change @@ -18,9 +18,10 @@ _git_wt() {
1818
1919 case " $cmd " in
2020 clone)
21- # clone takes a URL and optional folder name
22- # No completion for URLs, but complete local paths for folder name
23- if [[ $cword -eq 3 ]]; then
21+ if [[ $cur == -* ]]; then
22+ COMPREPLY=($( compgen -W " --help -h" -- " $cur " ) )
23+ elif [[ $cword -eq 3 ]]; then
24+ # No completion for URLs, but complete local paths for folder name
2425 _filedir -d
2526 fi
2627 ;;
@@ -71,10 +72,14 @@ _git_wt() {
7172 fi
7273 ;;
7374 lock | unlock | move | prune | repair)
74- # Pass-through commands - complete with worktree paths
75- local worktrees
76- worktrees=$( git worktree list --porcelain 2> /dev/null | grep ' ^worktree ' | sed ' s/^worktree //' | grep -v ' \.bare$' )
77- COMPREPLY=($( compgen -W " $worktrees " -- " $cur " ) )
75+ if [[ $cur == -* ]]; then
76+ COMPREPLY=($( compgen -W " --help -h" -- " $cur " ) )
77+ else
78+ # Pass-through commands - complete with worktree paths
79+ local worktrees
80+ worktrees=$( git worktree list --porcelain 2> /dev/null | grep ' ^worktree ' | sed ' s/^worktree //' | grep -v ' \.bare$' )
81+ COMPREPLY=($( compgen -W " $worktrees " -- " $cur " ) )
82+ fi
7883 ;;
7984 esac
8085}
Original file line number Diff line number Diff line change @@ -85,8 +85,13 @@ complete -c git-wt -n '__fish_git_wt_using_command list' -s h -l help -d 'Show h
8585complete -c git-wt -n ' __fish_git_wt_using_command migrate' -s h -l help -d ' Show help'
8686
8787# lock/unlock/move/prune/repair completions
88+ complete -c git-wt -n ' __fish_git_wt_using_command lock' -s h -l help -d ' Show help'
8889complete -c git-wt -n ' __fish_git_wt_using_command lock' -xa ' (__fish_git_wt_worktrees)'
90+ complete -c git-wt -n ' __fish_git_wt_using_command unlock' -s h -l help -d ' Show help'
8991complete -c git-wt -n ' __fish_git_wt_using_command unlock' -xa ' (__fish_git_wt_worktrees)'
92+ complete -c git-wt -n ' __fish_git_wt_using_command move' -s h -l help -d ' Show help'
9093complete -c git-wt -n ' __fish_git_wt_using_command move' -xa ' (__fish_git_wt_worktrees)'
94+ complete -c git-wt -n ' __fish_git_wt_using_command prune' -s h -l help -d ' Show help'
9195complete -c git-wt -n ' __fish_git_wt_using_command prune' -xa ' (__fish_git_wt_worktrees)'
96+ complete -c git-wt -n ' __fish_git_wt_using_command repair' -s h -l help -d ' Show help'
9297complete -c git-wt -n ' __fish_git_wt_using_command repair' -xa ' (__fish_git_wt_worktrees)'
Original file line number Diff line number Diff line change @@ -63,7 +63,9 @@ _git-wt() {
6363 ' (-h --help)' {-h,--help}' [Show help]'
6464 ;;
6565 lock|unlock|move|prune|repair)
66- _arguments ' *:worktree:__git_wt_worktrees'
66+ _arguments \
67+ ' (-h --help)' {-h,--help}' [Show help]' \
68+ ' *:worktree:__git_wt_worktrees'
6769 ;;
6870 esac
6971 ;;
You can’t perform that action at this time.
0 commit comments