Skip to content

Commit

Permalink
Add autocompletion for Fish Shell
Browse files Browse the repository at this point in the history
  • Loading branch information
yankeexe committed Jan 27, 2022
1 parent c67c8c2 commit 2d4edc1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ jobs:
- name: Run Shellcheck
run: |
./shellcheck --version
./shellcheck -e SC2148 wt completions/*
./shellcheck -e SC2148 wt completions/_wt_completion completions/wt_completion
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ sudo cp completions/_wt_completion <one-of-$fpath>

exec zsh
```

**For Fish**
```bash
cp completions/wt.fish ~/.config/fish/completions
```
---
Tab autocompletion works for switching between your worktrees.
```bash
Expand Down
16 changes: 16 additions & 0 deletions completions/wt.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# AUTOCOMPLETION FOR FISH
# Reference: https://fishshell.com/docs/current/completions.html

# wt list: list all the available worktrees
# | awk '{ print $1; }': grab the first column of the output
# | tr "\n" " ": replace line break character with space to put the worktrees on single line
# separated by space

set list (wt list | awk '{ print $1; }' | tr "\n" " ")
set opts ""

for item in (string split " " "$list")
set -a opts (basename -- "$item")
end

complete -c wt -f -a "$opts"

0 comments on commit 2d4edc1

Please sign in to comment.