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

Rehab the plugin #5

Merged
merged 4 commits into from
Feb 7, 2020
Merged
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
4 changes: 4 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
The MIT License (MIT)

Copyright (c) 2017 Pablo Aguiar
Copyright (c) 2016 Daniele Sluijters
Copyright (c) 2014 Bruno Ferreira Pinto
Copyright (c) 2013 Yamashita, Yuu
Copyright (c) 2013 Sam Stephenson

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
47 changes: 47 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<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

[![MIT License](https://img.shields.io/badge/license-MIT-007EC7.svg?style=flat-square)](/LICENSE)
[![Fish Shell Version](https://img.shields.io/badge/fish-v2.2.0-007EC7.svg?style=flat-square)](http://fishshell.com)
[![Oh My Fish Framework](https://img.shields.io/badge/Oh%20My%20Fish-Framework-007EC7.svg?style=flat-square)](https://www.github.com/oh-my-fish/oh-my-fish)

<br/>

Use [Pyenv][pyenv] with [fish shell][fish-shell] managed by [Oh my
fish][omf-link] in a very simple way!

## Installation

```fish
omf update # Just in case omf is outdated. 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 use pyenv as you see fit:

```fish
pyenv help
```

Don't forget to check the [docs][pyen-docs]!

# License

[MIT][mit] © [Oh My Fish! Authors][author] et [al][contributors]


[mit]: http://opensource.org/licenses/MIT
[author]: https://github.com/oh-my-fish/plugin-pyenv/blob/master/LICENSE
[contributors]: https://github.com/oh-my-fish/plugin-pyenv/graphs/contributors
[omf-link]: https://github.com/oh-my-fish/oh-my-fish
[fish-shell]: https://fishshell.com
[pyenv]: https://github.com/pyenv/pyenv
[pyenv-docs]: https://github.com/pyenv/pyenv/blob/master/COMMANDS.md#command-reference

[license-badge]: https://img.shields.io/badge/license-MIT-007EC7.svg?style=flat-square
22 changes: 22 additions & 0 deletions completions/pyenv.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
function __fish_pyenv_needs_command
set cmd (commandline -opc)
if [ (count $cmd) -eq 1 -a $cmd[1] = 'pyenv' ]
return 0
end
return 1
end

function __fish_pyenv_using_command
set cmd (commandline -opc)
if [ (count $cmd) -gt 1 ]
if [ $argv[1] = $cmd[2] ]
return 0
end
end
return 1
end

complete -f -c pyenv -n '__fish_pyenv_needs_command' -a '(pyenv commands)'
for cmd in (pyenv commands)
complete -f -c pyenv -n "__fish_pyenv_using_command $cmd" -a "(pyenv completions $cmd)"
end
11 changes: 11 additions & 0 deletions functions/pyenv.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
function pyenv
set cmd $argv[1]
set -e argv[1]

switch "$cmd"
case activate deactivate rehash shell virtualenvwrapper virtualenvwrapper_lazy
command pyenv "sh-$cmd" $argv | source
case '*'
command pyenv "$cmd" $argv
end
end
3 changes: 2 additions & 1 deletion init.fish
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
set -q PYENV_ROOT; or set -l PYENV_ROOT $HOME/.pyenv

set PATH $PYENV_ROOT/shims $PYENV_ROOT/bin $PATH
set PATH $PYENV_ROOT/libexec/pyenv $PYENV_ROOT/libexec $PYENV_ROOT/shims $PYENV_ROOT/bin $PATH 2> /dev/null
setenv PYENV_SHELL fish