question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Autocomplete for file names doesn't work (partially) [bash]

See original GitHub issue

Hello! When I use autocompletion script from here https://github.com/iterative/dvc.org/blob/master/static/docs/user-guide/autocomplete.md it doesn’t complete file and directory names from current directory for the command dvc repro .... But if I add some flag, for example dvc repro --force ... then it works fine. What should be changed in bash autocomplete script to allow autocompletion for dvc repro ... without any flags?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:5
  • Comments:19 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
g-simmons2commented, Dec 19, 2019

Not having the completions is definitely annoying, I switched to zsh just to have them 😃

Would it be possible to make the completions work for 3-token commands (not sure if this is the right terminology) - for example dvc pipeline show <tab to choose a file>?

The current behavior for dvc pipeline show <tab> is to list the available options:

 -- option --
--help     -h  -- Show help message related to the command.                                                                                             
--quiet    -q  -- Be quiet.                                                                                                                             
--verbose  -v  -- Be verbose. 

And the output for dvc pipeline show incomplete_filename<tab> is

-- no more arguments --

meaning one has to type the complete filename by hand.

Would certainly be a nice to have!

2reactions
ghostcommented, Apr 25, 2019

ohh my bad, @belskikh ! 🙈

I don’t have a good understanding of Bash’s completion engine, but you’ll need to add something like compgen -f -X '!*.dvc' over here https://github.com/iterative/dvc/blob/dd8598e53ea03aaa7554c6ebf8fa7fe37baffc31/scripts/completion/dvc.bash#L57-L63

Be aware that some commands accepts something more than just stage files (the ones ending in .dvc).

The script itself have some references that you can look up to understand how the file was created, I’ll leave you with one more: https://www.linuxjournal.com/content/more-using-bash-complete-command

By the way, installing Zsh is not that hard:

# Download and install from the package repository 
sudo apt-get install zsh

#[ch]ange [sh]ell to Zsh
chsh -s $(which zsh)

And you are all set!

If you want colors and stuff like that, I can recommend you the pure prompt

I’m currently using spaceship-prompt but requires a little bit more of configuration.

There’s also geometry prompt

Those are my favorites 😅 .

Anyways, if you manage to make completion work with bash it would be awesome! good luck 🦆

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bash Auto-completion with Tab button doesn't ... - Super User
In my Kubuntu there is no /usr/share/bash-completion/completions/vim file, but the file /usr/share/bash-completion/bash_completion.
Read more >
Why bash disables autocompletion for some commands and ...
I have files starting with "ba" in my home/working dir. When I type "ba[tab]" at the prompt, I do not get these names,...
Read more >
bash filename autocomplete - does it have to use so much ...
I have a vague memory of this working in the past, but can't find any info now. Using TAB in bash to show...
Read more >
How to autocomplete long file names in terminal - Server Fault
If I have in current directory a file with a long name starting with "build" I can write in console "build", press Tab...
Read more >
How do I make Vim do normal (Bash-like) tab completion for ...
If you don't want to set the wildmenu, you can always press Ctrl + L when you want to open a file. Ctrl...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found