Giter Site home page Giter Site logo

fictorial / autovenv Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 5 KB

automatic management of Python virtual environments with zsh integration for changing to the closest virtualenv when cd-ing into a directory

License: MIT License

python3 virtualenv virtualenv-manager zsh

autovenv's Introduction

autovenv

This script finds the closest Python 3 virtualenv and activates it.

If no venv is found in the current or directories up to $HOME, this script will create a venv for the current directory.

If it does find a venv in an ancestor directory but you want to force a new venv in the current directory, use the force option.

Rename the autovenv-created active venv with ./autovenv mv $new_name. Remove the autovenv-created active venv with ./autovenv rm.

Use with zsh

Add this to your ~/.zshrc, updating the path to this file:

function autovenv_cd_hook() { eval $(PRINT_VARS=1 ~/path/to/autovenv); }
autoload -U add-zsh-hook
add-zsh-hook chpwd autovenv_cd_hook

plugins(... virtualenv)
ZSH_THEME="autovenv"

Show the virtualenv in your zsh prompt with oh-my-zsh! for example:

# ~/.oh-my-zsh/custom/themes/autovenv.zsh-theme
PROMPT='$(virtualenv_prompt_info) '
PROMPT+="%(?:%{$fg_bold[green]%}%1{โžœ%} :%{$fg_bold[red]%}%1{โžœ%} ) %{$fg[cyan]%}%c%{$reset_color%}"
PROMPT+=' $(git_prompt_info)'
ZSH_THEME_VIRTUALENV_PREFIX="(๐Ÿ"
ZSH_THEME_VIRTUALENV_SUFFIX=")"
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}git:(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}%1{โœ—%}"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})"

autovenv's People

Contributors

fictorial avatar

Watchers

 avatar

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.