Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shims for Fish shell #195

Closed
gf3 opened this issue Feb 16, 2012 · 20 comments
Closed

Shims for Fish shell #195

gf3 opened this issue Feb 16, 2012 · 20 comments

Comments

@gf3
Copy link

gf3 commented Feb 16, 2012

It would be very helpful is rbenv provided shims that were also fish shell compatible. It wouldn't be a huge change, but it'd mean that rbenv could be used in a non-bash/zsh shell. The syntax for fish is actually much more sane than bash.

@kmcphillips
Copy link

I'd like to put in my support for this.

@emcmanus
Copy link

emcmanus commented Jun 7, 2012

Seems the shims are fine, it's the install guide that needs tweaking. Add this to config.fish for rbenv support:

set PATH $HOME/.rbenv/bin $PATH
set PATH $HOME/.rbenv/shims $PATH
rbenv rehash >/dev/null ^&1

@jonsterling
Copy link

Thanks, Ed! :)

@kmcphillips
Copy link

Works like a charm.
You are a gentleman and a scholar.

@sstephenson
Copy link
Contributor

As @emcmanus pointed out, rbenv's shims work fine with Fish or any other shell. You only need Bash installed to use them—it doesn't need to be your shell. The shims are Bash scripts, and you can run them from Fish in the same way that you can run a Ruby or Python script from Fish.

Adding rbenv to your PATH is all that's necessary for it to work. I would accept a patch that adds Fish compatibility for rbenv init so you don't need to manually construct the paths.

@darthdeus
Copy link

It looks like this isn't enough though, since rbenv shell won't work.

@sstephenson
Copy link
Contributor

rbenv shell is just a shortcut for setting the RBENV_VERSION environment variable. You don't lose any functionality without it.

@espen
Copy link

espen commented Jan 23, 2013

I used this to get rbenv shell to work in fish: https://coderwall.com/p/6hja1w

@skalee
Copy link

skalee commented May 2, 2013

When invoking rbenv from fish shell, no environment variables set in your shell are passed. What's more, neither ~/.bashrc nor ~/.bash_profile are read. If you want to customize rbenv, see #375.

@hauleth
Copy link

hauleth commented May 22, 2013

@espen has mentioned mine Coderwall protip, but there is updated version that allow partial Ruby name (the default will be choosen the newest one, still without completion). The Gist can be found there https://gist.github.com/5631243 (give it some love if you can).

@attilagyorffy
Copy link

I understand that this issue has now been closed but I still wonder if we could get this feature implemented the right way. Am I right thinking that we'd only need to make sure that when rbenv init - is called then it should echo fish shell friendly syntax so that fish will be able to evaluate that? In which case I'd rather have it implemented as part of the original rbenv repo than having external workarounds that might get out of sync with the original internals of rbenv...

I also understand that @sstephenson might not want to actively support the fish shell but perhaps we could try to implement an experimental compatibility in the beginning and I'm sure could get support from the fish shell community itself (they seem to be quite friendly and quite responsive as well).

Presumably the file we'd need to change is https://github.com/sstephenson/rbenv/blob/master/libexec/rbenv-init
Am I right? I'm not a shell script magician but I'd rather attempt to do it right in collaboration with somebody if one's up to doing this the right way.

Cheers

@mislav
Copy link
Member

mislav commented Jul 16, 2013

Any fish user is welcome to improve the output of rbenv init so that it supports fish shell and send us a pull request.

@hauleth
Copy link

hauleth commented Jul 16, 2013

Problem is that fish isn't POSIX shell and it will be hard to implement rbenv init in right way to provide support to fish (I assume that there will be then some will want support for csh or tcsh). I think that it should be noted that if someone use non-POSIX shell then he can use one of community functions (and give a links) or (s)he must write it by himself/herself.

@attilagyorffy
Copy link

@hauleth I think you may be mistaken. Based on the comments from @emcmanus and @sstephenson all we need to do is to get rbenv init to produce fish compatible syntax so that it can be evald by fish. A POSIX compatible shell (like bash for that manner) just needs to be installed and not necessarily have to be the shell of your choice. See the comments by @sstephenson above.

I'll fire off an email to the fish community mailing list and initiate the conversation, will try to get some help from the guys there.

@bitboxer
Copy link

The original rbenv shell command calls rbenv sh-shell, which returns a string that is also evald. We could work around it and parse the return code of that call instead of evaling the returned string. Would that be okay? If yes, I could create something that would do this.

@mislav
Copy link
Member

mislav commented Oct 26, 2013

@bitboxer Fish shell should be fully supported by rbenv master. If you find that's not the case, please open a new issue. Thanks!

@SaimonL
Copy link

SaimonL commented Nov 17, 2014

Thank you "emcmanus"
I use fish and was looking for an answer.

As "emcmanus" mentioned, if you are using fish shell then the following worked for me.

TESTED IN

  • Debain
  • Ubuntu
  • Kubuntu
  • Fedora
  • CentOS
  • RedHat Enterprise
vi ~/.config/fish/config.fish
  set PATH $HOME/.rbenv/bin $PATH
  set PATH $HOME/.rbenv/shims $PATH
  rbenv rehash >/dev/null ^&1

Then exit fish and reload fish or just log off and back on again. If can't find the file then that means you just installed fish and did not ran it once. Just run fish and that folder will be created (file may not).

This is fishfish not fish.
http://fishshell.com/

@muloka
Copy link

muloka commented Feb 9, 2015

Thanks @emcmanus and @sstephenson.

AlexWayfer added a commit to AlexWayfer/rbenv that referenced this issue May 30, 2018
zx1986 added a commit to zx1986/xProfile that referenced this issue Dec 12, 2018
jrolfs pushed a commit to jrolfs/rbenv that referenced this issue May 21, 2019
@ChFlick
Copy link

ChFlick commented Mar 9, 2020

Apparently the ^ syntax will be deprecated in the future and is broken in some versions (see this issue here).

Therefore it may be better to use the following syntax instead: rbenv rehash >/dev/null >2&1.

@JelteF
Copy link

JelteF commented Jul 10, 2020

Therefore it may be better to use the following syntax instead: rbenv rehash >/dev/null >2&1.

There's a typo in there 2 and > should be swapped:

rbenv rehash >/dev/null 2>&1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

17 participants