1

I'm new in macOS and I'm using macOS Sierra,

In my Ubuntu and other Linux-based system, terminal has an auto-complete that helps to complete commands and their options.

For example for wget and other commands, in additional to command completion, after pressing Tab 2 times, it lists all command options (if any), or in sudo w it list all commands start with w

Ubuntu terminal auto-compelete

But on my Mac, it just complete first commands and don't help for options or second part of command like whoami in sudo whoami,

I mean it don't show a list of all command that start with who after pressing Tab 2 times in sudo who

[2]

I found some Scripts for git options at https://github.com/git/git/tree/master/contrib/completion/ , but I want something that do this for all commands and applications.

Is there any solution for that?

2

As @Mark said, bash-completion package adds this functionality to terminal.

1

The completion function is neither coming from any Terminal application or the OS on which you work: MacOS X, Linux…

This function is provided by your shell. To check which one is providing you the completion function you like, just get which shell you are using on Linux with:

echo ${SHELL}

Then change your login shell on MacOS X with:

chsh -s /bin/my_preferred_shell

to use the one which is performing the completion function you want.

Check that this shell exists and is executable, and read the documentation of chsh:

ls -ld /bin/my_preferred_shell

man chsh

To test it without risk, don't restart your session, just open a new Terminal. In case of error, you will be able to run chsh once more.

  • Thanks, so, which shell supports this functionality?I'm using bash – M.A. Heshmat Khah Sep 3 '17 at 17:02
  • Run this command on the environment you'd like to have, not the one you don't like :). – dan Sep 3 '17 at 17:27
  • The function is not usually in the plain shell but in extra packages look for bash_completion for example – Mark Sep 5 '17 at 2:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .