:-'Generic Commit'

This commit is contained in:
Your Name
2025-05-28 20:40:20 +12:00
parent 0fc886bbf7
commit dae98a3686
2 changed files with 44 additions and 35 deletions

View File

@ -100,7 +100,9 @@ void DropshellScriptManager::addAutocomplete(const std::string& toolName) {
std::string funcDef;
funcDef += blockStart + "\n";
funcDef += funcName + "() {\n";
funcDef += " COMPREPLY=($(" + toolName + " autocomplete \"${COMP_WORDS[@]:1}\"))\n";
funcDef += " local cur=\"${COMP_WORDS[COMP_CWORD]}\"\n";
funcDef += " mapfile -t completions < <(" + toolName + " autocomplete \"${COMP_WORDS[@]:1:${COMP_CWORD}-1}\")\n";
funcDef += " mapfile -t COMPREPLY < <(compgen -W \"${completions[*]}\" -- \"$cur\")\n";
funcDef += "}\n";
funcDef += blockEnd + "\n";
std::string completeLine = "complete -F " + funcName + " " + toolName + " # dropshell-autocomplete:" + toolName;