tralph3 / ddi

A safer dd
GNU General Public License v3.0
81 stars 3 forks source link

Shell completion? #1

Open farzadmf opened 3 years ago

farzadmf commented 3 years ago

Hi, thank you for the nice tool, but I think it would be nice if it provided shell completion as well

tralph3 commented 3 years ago

Oh, I didn't notice it didn't have it, one would think that comes without doing anything extra. I'll take a look and see how I can implement that, I made this to learn Rust after all.

farzadmf commented 3 years ago

That's nice. I guess if you're only wrapping calls to dd, it may be a bit harder since usually completion scripts are generated by the arguments/etc you define in your program. But if that's not the case, then it may need some more work.

tralph3 commented 3 years ago

Oh man this may be a real headache.

farzadmf commented 3 years ago

Yup, I agree :slightly_smiling_face:

tralph3 commented 3 years ago

This seems to be a bigger problem than what I'm willing to tackle currently. I'll need to read more about how this all works to even know if it's possible to implement without literally taking all of dd's arguments aswell. I'll leave the issue open, but I'll have to take a look at this later.

farzadmf commented 3 years ago

True, makes sense

tralph3 commented 3 years ago

I've been researching this. I'm trying to add the already existing dd completions for ddi, since they should be the same. I got this to work with bash with the bash-completion package. It ships with a completion script for dd, which after a bit of modification works perfectly with ddi. However I'm trying to do the same with zsh, and it just ain't working.

Zsh stores the competion scripts in /usr/share/zsh/functions/Completions/, the dd one specifically in the Unix folder inside that directory, in a file called _dd. I tried to just copy the file, change the name to _ddi and change the first line which says for what command this is for from #compdef dd gdd to #compdef ddi. It doesn't work. I tried a lot of variations, and I just can't get it to work.

Anybody knows anything about this?

farzadmf commented 3 years ago

Hey @tralph3 , I actually followed what you mentioned, and for me it was like this:

tralph3 commented 3 years ago

Hmm.... it still ain't working for me... _dd was in the same folder than yours, I just didn't provide a full path in one go. Anyways, I removed the _ddi file from the Completion/Unix directory and moved it to site-functions. Yes the first line is changed as it should, but it still ain't working. Normal dd does work tho...

farzadmf commented 3 years ago

Did you open a new shell? I have a feeling this is a shell/caching issue :thinking: but of course I may be wrong

tralph3 commented 3 years ago

Yes, multiple times.

tralph3 commented 3 years ago

Can you check your zshrc and see if you have something that loads these scripts? Maybe it needs configuration.

farzadmf commented 3 years ago

I'm not sure if that would be helpful :stuck_out_tongue: I have a million things in my zsh, I use antigen; maybe that's doing something.

I'll try to set up with a minimal zshrc to see what happens with that when I get some time :slightly_smiling_face: