'Bash tab completion for command called by time
A custom command based (complete -C ...) completion works fine when invoked from the top level. Like
my-command <Tab>
Completion code
package main
import "fmt"
func main() {
fmt.Println("foo")
}
The completion command is provided with 3 arguments - completed command name, current word and previous word - and 4 envirnoment variables - COMP_KEY, COMP_LINE, COMP_POINT, COMP_TYPE - as described in documentation chapter Programmable Completion Builtins.
However when invoked with time prefix (to measure execution time), like
time my-command <Tab>
the completion command is invoked without COMP_LINE and COMP_POINT environment variables set and arguments are set to compget, current word and empty string. Also warning
bash: compgen: warning: -C option may not work as you expect
is printed.
I have 2 questions
- Is the changed way the completion command is called result of insufficient implementation of completion for
timecommand, or general limitation of command based completion (complete -C)? - How to make it work? How to get rid of the warning and get necessary state data from the completion command - at least a string of line being completed and current cursor position?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
