Skip to content

Commit 2d4edc1

Browse files
committed
Add autocompletion for Fish Shell
1 parent c67c8c2 commit 2d4edc1

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ jobs:
2727
- name: Run Shellcheck
2828
run: |
2929
./shellcheck --version
30-
./shellcheck -e SC2148 wt completions/*
30+
./shellcheck -e SC2148 wt completions/_wt_completion completions/wt_completion

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ sudo cp completions/_wt_completion <one-of-$fpath>
4141

4242
exec zsh
4343
```
44+
45+
**For Fish**
46+
```bash
47+
cp completions/wt.fish ~/.config/fish/completions
48+
```
4449
---
4550
Tab autocompletion works for switching between your worktrees.
4651
```bash

completions/wt.fish

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# AUTOCOMPLETION FOR FISH
2+
# Reference: https://fishshell.com/docs/current/completions.html
3+
4+
# wt list: list all the available worktrees
5+
# | awk '{ print $1; }': grab the first column of the output
6+
# | tr "\n" " ": replace line break character with space to put the worktrees on single line
7+
# separated by space
8+
9+
set list (wt list | awk '{ print $1; }' | tr "\n" " ")
10+
set opts ""
11+
12+
for item in (string split " " "$list")
13+
set -a opts (basename -- "$item")
14+
end
15+
16+
complete -c wt -f -a "$opts"

0 commit comments

Comments
 (0)