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

Add plugin-pyenv as an available function for fish #3

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

<img src="https://cdn.rawgit.com/oh-my-fish/oh-my-fish/e4f1c2e0219a17e2c748b824004c8d0b38055c16/docs/logo.svg" align="left" width="144px" height="144px"/>

# Pyenv Plugin for Fish Shell
Use [Pyenv](https://github.com/pyenv/pyenv) with [fish shell](https://fishshell.com) managed by [Oh my fish](https://github.com/oh-my-fish/oh-my-fish) in a very simple way!

<br />
<br />

## Installation

```fish
omf update # Just if your omf installation is old. Avoids missing the package
omf install pyenv
```
> omf (Oh my fish) is a package manager for fish shell. Just like pip is for Python and gem is for Ruby

## Usage

Just add the following line in your ```config.fish``` file:
Copy link
Member

@scorphus scorphus Jun 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The beauty of plugins is them being able to just work out of the box, with the least possible being left up to the user. That means the init function of a plugin does all the witchery.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally agree. I did not find how to create this init. Since it is possible, this function may do that easier for users.


```fish
# Initializes Pyenv
pyenv-init
```

This will initialize pyenv every time a new Fish session starts.
And that is all!
16 changes: 16 additions & 0 deletions functions/pyenv-init.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

function pyenv-init --description "Pyenv initialization script for fish shell"

# Checks if directories already exists. If not, creates then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't pyenv take care of this? And is it really necessary to check every time a new session is created?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could also be solved by the init function. It is not necessary to run that on every new session.

for dir in "shims" "bin"
if not test -d $HOME/pyenv/$dir
mkdir -p $HOME/pyenv/$dir
end
end

# Respects if PYENV_ROOT exists. Otherwise, sets it to a default directory
set --query PYENV_ROOT; or set --local PYENV_ROOT $HOME/.pyenv

# Appends PYENV_ROOT directories to PATH variable
set PATH $PYENV_ROOT/shims $PYENV_ROOT/bin $PATH
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this might be something related to making pyenv command available, but my experience tells me shims suffices. Not sure how it works on OSs other than OS X thou.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really do not know this behavior in other OSs. I just keep the way this plugin did.

end
3 changes: 0 additions & 3 deletions init.fish

This file was deleted.