Site Map - skip to main content

Hacker Public Radio

Your ideas, projects, opinions - podcasted.

New episodes every weekday Monday through Friday.
This page was generated by The HPR Robot at


hpr2333 :: VirtualenvWrapper for Fish Shell

In this episode, talk about how I created my own virtualenvwrapper-like interface using Fish Shell.

<< First, < Previous, , Latest >>

Thumbnail of Mr. Young
Hosted by Mr. Young on 2017-07-12 is flagged as Explicit and is released under a CC-BY-SA license.
python, virtualenv, fish shell. 1.
The show is available on the Internet Archive at: https://archive.org/details/hpr2333

Listen in ogg, spx, or mp3 format. Play now:

Duration: 00:13:55

general.

In this episode, talk about how I created my own virtualenvwrapper-like interface using Fish Shell.

Fish Shell is "a smart and user-friendly command line shell for macOS, Linux, and the rest of the family. It excels in tab completion and ease of use, but virtualenvwrapper does not support it.

Virtualenvwrapper, like the name suggests, is a wrapper around python's virtualenv functionality, which allows you to use different versions of python packages in separate environments. To learn more, listen to BJB's show called A bit of background on virtualenvwrapper.

Functions and aliases in my fish config file:

# Set virtual directory root
export set WORKON_HOME=$HOME/Envs

# List virtual environments
alias lsenvs="ls -m $WORKON_HOME | sed 's/\///g'"

# Create python2 virtual environment
function -d "Like virtualenvwrapper for python2" mkvirtualenv2
    virtualenv -p python2 $WORKON_HOME/$argv;
    and source $WORKON_HOME/$argv/bin/activate.fish;
    and echo "Virtual environment created."
end

# Create python3 virtual environment
function -d "Like virtualenvwrapper" mkvirtualenv
    virtualenv -p python3 $WORKON_HOME/$argv;
    and source $WORKON_HOME/$argv/bin/activate.fish;
    and echo "Virtual environment created."
end

# Source a virtual environment
function workon
    source $WORKON_HOME/$argv/bin/activate.fish; and echo "Switch to virtual environment."
end

# Delete a virtual environment
function -d "Like virtualenvwrapper" rmvirtualenv
    if test -n "$VIRTUAL_ENV"
        deactivate
    end
    rm -rf $WORKON_HOME/$argv; and echo "Virtual environment deleted."
end

Comments

Subscribe to the comments RSS feed.

Comment #1 posted on 2017-07-17 21:50:27 by klaatu

homebrew virtual envs

I'm not a fan of fish, but I love your homemade virtual env. I did something somewhat similar in bash at my old job, and it worked pretty well. When I stumbled across virtualenv, I just used that.

Leave Comment

Note to Verbose Commenters
If you can't fit everything you want to say in the comment below then you really should record a response show instead.

Note to Spammers
All comments are moderated. All links are checked by humans. We strip out all html. Feel free to record a show about yourself, or your industry, or any other topic we may find interesting. We also check shows for spam :).

Provide feedback
Your Name/Handle:
Title:
Comment:
Anti Spam Question: What does the letter P in HPR stand for?
Are you a spammer?
What is the HOST_ID for the host of this show?
What does HPR mean to you?