You are not logged in.
Pages: 1
Topic closed
In bash, tab completion of paths has recently stopped working when issuing vim commands, where the path is deeper than two directories (it continues to work as expected with other commands, such as ls and cd).
For example, pressing tab after
ls .config/btsync/bt
expands to
ls .config/btsync/btsync.conf
and pressing tab after
vim .config/bt
expands to
vim .config/btsync/
However, when pressing tab after
vim .config/btsync/bt
nothing happens.
I would expect it to expand to
vim .config/btsync/btsync.conf
as in the ls example, above.
I have bash-completion installed, there is no 'vim' file in /usr/share/bash-completion/completions/ or /etc/bash_completion.d/
Any suggestions as to the potential cause of this behaviour would be gratefully received!
Update:
I've narrowed this down to vim command in bash will only tab-complete directories, not files.
Last edited by roguewolf (2014-07-26 10:37:50)
Offline
The aliases and functions commands sourced by your bashrc might also help.
"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" - Richard Stallman
Offline
Have you tried tapping 'tab' twice?
Offline
Thanks for the quick replies.
@Trilby: Good point, I've edited my original post to include links.
@Karol: Tapping tab twice also has no effect.
Offline
Have you, by chance, installed bash-completion and managed to misconfigure it?
Offline
@Awebb: I've had bash-completion installed for quite a long time but have never made any (intentional) changes to its configuration.
For information, there is no 'vim' file in /usr/share/bash-completion/completions/ or /etc/bash_completion.d/, I'm not sure if there should be.
Offline
You could find that out, by going to the bash-completion page on the package site and list all files. There is no vim file by default. However, try uninstalling bash-completion, I remember having such an effect due to it.
Offline
I ran
pacman -Qi bash-completion
to get a list of all files installed by that package to find out if there were any vim-related files but, as you mentioned, there are none.
I uninstalled bash-completion but vim path completion still didn't work. I also reinstalled, but still no joy.
I've also just confirmed that the same behaviour occurs when running as su, so that seems to suggest that it's not related to my user configuration?
Offline
Yes, this is a safe assumption. I also reproduced the folder name and file to make sure it's not specific to the string. It works for me. It's a wild guess, but could you check your folder permissions?
Offline
Thank you for sticking with me on this. I've just checked the folder permissions and everything is as I would expect. I can also reproduce the behaviour on a number of folders throughout the filesystem (e.g. with '/usr/share/bash-completion', ironically).
I've also just noticed that it does not seem to be limited to subfolders; if I type
vim .bash
and press TAB, it does not autocomplete to
vim .bashrc
even though the file is present.
Last edited by roguewolf (2014-07-25 14:28:28)
Offline
Also, if I just type 'vim ' (with the trailing space) and press tab twice, only directories are displayed.
If I type 'nano ' and press tab twice, both files and directories are displayed.
So, I think I can narrow this issue down to: vim command in bash will only tab-complete directories, not files.
Offline
It turned out to be due to the completion specifications associated with vim.
complete -p vim
returned
complete -F _filedir_xspec vim
Running
complete -r vim
removed those entries and allowed vim to complete filenames again.
Now to do some research on what the original associated specifications meant and how they ended up there.
Thanks to everyone for their help. Marking as solved.
Offline
Wow, I'm glad I stuck around. I was not aware of the complete command. Nice!
Offline
Wow, I'm glad I stuck around. I was not aware of the complete command. Nice!
bash-completion is built around the complete command
Offline
I have the same output for complete -p vim but don't have the same issue with autocompletion:
$ complete -p vim
complete -F _filedir_xspec vim
$ ls -F test/
a_file somefile some_otherfile.conf this_dir/
$ vim test/<tab><tab>
a_file somefile some_otherfile.conf this_dir/
$ vim test/some<tab><tab>
somefile some_otherfile.conf
$ vim test/some
If I type the '_' and press tab, some_otherfile.conf is autocompleted.
I wonder if the actual problem could be the 'xspec' part. Firefox has the same output for complete -p, but only certain files will autocomplete:
$ complete -p firefox
complete -F _filedir_xspec firefox
$ ls
this_dir a_file arch.htm somefile
$ firefox <tab><tab>
arch.htm this_dir/
$ firefox
So maybe something is limiting which files are autocomplete possibilities for vim.
Last edited by alphaniner (2014-07-28 14:25:15)
But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner
Offline
I've done some more digging.
complete | grep _filedir_xspec
Showed that a large number of commands were using the _filedir_xspec function. All of these commands (those that I tested, at least) exhibited the same 'directory-only' completion behaviour.
I then found the _filedir_xspec function in /usr/share/bash-completion/bash_completion:
_filedir_xspec()
{
local cur prev words cword
_init_completion || return
_tilde "$cur" || return 0
local IFS=$'\n' xspec=${_xspecs[${1##*/}]} tmp
local -a toks
toks=( $(
compgen -d -- "$(quote_readline "$cur")" | {
while read -r tmp; do
printf '%s\n' $tmp
done
}
))
# Munge xspec to contain uppercase version too
# http://thread.gmane.org/gmane.comp.shells.bash.bugs/15294/focus=1 eval xspec="${xspec}"
local matchop=!
if [[ $xspec == !* ]]; then
xspec=${xspec#!}
matchop=@
fi
xspec="$matchop($xspec|${xspec^^})"
toks+=( $(
eval compgen -f -X "!$xspec" -- "\$(quote_readline "\$cur")" | {
while read -r tmp; do
[[ -n $tmp ]] && printf '%s\n' $tmp
done
}
))
if [[ ${#toks[@]} -ne 0 ]]; then
compopt -o filenames
COMPREPLY=( "${toks[@]}" )
fi
}
Although I can't claim to understand everything the function is doing, one thing I do know is that it restricts completion to directories only.
So, I've uninstalled bash-completion and vim is now working as expected (not sure why this didn't work when I tried it previously, although I can't remember if I rebooted on that occasion).
@alphaniner: That is curious, it seems odd that both vim and firefox would share the same function but behave differently. If you run
ls /usr/share/bash-completion/completions/
is there a file for either vim or firefox?
Also, does the _filedir_xspec function in your /usr/share/bash-completion/bash_completion file match the one I posted above?
Offline
I don't have any completions for vim or firefox in /usr/share/bash-completion/completions/ and my _filedir_xspec function matches yours. Regarding the different behaviour I see for vim and firefox, further down in the bash_completions file there's a bunch of calls to _install_xspec, specifically
_install_xspec '*.@([ao]|so|so.!(conf|*/*)|[rs]pm|gif|jp?(e)g|mp3|mp?(e)g|avi|asf|ogg|class)' vi vim gvim rvim ...
_install_xspec '!*.@(?([xX]|[sS])[hH][tT][mM]?([lL]))' netscape mozilla lynx galeon dillo elinks amaya firefox ...
I thought a borked _xspec for vim could have caused the problem you were having (presumably they can be modified elsewhere), but if everything using _filedir_xspec is misbehaving it's probably something else. FWIW I just discovered you can view the 'active' _xspecs with
set |grep "^_xspecs"
But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner
Offline
I have same issue with bash version 4.3.42, but bash version 4.3.11 don't have this issue!!!
bash --version
GNU bash, version 4.3.42(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
./bash --version
GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Offline
Please open a new topic about your problem, this one is old and marked as solved.
https://wiki.archlinux.org/index.php/Fo … bumping.22
https://wiki.archlinux.org/index.php/Fo … ow_to_post
Closing.
Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD
Making lemonade from lemons since 2015.
Offline
Pages: 1
Topic closed