bash_completion

package module
v0.0.20 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 11, 2025 License: MIT Imports: 8 Imported by: 1

README

bash_completion

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BashCompletionAvailable added in v0.0.4

func BashCompletionAvailable() bool

func BashPath added in v0.0.4

func BashPath() string

func InBash added in v0.0.4

func InBash() bool

Types

type Complete

type Complete struct {
	// contains filtered or unexported fields
}

func New

func New(program string, completer Completer, options ...Option) *Complete

func (*Complete) GetEnv

func (me *Complete) GetEnv(k EnvName) (val string, err error)

func (*Complete) Run

func (me *Complete) Run(word, preceedingWord string) error

bash passes word and preceedingWord to the complete command, but it is not used, nor needed

func (*Complete) SetEnv

func (me *Complete) SetEnv(k EnvName, val string) error

type Completer

type Completer interface {
	Complete(args []string, partial string) (suggestions []string, finished bool, err error)
}

type EnvName

type EnvName string
const (
	ENV_COMP_LINE       EnvName = "COMP_LINE"       // The current command line.
	ENV_COMP_POINT      EnvName = "COMP_POINT"      // The index of the current cursor position relative to the beginning of the current command.
	ENV_COMP_KEY        EnvName = "COMP_KEY"        // The key (or final key of a key sequence) used to invoke the current completion function.
	ENV_COMP_TYPE       EnvName = "COMP_TYPE"       // Set to an integer value corresponding to the type of completion attempted that caused a completion function to be called: TAB, for normal completion, ‘?’, for listing completions after successive tabs, ‘!’, for listing alternatives on partial word completion, ‘@’, to list completions if the word is not unmodified, or ‘%’, for menu completion.
	ENV_COMP_WORDS      EnvName = "COMP_WORDS"      // An array variable consisting of the individual words in the current command line. The line is split into words as Readline would split it, using COMP_WORDBREAKS as described above.
	ENV_COMP_CWORD      EnvName = "COMP_CWORD"      // An index into ${COMP_WORDS} of the word containing the current cursor position.
	ENV_COMP_WORDBREAKS EnvName = "COMP_WORDBREAKS" // The set of characters that the Readline library treats as word separators when performing word completion. If COMP_WORDBREAKS is unset, it loses its special properties, even if it is subsequently reset.
)

func (EnvName) String

func (me EnvName) String() string

type Option

type Option func(*Complete)

func WithEnv

func WithEnv(key EnvName, val string) Option

func WithLogger

func WithLogger(logger io.Writer) Option

func WithStdout

func WithStdout(newStdout io.Writer) Option

Directories

Path Synopsis
cmd
bash_info command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL