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?
Hi @belskikh !
Thanks for the feedback! I suppose you'd like to contribute a fix for it? @mroutis should be able to help with it.
For the record: moved issue from dvc.org repo to dvc repo.
Hi, @efiop
Yes, I will fix it, if someone helps me
@belskikh , are you using the latest version of the script?
It should be working (or at least it does for me), the line that deals with this is the following:
@mroutis I am using this version
https://github.com/iterative/dvc/blob/dd8598e53ea03aaa7554c6ebf8fa7fe37baffc31/scripts/completion/dvc.bash#L1
@mroutis that's awesome, and I will definetly try zsh
, but for standard Ubuntu bash terminal it doesn't work.
Can you help me to understand, what I should add/change in dvc.bash
script to fix it?
ohh my bad, @belskikh ! :see_no_evil:
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 :sweat_smile: .
Anyways, if you manage to make completion work with bash it would be awesome! good luck :duck:
this is annoying. doesn't work for me for dvc add
in the latest version either
@casperdcl , Bash, right?
@mroutis if it was zsh
I'd assign you :D
@casperdcl, please feel free :slightly_smiling_face:
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!
@g-simmons2 definitely possible but you're talking about #1924 (zsh
).
I'll submit a bash
PR soon...
@casperdcl If it works on bash I'll switch back 馃槃
+1 on the annoyed crew here, I'm looking forward for @casperdcl PR 馃檮
looking forward for @casperdcl PR
hah me too :D
Fix coming soon (#3360)!
@casperdcl Should we create a ticket for subdir support?
definitely will do it soon :)
Most helpful comment
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!