From 4af5278d737390ff22bd0d5571e3e9ae0f60d236 Mon Sep 17 00:00:00 2001 From: Valentin Maerten Date: Sun, 7 Dec 2025 12:20:45 +0100 Subject: [PATCH] fix: autocomplete works with other binary than 'task' (#2495) --- completion/bash/task.bash | 3 ++- completion/fish/task.fish | 2 +- completion/zsh/_task | 5 +++-- website/src/docs/installation.md | 7 +++++++ 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/completion/bash/task.bash b/completion/bash/task.bash index de93e4c8..0b19329e 100644 --- a/completion/bash/task.bash +++ b/completion/bash/task.bash @@ -1,6 +1,7 @@ # vim: set tabstop=2 shiftwidth=2 expandtab: _GO_TASK_COMPLETION_LIST_OPTION='--list-all' +TASK_CMD="${TASK_EXE:-task}" function _task() { @@ -52,4 +53,4 @@ function _task() __ltrim_colon_completions "$cur" } -complete -F _task task +complete -F _task "$TASK_CMD" diff --git a/completion/fish/task.fish b/completion/fish/task.fish index a6797ed8..383cc629 100644 --- a/completion/fish/task.fish +++ b/completion/fish/task.fish @@ -1,4 +1,4 @@ -set -l GO_TASK_PROGNAME task +set -l GO_TASK_PROGNAME (if set -q GO_TASK_PROGNAME; echo $GO_TASK_PROGNAME; else if set -q TASK_EXE; echo $TASK_EXE; else; echo task; end) # Cache variables for experiments (global) set -g __task_experiments_cache "" diff --git a/completion/zsh/_task b/completion/zsh/_task index d6e0aa61..006b3c8f 100755 --- a/completion/zsh/_task +++ b/completion/zsh/_task @@ -1,6 +1,7 @@ #compdef task -compdef _task task typeset -A opt_args +TASK_CMD="${TASK_EXE:-task}" +compdef _task "$TASK_CMD" _GO_TASK_COMPLETION_LIST_OPTION="${GO_TASK_COMPLETION_LIST_OPTION:---list-all}" @@ -16,7 +17,7 @@ function __task_list() { local -i enabled=0 local taskfile item task desc - cmd=(task) + cmd=($TASK_CMD) taskfile=${(Qv)opt_args[(i)-t|--taskfile]} taskfile=${taskfile//\~/$HOME} diff --git a/website/src/docs/installation.md b/website/src/docs/installation.md index 6b37769d..4a7e03bb 100644 --- a/website/src/docs/installation.md +++ b/website/src/docs/installation.md @@ -332,21 +332,28 @@ config: This method loads the completion script from the currently installed version of task every time you create a new shell. This ensures that your completions are always up-to-date. +If your executable isn’t named task, set the `TASK_EXE` environment variable before running eval. ::: code-group ```shell [bash] # ~/.bashrc + +# export TASK_EXE='go-task' if needed eval "$(task --completion bash)" ``` ```shell [zsh] # ~/.zshrc + +# export TASK_EXE='go-task' if needed eval "$(task --completion zsh)" ``` ```shell [fish] # ~/.config/fish/config.fish + +# export TASK_EXE='go-task' if needed task --completion fish | source ```