loopbit / autoenv_fish

Directory-based environments for fish shell users
MIT License
38 stars 4 forks source link

function "cd" shadows function #2

Open unixfile opened 8 years ago

unixfile commented 8 years ago

Using fish version 2.3.1-424-g0a51b17, I get the following error

> source .autoenv/activate.fish --shadow-builtin
function: function name shadows a builtin so you must use '--shadow-builtin'
.autoenv/activate.fish (line 1): function cd
        autoenv_cd "$argv"
                                 ^
in function “enable_autoenv”
        called on line 143 of file .autoenv/activate.fish

from sourcing file .autoenv/activate.fish
        called on standard input

Can be fixed by adding --shadow-builtin to line 126 in activate.fish

Btw, why not merge this repo with the bash repo. Would take away one installation step.

Miguel-Alonso commented 8 years ago

@00001 Will check and fix. Thanks for letting me know!

As for why not merging this with the bash repo, this project actually started as a pull request to do exactly that, see kennethreitz/autoenv#59 for more info.

Miguel-Alonso commented 8 years ago

BTW, if you use fish as your only shell, you don't need to install the standard autoenv, this one will do. If you use several shells (or several users, each with their own shell) and I can do anything to make installation easier, just let me know.

Miguel-Alonso commented 8 years ago

It looks like the "shadow-builtin" is still very much in the air and, as far as I can tell, has been removed from the code base.

Will keep an eye on fish-shell/fish-shell#3000 and implement if the builtin protection comes back again.

unixfile commented 8 years ago

Amazingly fast response I have to say!

As for my setup, I use fish 90 % of the time, but fall back on bash sometimes for compatibility reasons.

I investigated this project as an alternative to direnv, to manage environment variables in one place, but realized that it is not possible because fish assigns them in an idiosyncratic way.

Direnv works, but generates too much noise.

Anyway, thanks for this otherwise very useful project.

CrusaderW commented 7 years ago

I found a bug causing 2 symptoms:

  1. cd doesn't change to the home-folder anymore and instead returns: cd: Unknown error trying to locate directory “”
  2. same goes for cd - instead of switsching back to last directory it returns: cd: Unknown error trying to locate directory “”

here are my dotfiles, so you can see how I included activate.fish: https://github.com/CrusaderW/dotfiles

I'm happy to fork and dig into the problem myself, but as I'm quite new to fish-scripting I need some insight, where the unintended behaviour originates.

And great work with the script. I love it and use it though it causes minor inconvenience.

Miguel-Alonso commented 7 years ago

@CrusaderW thanks for letting me know!

I'll have a look and probably push a fix tomorrow. I must admit that I wasn't aware of the cd - behaviour, never used it myself. And thanks! I'm glad you find it useful (now let's see if I can remove the inconveniences).

dideler commented 7 years ago

@CrusaderW Fish ships with a wrapper function around the builtin cd that understands cd - as changing to the previous directory. When you normally type cd, you're calling the function cd.fish that provides the bells and whistles. But the autoenv script uses builtin cd.

gomes-fdr commented 5 years ago

Hi, Any news about this issue? I recently discover autoenv and I am using fish - but this issue with 'cd' command cause some noise in day use. I am try fix it, no success yet, if you know something...thank you.