[Bug]: System alias ll='ls -l --color=auto' with aliases completion enabled breaks bash file/directory tab completion behavior
Expected behavior
cd $HOME
ll .bash<tab><tab> # should show files/directories that begin with .bash
Current behavior
cd $HOME
ll .bash<tab><tab> # shows all files/directories with the first four characters highlighted as if attempting completion of the ls command. Other behavior may include having all characters after the '.' deleted and showing all files/directories starting with the '.'.
Possible solution
I have not looked into it yet, but it's related to the aliases.completion.bash being enabled.
Context
I've had to either resort to not using the ll alias (not desirable) or disabling the aliases completion (less desirable).
Steps to reproduce
Make sure all aliases, completions, and plugins are disabled. Then:
sudo dnf install bash-completion
bash-it enable completion aliases
bash-it reload
cd $HOME
ll .bash<tab><tab>
Bash-it version
v3.0.2
List of enabled plugins, themes and aliases
Only the following is enabled: completions: aliases
Bash version
5.2.2
Operating system and version
Fedora 36
bash-it doctor output
# How to get: bash-it doctor
→ bash-it doctor
DEBUG: core: main: Loading libraries(except appearance)...
DEBUG: lib: colors: Loading library file...
DEBUG: lib: command_duration: Loading library file...
DEBUG: lib: helpers: Loading library file...
DEBUG: lib: history: Loading library file...
DEBUG: lib: log: Loading library file...
DEBUG: lib: preexec: Loading library file...
DEBUG: lib: preview: Loading library file...
DEBUG: lib: search: Loading library file...
DEBUG: lib: utilities: Loading library file...
DEBUG: core: reloader: Loading all enabled components...
DEBUG: completion: aliases: Loading component...
DEBUG: completion: aliases: Loaded.
DEBUG: core: main: Loading theme 'font'.
DEBUG: core: main: Loading custom aliases, completion, plugins...
DEBUG: core: main: Loading general custom files...
DEBUG: aliases: custom: Loading custom file...
DEBUG: bash-it: custom: Loading custom file...
DEBUG: core: main: Command 'gloobus-preview' does not exist
Your ~/.bashrc
This should be reproducible with the default vanilla .bashrc provided by bash-it.
# How to get: cat ~/.bashrc
Notes
No response
Greetings!
I tried bringing up fedora 36 in docker, installing git and bash-completion via yum, then installing bash-it, then enabling general aliases and alias completion ...
And I am unable to reproduce this bug. Some additional things that might help to share:
$ type ls
$ type ll
$ complete -p ls
$ complete -p ll
# For completions that are type -F, maybe also
$ type <completion_function_name>
With the output of all these, I may get a better since of what is happning.
Additionally, if you were able to reproduce starting from:
$ docker run -it fedora:36
I would be very interested in knowing the steps to repeat in my local docker ...
-D
So by fumbling around, i was able to duplicate this issue in my docker image.
I get the error when I have the --color option in the ll alias in my .bashrc
alias ll='ls -al --color'
If instead I put the color option as an ls alias, I get the correct behavior:
alias ls='ls --color'
alias ll='ls -al'
Lemme know if this relates to your issue ...
So by fumbling around, i was able to duplicate this issue in my docker image.
I get the error when I have the
--coloroption in thellalias in my .bashrcalias ll='ls -al --color'If instead I put the color option as an
lsalias, I get the correct behavior:alias ls='ls --color' alias ll='ls -al'Lemme know if this relates to your issue ...
Yes, it's related to that, as the default bash aliases will set up both ls and ll to include --color=auto.
It's also important to make sure only the aliases completion is turned on and nothing else as the general aliases will overwrite the system ll alias and all will work fine.
And the following package needs to be installed if it is not already:
sudo dnf install bash-completion
I've now updated the original title and post to clarify these things.
One final comment is that I don't use the general aliases, but I do set up my own custom aliases such as alias ll='ls -al' in my BASH_IT_CUSTOM scripts. The problem is that the custom scripts are loaded after the enabled features, so the aliases completion is already run before my custom aliases are set up. Perhaps this should be reversed by default or configurable to be reversed. WDYT?
There are two things we need to address here:
- make custom scripts load before alias completion
- understand why the
--coloroption makes the alias-completion sad. This is a much harder problem
what do you think @davidpfarrell @font ?