-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New completions package with embedded scripts in binary
Our completion scripts can be embedded as global strings. New zsh-completion and bash-completion subcommands print these embedded strings to stdout. Users can source them from their startup scripts: source <(dstask zsh-completion) Add symlinks at original completion script locations
- Loading branch information
Showing
8 changed files
with
92 additions
and
68 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
completions/bash.sh |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
completions/zsh.sh |
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# wire bash completions to dstask completion engine. Some of the workarounds for | ||
# idiosyncrasies around separation with colons taken from /etc/bash_completion | ||
|
||
_dstask() { | ||
# reconstruct COMP_WORDS to re-join separations caused by colon (which is a default separator) | ||
# yes, this method ends up splitting by spaces, but that's not a problem for the dstask parser | ||
# see http://tiswww.case.edu/php/chet/bash/FAQ | ||
original_args=( $(echo "${COMP_WORDS[@]}" | sed 's/ : /:/g' | sed 's/ :$/:/g') ) | ||
|
||
# hand to dstask as canonical args | ||
COMPREPLY=( $(dstask _completions "${original_args[@]}") ) | ||
|
||
# convert dstask's suggestions to remove prefix before colon so complete can understand it | ||
local last_arg="${original_args[-1]}" | ||
local colon_word=${last_arg%"${last_arg##*:}"} | ||
local i=${#COMPREPLY[*]} | ||
while [[ $((--i)) -ge 0 ]]; do | ||
COMPREPLY[$i]=${COMPREPLY[$i]#"$colon_word"} | ||
done | ||
} | ||
|
||
complete -F _dstask dstask | ||
complete -F _dstask task | ||
#complete -F _dstask n | ||
#complete -F _dstask t |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package completions | ||
|
||
import _ "embed" | ||
|
||
//go:embed zsh.sh | ||
var Zsh string | ||
|
||
//go:embed bash.sh | ||
var Bash string |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#compdef dstask | ||
#autoload | ||
|
||
|
||
_dstask() { | ||
compadd -- $(dstask _completions "${words[@]}") | ||
} | ||
|
||
compdef _dstask dstask |
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