Allow bash completion to complete tasks in other directories (#1303)

This commit is contained in:
JP Bochi
2022-09-23 23:34:55 -04:00
committed by GitHub
parent 76bda4cfd9
commit 7f7275550d
6 changed files with 126 additions and 2 deletions

View File

@@ -25,7 +25,14 @@ _just() {
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
elif [[ ${COMP_CWORD} -eq 1 ]]; then
local recipes=$(just --summary --color never 2> /dev/null)
local recipes=$(just --summary 2> /dev/null)
if echo "${cur}" | grep -qF '/'; then
local path_prefix=$(echo "${cur}" | sed 's/[/][^/]*$/\//')
local recipes=$(just --summary 2> /dev/null -- "${path_prefix}")
local recipes=$(printf "${path_prefix}%s\t" $recipes)
fi
if [[ $? -eq 0 ]]; then
COMPREPLY=( $(compgen -W "${recipes}" -- "${cur}") )
return 0