Skip to main content
Alioth migration.
Source Link
Stephen Kitt
  • 481.4k
  • 60
  • 1.2k
  • 1.4k

Quick answer:

I suppose that you use MacOSX with brew.

Try:

brew update
brew install bash-completion
brew info bash-completion
# bash-completion: stable 1.3
. $(brew --prefix)/etc/bash_completion
complete -p sudo

You should see something like this:

complete -F _root_command sudo

Test:

function _comp_foo() { COMPREPLY=($(compgen -W 'a b c' -- "$2")); }
complete -F _comp_foo foo

Type foo SpaceTabTab
You should see a b c

Type sudo foo SpaceTabTab
You should see a b c

Then remove complete -fc sudo from your initialisation files (~/.bash_profile, ~/.bashrc etc)
Add the following lines to your initialisation files:

if [ -f $(brew --prefix)/etc/bash_completion ]; then
  . $(brew --prefix)/etc/bash_completion
fi

# Your compspec here
complete -o default -o nospace -W "$(sudo ls -1 /var/cache/salt/master/minions)" salt

Reopen terminal.
Type complete -p sudo.
You should see complete -F _root_command sudo.

Type complete -p salt.
You should see something like this:

complete -o default -o nospace -W 'a
b
c' salt

bash-completion2. note*:
You can install bash-completion2: https://github.com/Homebrew/homebrew/issues/19258
But:

  • 2.* works with Bash 4.*
  • 2.* uses the -D option for compspecs lazy loading. So, complete -p sudo outputs complete: sudo: no completion specification until you type sudoSpaceTab

Quick answer:

  • Install bash-completion
  • Source bash_completion on Bash startup
  • Add your compspec on Bash startup
  • Don't overwrite sudo compspec with complete -cf sudo

I suppose that you use MacOSX with brew.

Try:

brew update
brew install bash-completion
brew info bash-completion
# bash-completion: stable 1.3
. $(brew --prefix)/etc/bash_completion
complete -p sudo

You should see something like this:

complete -F _root_command sudo

Test:

function _comp_foo() { COMPREPLY=($(compgen -W 'a b c' -- "$2")); }
complete -F _comp_foo foo

Type foo SpaceTabTab
You should see a b c

Type sudo foo SpaceTabTab
You should see a b c

Then remove complete -fc sudo from your initialisation files (~/.bash_profile, ~/.bashrc etc)
Add the following lines to your initialisation files:

if [ -f $(brew --prefix)/etc/bash_completion ]; then
  . $(brew --prefix)/etc/bash_completion
fi

# Your compspec here
complete -o default -o nospace -W "$(sudo ls -1 /var/cache/salt/master/minions)" salt

Reopen terminal.
Type complete -p sudo.
You should see complete -F _root_command sudo.

Type complete -p salt.
You should see something like this:

complete -o default -o nospace -W 'a
b
c' salt

bash-completion2. note*:
You can install bash-completion2: https://github.com/Homebrew/homebrew/issues/19258
But:

  • 2.* works with Bash 4.*
  • 2.* uses the -D option for compspecs lazy loading. So, complete -p sudo outputs complete: sudo: no completion specification until you type sudoSpaceTab

Quick answer:

  • Install bash-completion
  • Source bash_completion on Bash startup
  • Add your compspec on Bash startup
  • Don't overwrite sudo compspec with complete -cf sudo

I suppose that you use MacOSX with brew.

Try:

brew update
brew install bash-completion
brew info bash-completion
# bash-completion: stable 1.3
. $(brew --prefix)/etc/bash_completion
complete -p sudo

You should see something like this:

complete -F _root_command sudo

Test:

function _comp_foo() { COMPREPLY=($(compgen -W 'a b c' -- "$2")); }
complete -F _comp_foo foo

Type foo SpaceTabTab
You should see a b c

Type sudo foo SpaceTabTab
You should see a b c

Then remove complete -fc sudo from your initialisation files (~/.bash_profile, ~/.bashrc etc)
Add the following lines to your initialisation files:

if [ -f $(brew --prefix)/etc/bash_completion ]; then
  . $(brew --prefix)/etc/bash_completion
fi

# Your compspec here
complete -o default -o nospace -W "$(sudo ls -1 /var/cache/salt/master/minions)" salt

Reopen terminal.
Type complete -p sudo.
You should see complete -F _root_command sudo.

Type complete -p salt.
You should see something like this:

complete -o default -o nospace -W 'a
b
c' salt

bash-completion2. note*:
You can install bash-completion2: https://github.com/Homebrew/homebrew/issues/19258
But:

  • 2.* works with Bash 4.*
  • 2.* uses the -D option for compspecs lazy loading. So, complete -p sudo outputs complete: sudo: no completion specification until you type sudoSpaceTab
Add info about complete -p salt
Source Link
Evgeny
  • 5.7k
  • 4
  • 40
  • 46

Quick answer:

  • Install bash-completion
  • Source bash_completion on Bash startup
  • Add your compspec on Bash startup
  • Don't overwrite sudo compspec with complete -cf sudo

I suppose that you use MacOSX with brew.

Try:

brew update
brew install bash-completion
brew info bash-completion
# bash-completion: stable 1.3
. $(brew --prefix)/etc/bash_completion
complete -p sudo

You should see something like this:

complete -F _root_command sudo

Test:

function _comp_foo() { COMPREPLY=($(compgen -W 'a b c' -- "$2")); }
complete -F _comp_foo foo

Type foo SpaceTabTab
You should see a b c

Type sudo foo SpaceTabTab
You should see a b c

Then remove complete -fc sudo from your initialisation files (~/.bash_profile, ~/.bashrc etc)
Add the following lines to your initialisation files:

if [ -f $(brew --prefix)/etc/bash_completion ]; then
  . $(brew --prefix)/etc/bash_completion
fi

# Your compspec here
complete -o default -o nospace -W "$(sudo ls -1 /var/cache/salt/master/minions)" salt

Reopen terminal.
Type complete -p sudo.
You should see complete -F _root_command sudo.

Type complete -p salt.
You should see something like this:

complete -o default -o nospace -W 'a
b
c' salt

bash-completion2. note*:
You can install bash-completion2: https://github.com/Homebrew/homebrew/issues/19258
But:

  • 2.* works with Bash 4.*
  • 2.* uses the -D option for compspecs lazy loading. So, complete -p sudo outputs complete: sudo: no completion specification until you type sudoSpaceTab

Quick answer:

  • Install bash-completion
  • Source bash_completion on Bash startup
  • Add your compspec on Bash startup
  • Don't overwrite sudo compspec with complete -cf sudo

I suppose that you use MacOSX with brew.

Try:

brew update
brew install bash-completion
brew info bash-completion
# bash-completion: stable 1.3
. $(brew --prefix)/etc/bash_completion
complete -p sudo

You should see something like this:

complete -F _root_command sudo

Test:

function _comp_foo() { COMPREPLY=($(compgen -W 'a b c' -- "$2")); }
complete -F _comp_foo foo

Type foo SpaceTabTab
You should see a b c

Type sudo foo SpaceTabTab
You should see a b c

Then remove complete -fc sudo from your initialisation files (~/.bash_profile, ~/.bashrc etc)
Add the following lines to your initialisation files:

if [ -f $(brew --prefix)/etc/bash_completion ]; then
  . $(brew --prefix)/etc/bash_completion
fi

# Your compspec here
complete -o default -o nospace -W "$(sudo ls -1 /var/cache/salt/master/minions)" salt

Reopen terminal.
Type complete -p sudo.
You should see complete -F _root_command sudo.

bash-completion2. note*:
You can install bash-completion2: https://github.com/Homebrew/homebrew/issues/19258
But:

  • 2.* works with Bash 4.*
  • 2.* uses the -D option for compspecs lazy loading. So, complete -p sudo outputs complete: sudo: no completion specification until you type sudoSpaceTab

Quick answer:

  • Install bash-completion
  • Source bash_completion on Bash startup
  • Add your compspec on Bash startup
  • Don't overwrite sudo compspec with complete -cf sudo

I suppose that you use MacOSX with brew.

Try:

brew update
brew install bash-completion
brew info bash-completion
# bash-completion: stable 1.3
. $(brew --prefix)/etc/bash_completion
complete -p sudo

You should see something like this:

complete -F _root_command sudo

Test:

function _comp_foo() { COMPREPLY=($(compgen -W 'a b c' -- "$2")); }
complete -F _comp_foo foo

Type foo SpaceTabTab
You should see a b c

Type sudo foo SpaceTabTab
You should see a b c

Then remove complete -fc sudo from your initialisation files (~/.bash_profile, ~/.bashrc etc)
Add the following lines to your initialisation files:

if [ -f $(brew --prefix)/etc/bash_completion ]; then
  . $(brew --prefix)/etc/bash_completion
fi

# Your compspec here
complete -o default -o nospace -W "$(sudo ls -1 /var/cache/salt/master/minions)" salt

Reopen terminal.
Type complete -p sudo.
You should see complete -F _root_command sudo.

Type complete -p salt.
You should see something like this:

complete -o default -o nospace -W 'a
b
c' salt

bash-completion2. note*:
You can install bash-completion2: https://github.com/Homebrew/homebrew/issues/19258
But:

  • 2.* works with Bash 4.*
  • 2.* uses the -D option for compspecs lazy loading. So, complete -p sudo outputs complete: sudo: no completion specification until you type sudoSpaceTab
Add salt compspec
Source Link
Evgeny
  • 5.7k
  • 4
  • 40
  • 46

Quick answer:

  • Install bash-completion
  • Source bash_completion on Bash startup
  • Add your compspec on Bash startup
  • Don't overwrite sudo compspec with complete -cf sudo

I suppose that you use MacOSX with brew.

Try:

brew update
brew install bash-completion
brew info bash-completion
# bash-completion: stable 1.3
. $(brew --prefix)/etc/bash_completion
complete -p sudo

You should see something like this:

complete -F _root_command sudo

Test:

function _comp_foo() { COMPREPLY=($(compgen -W 'a b c' -- "$2")); }
complete -F _comp_foo foo

Type foo SpaceTabTab
You should see a b c

Type sudo foo SpaceTabTab
You should see a b c

Then remove complete -fc sudo from your initialisation files (~/.bash_profile, ~/.bashrc etc)
Add the following lines to your initialisation files:

if [ -f $(brew --prefix)/etc/bash_completion ]; then
  . $(brew --prefix)/etc/bash_completion
fi

# Your compspec here
complete -o default -o nospace -W "$(sudo ls -1 /var/cache/salt/master/minions)" salt

Reopen terminal.
Type complete -p sudo.
You should see complete -F _root_command sudo.

bash-completion2. note*:
You can install bash-completion2: https://github.com/Homebrew/homebrew/issues/19258
But:

  • 2.* works with Bash 4.*
  • 2.* uses the -D option for compspecs lazy loading. So, complete -p sudo outputs complete: sudo: no completion specification until you type sudoSpaceTab

Quick answer:

I suppose that you use MacOSX with brew.

Try:

brew update
brew install bash-completion
brew info bash-completion
# bash-completion: stable 1.3
. $(brew --prefix)/etc/bash_completion
complete -p sudo

You should see something like this:

complete -F _root_command sudo

Test:

function _comp_foo() { COMPREPLY=($(compgen -W 'a b c' -- "$2")); }
complete -F _comp_foo foo

Type foo SpaceTabTab
You should see a b c

Type sudo foo SpaceTabTab
You should see a b c

Then remove complete -fc sudo from your initialisation files (~/.bash_profile, ~/.bashrc etc)
Add the following lines to your initialisation files:

if [ -f $(brew --prefix)/etc/bash_completion ]; then
  . $(brew --prefix)/etc/bash_completion
fi

Reopen terminal.
Type complete -p sudo.
You should see complete -F _root_command sudo.

bash-completion2. note*:
You can install bash-completion2: https://github.com/Homebrew/homebrew/issues/19258
But:

  • 2.* works with Bash 4.*
  • 2.* uses the -D option for compspecs lazy loading. So, complete -p sudo outputs complete: sudo: no completion specification until you type sudoSpaceTab

Quick answer:

  • Install bash-completion
  • Source bash_completion on Bash startup
  • Add your compspec on Bash startup
  • Don't overwrite sudo compspec with complete -cf sudo

I suppose that you use MacOSX with brew.

Try:

brew update
brew install bash-completion
brew info bash-completion
# bash-completion: stable 1.3
. $(brew --prefix)/etc/bash_completion
complete -p sudo

You should see something like this:

complete -F _root_command sudo

Test:

function _comp_foo() { COMPREPLY=($(compgen -W 'a b c' -- "$2")); }
complete -F _comp_foo foo

Type foo SpaceTabTab
You should see a b c

Type sudo foo SpaceTabTab
You should see a b c

Then remove complete -fc sudo from your initialisation files (~/.bash_profile, ~/.bashrc etc)
Add the following lines to your initialisation files:

if [ -f $(brew --prefix)/etc/bash_completion ]; then
  . $(brew --prefix)/etc/bash_completion
fi

# Your compspec here
complete -o default -o nospace -W "$(sudo ls -1 /var/cache/salt/master/minions)" salt

Reopen terminal.
Type complete -p sudo.
You should see complete -F _root_command sudo.

bash-completion2. note*:
You can install bash-completion2: https://github.com/Homebrew/homebrew/issues/19258
But:

  • 2.* works with Bash 4.*
  • 2.* uses the -D option for compspecs lazy loading. So, complete -p sudo outputs complete: sudo: no completion specification until you type sudoSpaceTab
Source Link
Evgeny
  • 5.7k
  • 4
  • 40
  • 46
Loading