Giter Site home page Giter Site logo

Comments (9)

DannyBen avatar DannyBen commented on July 23, 2024 1

Well, I suggested you try the standalone-file-in-the-completions-directory route, mainly as a measure of debugging.
if it works in this approach - it means your zshrc is not loaded properly.
If it does not work - it means the zsh bash completion functions are not working properly.

Also simple test: If you do source ~/.zshrc in a terminal where it does not work - does it start to work?

And - sine you have oh-my-zsh - I believe you do not need the autoload calls - oh-my-zsh should already be taking care of this.

Finally - when testing a new approach, be sure to start from a completely new zsh terminal - as I don't know what misconfiguration is carried over to the subshells you open.

Other than this, I am pretty much out of ideas...

from completely.

DannyBen avatar DannyBen commented on July 23, 2024 1

Excellent, thanks for reporting.

No need for autoload or compinit stuff.

I suspect something loads it for you. If you have OhMyZsh, I think it does this.

from completely.

DannyBen avatar DannyBen commented on July 23, 2024

Well, I can try, but I am not a zsh user myself, so I can only propose some thing sto try.

First of all - we are talking about ~/.zshrc - in your home directory yes? if so, then you should not need to source it - any new zsh terminal you open should source it on its own. To test it put some "export WORKS=1" in it or something, to verify it is loaded.

If it isn't, then perhaps there is another initialization script that zsh loads instead of this one.

Another thing to consider, is are you using oh-my-zsh or not. I believe oh-my-zsh already comes with these autoload commands.

Finally - instead of using eval to add the completion script to the system, there are alternative ways - like putting the completions script in the completions directory. See if your system has any of these directories, and you can put the script there:

/usr/share/bash-completion/completions
/usr/local/etc/bash_completion.d

from completely.

RicardoM17 avatar RicardoM17 commented on July 23, 2024

Hi @DannyBen. Thanks for the quick reply!

Yes I meant ~/.zshrc and I don't source when opening a new terminal, as like you said opening a new terminal sources it on it's own. It does get loaded properly as I have some exports already working there for example.

I am using oh-my-zsh yes, and so are my colleagues but unfortunately I can't get it to work on my system.

I have the the first directory you mentioned:

/usr/share/bash-completion/completions and it's quite populated. Should I create a symlink here to the scripts that are generated by bashly i.e. to send_completions.sh ?

And in this case what should I have in ~/.zshrc if anything?

Once again thanks a lot for all the help

from completely.

DannyBen avatar DannyBen commented on July 23, 2024

Hmm. Ok - since you have oh-my-zsh - I would try these actions:

  1. From your ~/.zshrc - comment out the two autoload functions - I know that if these are called more than once they may cause a problem. What we are trying to test here, is perhaps oh-my-zsh loads these functions elsewhere.
  2. Leave the eval in there for the time being.
  3. Start a fresh new terminal, see if it works.

If you gat any error now about complete: function not found than we need to bring the two autoload calls back.

If you get no error, but the completions are not working, try typing the eval in the command line:

eval "$(my_script completions)"

If after this, you DO have completions, then it is definitely something fishy in your zsh init, and probably beyond the scope of my understanding.

Finally, if we are still not operational at this point, I would also remove the eval from the ~/.zshrc and instead, put the completions script in the directory we mentioned earlier.

Take a look at some of the other scripts that exist there, to get an idea of how they should look.
To get a similar script to put there, you can run bashly add comp script my-completions.bash.

And - just to make sure I got it correctly - you are saying that it works ok on other zsh systems? Are they using the same content in their ~/.zshrc? If you have a working system, it would be interesting to compare the two.

from completely.

RicardoM17 avatar RicardoM17 commented on July 23, 2024

Hmm. Ok - since you have oh-my-zsh - I would try these actions:

  1. From your ~/.zshrc - comment out the two autoload functions - I know that if these are called more than once they may cause a problem. What we are trying to test here, is perhaps oh-my-zsh loads these functions elsewhere.
  2. Leave the eval in there for the time being.
  3. Start a fresh new terminal, see if it works.

If you gat any error now about complete: function not found than we need to bring the two autoload calls back.

Just did this, no errors on new terminal, but the same happens. I change ~/.zshrc, open a new terminal it works, open another terminal it doesn't work. (It keeps working in the previous terminal however).

If you get no error, but the completions are not working, try typing the eval in the command line:

eval "$(my_script completions)"

If I do this in the terminal where it doesn't work, nothing happens, and it still doesn't work. If I do it on the terminal where it works, nothing happens and it still works.

If after this, you DO have completions, then it is definitely something fishy in your zsh init, and probably beyond the scope of my understanding.

Finally, if we are still not operational at this point, I would also remove the eval from the ~/.zshrc and instead, put the completions script in the directory we mentioned earlier.

Take a look at some of the other scripts that exist there, to get an idea of how they should look. To get a similar script to put there, you can run bashly add comp script my-completions.bash.

Ideally I would still be able to do this off the send_completions.sh, just because we have this in a repo and it is updated quite often.

And - just to make sure I got it correctly - you are saying that it works ok on other zsh systems? Are they using the same content in their ~/.zshrc? If you have a working system, it would be interesting to compare the two.

Yes, in a laptop from a colleague of mine he has eval "$(sfl completions)" in his ~/.zshrc and it worked. He did try the autoload commands and eventually it started working and it never stopped. He also just installed zsh and oh-my-zsh recently so everything is rather clean.

Re installing my zsh will be my final resort but I wanted to avoid that just for all the work it entails.

from completely.

DannyBen avatar DannyBen commented on July 23, 2024

I am closing this. If new facts come to light we can reopen.

from completely.

RicardoM17 avatar RicardoM17 commented on July 23, 2024

FYI I solved this today.

I had source zsh-snap line on my .zshrc which I removed. I suspect this sourced a zsh-autocomplete package, and that was probably messing it up.

So now I just have the eval "$(script comp)" and everything is fine. No need for autoload or compinit stuff.

from completely.

RicardoM17 avatar RicardoM17 commented on July 23, 2024

Excellent, thanks for reporting.

No problem. And thank you for the information and help.

No need for autoload or compinit stuff.

I suspect something loads it for you. If you have OhMyZsh, I think it does this.

Correct. I was just restating this. Indeed it is expected that OhMyZsh does this according to the documentation so it is not necessary.

from completely.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.