chubin / chubin/cheat.sh

Autocompletion on Bash on Mac not working

Open
#304 1 comment 0 reactions 0 assignees View on GitHub
waiting-for-feedback
Dominant language
Python
Stars
41.7k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

Each time I'm doing a TAB, I see things like this:

```
-bash: _get_comp_words_by_ref: command not found
```

I can avoid it by catching the errors:

```bash
$ cat ~/.bash.d/cht.sh
_cht_complete()
{
local cur prev opts
_get_comp_words_by_ref -n : cur 2>/dev/null

COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="$(curl -s cheat.sh/:list)"

if [ ${COMP_CWORD} = 1 ]; then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
__ltrim_colon_completions "$cur" 2>/dev/null
fi
return 0
}
complete -F _cht_complete cht.sh
```

Notice the `2>/dev/null` for both commands.

Contributor guide

Open the contributing guide

Research direction

Start with the Bash completion entry point in ~/.bash.d/cht.sh and reproduce the TAB completion error on macOS. Check the availability of _get_comp_words_by_ref and __ltrim_colon_completions in the completion environment. Done means cht.sh completion works without requiring error suppression.

Written by the indexing model from the issue text.

Assessment

Tech stack
bash
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.