File tree Expand file tree Collapse file tree 3 files changed +39
-3
lines changed
Expand file tree Collapse file tree 3 files changed +39
-3
lines changed Original file line number Diff line number Diff line change @@ -18,13 +18,31 @@ Copy the executable to any directory in your `$PATH`
1818$ sudo cp wt /usr/local/bin
1919```
2020
21- ### Tab Completion
22- :warning : Only ** bash** completion is available for now.
21+ ### Tab Autocompletion :zap :
2322
23+ ** For Bash**
2424``` bash
25- sudo cp wt_completion /etc/bash_completion.d
25+ sudo cp completions/ wt_completion /etc/bash_completion.d
2626```
2727
28+ ** For ZSH**
29+ > Note: completion file for zsh has ` _ ` prefix
30+
31+
32+ Find paths where you can store your completion
33+ ``` bash
34+ print -rl -- $fpath
35+ ```
36+
37+ Copy completion script to one of that location and restart the shell.
38+
39+ ``` bash
40+ sudo cp completions/_wt_completion < one-of-$fpath >
41+
42+ exec zsh
43+ ```
44+ ---
45+ Tab autocompletion works for switching between your worktrees.
2846``` bash
2947wt < TAB> < TAB>
3048
Original file line number Diff line number Diff line change 1+ #compdef wt
2+
3+ # AUTOCOMPLETION FOR ZSH
4+
5+ list="$(wt list | awk '{ print $1; }' | tr "\n" " ")"
6+ declare -A opts
7+
8+ setopt shwordsplit
9+ for item in $list
10+ do
11+ base="$(basename ${item} | xargs)"
12+ opts+=(["$base"]="$base")
13+ done
14+ unsetopt shwordsplit
15+
16+ compadd -Qa opts
Original file line number Diff line number Diff line change 11#! /usr/bin/env bash
22
3+ # AUTOCOMPLETION FOR BASH
4+
35_wt () {
46 local cur opts
57 COMPREPLY=()
You can’t perform that action at this time.
0 commit comments