I just recently started out with MacOS, but there one some strange completion behaviour with the bash
shell (compared to OpenSuse Linux with tcsh where I come from) that is bugging me:
For example, when I am in $HOME and write Pu on the command line, followed by tabbing for completion, I expected that one of the options shown would be my Public/ directory. However, as long as there are executable files, the completion never shows directories that share the same prefix. Only after entering Publ, the tab completion gives me Public/ as there are no more executables with that prefix.
So my question would be, is there an option to have the completion directly show executables and directories with the given prefix?
I already tried upgrading to bash 4 and installing bash-completion via homebrew but that did not help. I suspect that either the MacOS readline behaves differently or that there are some more setting for .inputrc which I do not know about.
I further know that by starting with ./ I only get directories. This is the bandaid that I use at the moment.
Best Answer
For most shells with a file expansion function what is expanded in
argv[0]
position is an executable found within one of the directories of the PATH variable.If you want to find directories when entered as 1st argument within
bash
orzsh
, simply modifyPATH
as follows:and test it with:
Pub
tabFor
tcsh
the equivalent modification of PATH is obtained with:Warning
To include
.
into thePATH
variable is a security risk. Since this modification any file in the directory where you are will be found as a standard command. This might lead you to execute files you would never had tried to execute otherwise: executables which will cause a core dump in a development directory, or binaries which will make you execute commands to get priviledged access to your system.This risk is the same for any Unix like OS.