Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

It all started with a simple

alias gv='gvim --remote-quiet'

and now gv Space Tab gives nothing where it normally should give filenames. Oddly,

alias gvi='gvim --remote-quiet'

works as expected. I clearly have a workaround, but I'd like to know what is catching my gv for special processing. compopt is no help as gv shares the same settings as ls which does filename completion correctly.

$compopt gv
compopt +o bashdefault +o default +o dirnames -o filenames +o nospace +o plusdirs gv
$ compopt ls
compopt +o bashdefault +o default +o dirnames -o filenames +o nospace +o plusdirs ls

The complete command is slightly more helpful but it doesn't tell me why my two characters got singled out for alteration:

$ complete -p gv
complete -o filenames -F _filedir_xspec gv
$ complete -p ls
complete -o filenames -F _longopt ls
$ complete -p echo
bash: complete: echo: no completion specification
$ alias gvi='gvim --remote-silent'
$ complete -p gvi
bash: complete: gvi: no completion specification

Where did complete -o filenames -F _filedir_xpec gv come from?

share|improve this question
+1 for completeness and <kbd>Space</kbd> <kbd>Tab</kbd> – Aleksandr Levchuk May 28 '11 at 2:31
up vote 9 down vote accepted

I got it, finally. It was hiding in /etc/bash_completions which - ironically - I overlooked as it didn't appear on my filename completions.

The helpful bash_completions thinks that gv means ghostview so it will only allow me to complete filenames that it expects ghostview can handle:

complete -f -X '!*.@(@(?(e)ps|?(E)PS|pdf|PDF)?' gv ggv kghostview

I think that counts as "too damn helpful". Adding

alias gv='gvim --remote-silent'
complete -r gv 

to my ~/.bash_aliases file was sufficient.

share|improve this answer
Compliments! Great troubleshoot! – dag729 May 17 '10 at 23:43

You must log in to answer this question.

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