dvc: Autocomplete for file names doesn't work (partially) [bash]
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?
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 5
- Comments: 19 (9 by maintainers)
Commits related to this issue
- completion: fix missing expansions Fixes #1923 — committed to casperdcl/dvc by casperdcl 4 years ago
- Fix bash completion (#3360) * completion: safer function names * completion: fix missing expansions Fixes #1923 * complete: bash: all filenames * complete: bash: DVC-files * complete: ... — committed to iterative/dvc by casperdcl 4 years ago
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:And the output for
dvc pipeline show incomplete_filename<tab>
ismeaning one has to type the complete filename by hand.
Would certainly be a nice to have!
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-L63Be 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:
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 🦆
definitely will do it soon 😃
hah me too 😄
+1 on the annoyed crew here, I’m looking forward for @casperdcl PR 🙄
this is annoying. doesn’t work for me for
dvc add
in the latest version eitherHi, @efiop Yes, I will fix it, if someone helps me