-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move worktree names code to the main wt script
It is used in all completions. So, might as well move it into the main script.
- Loading branch information
1 parent
f03da74
commit 524e68b
Showing
4 changed files
with
22 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,4 @@ | ||
# AUTOCOMPLETION FOR FISH | ||
# Reference: https://fishshell.com/docs/current/completions.html | ||
|
||
# if git rev-parse --git-dir &> /dev/null: Only check for completions if the user is in a git repository | ||
# git worktree list --porcelain: list all the available worktrees in a format that's easy to parse | ||
# | awk '/^worktree / { sub("worktree ", ""); print; }': grab only lines beginning with worktree and keep only their path | ||
# | xargs -I{} basename {}: get the basename of each worktree | ||
# separated by space | ||
|
||
function _wt_complete | ||
git rev-parse --git-dir &> /dev/null && git worktree list --porcelain | awk '/^worktree / { sub("worktree ", ""); print; }' | xargs -I{} basename {} | ||
end | ||
|
||
complete -c wt -f -n '__fish_is_nth_token 1' -a "(_wt_complete)" | ||
complete -c wt -f -n '__fish_is_nth_token 1' -a "(wt names)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters