Giter Club home page Giter Club logo

virtualenv-switcher's Introduction

Virtualenv Switcher

Python developers often end up with many virtualenvs scattered around the hard drive. Some belong to a particular project, some are general, some are created for a particular tool. Remembering the location of all environments, typing their paths to activate them and distinguishing which one is active now (for example if you happen to have foo/venv and bar/venv) can get tedious. There must be a better way!

$ vs-add ~/envs/numpy
Added /home/foo/envs/numpy as numpy
$ vs-add ~/envs/hg mercurial
$ vs-list
numpy      /home/foo/envs/numpy
mercurial  /home/foo/envs/hg
$ hg
hg: command not found
$ vs mer
[mercurial] $ hg st
abort: no repository found in ...
[mercurial] $ vs-expose hg
[mercuaial] $ vs-off
$ hg
abort: no repository found in ...

Installation

Prerequisites: a virtualenv with Python 3.

This will install virtualenv-switcher using pip and append the vs function and its completion configuration to your bash profile:

(vs-env) $ pip install virtualenv-switcher
(vs-env) $ vs-install >>~/.bashrc
(vs-env) $ source ~/.bashrc

Configuration

Virtualenv Switcher keeps the paths to all virtualenvs as well as the path the directory where the commands are exposed in ~/.vs.conf. The file will be created if it doesn't exist. It can be edited by hand or via the following commands:

  • vs-add -- to add a virtualenv to the configuration,
  • vs-del -- to delete virtualenv from the configuration,
  • vs-path -- to configure the path for exposing the commands.

Other features

  • By default vs-install configures autocompletion of virtualenv names for vs and vs-del.
  • When a virtualenv is activated its name becomes the name of the window in Tmux and some terminal emulators. This behavior can be disabled by editing the code that is added to the profile by vs-install.

Alternatives

  • Virtualenvwrapper has some of the functionality of Virtualenv Switcher and quite a bit more on top. The scope of two packages is different: Virtualenvwrapper is a more complete virtualenv management solution whereas this package just makes switching between the environments as easy as possible and does not force any decisions on the user.

virtualenv-switcher's People

Contributors

kvas-it avatar

Watchers

 avatar  avatar

Forkers

bjoernbuth

virtualenv-switcher's Issues

Default virtualenv for vs-add, vs-del and vs

  • vs-add and vs-del without arguments by default work on a currently activated virtualenv.
  • vs without arguments should look for a registered virtualenv whose path starts with the current directory. If it's not found, look for a virtualenv in the parent and so forth.

Add -d/--delete option to vs-expose

It should remove target file from the scripts directory but only if it's a symlink. Also remove it from the configuration if it's there. If the file is not a symlink, report error.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.