Forked from kishannareshpal/activatevenv.plugin.README.md
Created
February 7, 2024 22:38
-
-
Save smetroid/e91f2ba50a6bf338f80bcfb74cb6cd06 to your computer and use it in GitHub Desktop.
Revisions
-
kishannareshpal revised this gist
Mar 23, 2022 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -13,7 +13,7 @@ # To deactivate run `deactivate` and to manually activate run `activatevenv` function activatevenv() { # Names of possible virtualenv directories VIRTUALENV_DIRS=("venv/" "env/" ".env/" ".venv/" "${PWD##*/}") for dir in $VIRTUALENV_DIRS; do if [[ -d "${dir}" ]]; then -
kishannareshpal renamed this gist
Mar 23, 2022 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
kishannareshpal revised this gist
Mar 21, 2022 . 2 changed files with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -21,6 +21,6 @@ Download the `activatevenv.plugin.sh` into your computer. ## Usage Simply `cd` into a project directory with a python virtual environment setup (with any of these names: `venv/`, `.venv/`, `env` or `.env`), and the script will activate it automatically for you (just as you would do with `source ./venv/bin/activate`). If you are creating a new virtualenv, run `python -m <venv|virtualenv> <venv|.venv|.env|env>` in your root directory and to activate it manually call `activatevenv` (also when you cd back into your project folder it will automatically activate it). This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,7 @@ # . # ├── <other_project_files> # ├── ... # └── <.venv|venv|.env|env> # ├── bin # ├── include # └── lib @@ -13,7 +13,7 @@ # To deactivate run `deactivate` and to manually activate run `activatevenv` function activatevenv() { # Names of possible virtualenv directories VIRTUALENV_DIRS=(("venv/" "env/" ".env/" ".venv/" "${PWD##*/}") for dir in $VIRTUALENV_DIRS; do if [[ -d "${dir}" ]]; then -
kishannareshpal revised this gist
Dec 27, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -30,7 +30,7 @@ function activatevenv() { } activatevenv # Extension for `cd` command in order to automatically activate virtualenv when changin directories. function cd() { builtin cd $1 # Try activating venv -
kishannareshpal revised this gist
Dec 27, 2020 . 1 changed file with 4 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -17,9 +17,10 @@ Download the `activatevenv.plugin.sh` into your computer. ``` ### Manually 1. Copy and paste the `activatevend.plugin.sh` script to the bottom of your `~/.bashrc` or `~/.zshrc` and restart your terminal. ## Usage For existing projects, simply `cd` into that directory and it should contain either a `venv/`, `.venv/`, and the script will activate it automatically!! (Just as you would do with source ./venv/bin/activate). If you are creating a new virtualenv, run `python -m <venv|virtualenv> <venv|.venv>` in your root directory and to activate it manually use call `activatevenv` (or if you cd back into your project it will automatically activate it without the need of calling activatevenv). -
kishannareshpal revised this gist
Dec 18, 2020 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -22,6 +22,7 @@ function activatevenv() { if [[ -e "./${dir}/bin/activate" ]]; then source ./$dir/bin/activate echo "Virtual environment activated automatically" break fi fi done -
kishannareshpal revised this gist
Dec 18, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ #### This is a custom shell script I wrote in order to ease my workflow when dealing with Python Virtual Environments. ## Installation Download the `activatevenv.plugin.sh` into your computer. ### oh-my-zsh 1. Download the script into `$ZSH_CUSTOM/plugins/<plugin_name>/activatevenv/`. See [oh-my-zsh Plugin Customization Wiki](https://github.com/ohmyzsh/ohmyzsh/wiki/Customization) ```sh -
kishannareshpal revised this gist
Dec 18, 2020 . 2 changed files with 25 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ #### This is a custom shell script I wrote in order to ease my workflow when dealing with Python Virtual Environments. ## Installation Download the `activateenv.plugin.sh` into your computer. ### oh-my-zsh 1. Download the script into `$ZSH_CUSTOM/plugins/<plugin_name>/activatevenv/`. See [oh-my-zsh Plugin Customization Wiki](https://github.com/ohmyzsh/ohmyzsh/wiki/Customization) ```sh # Use curl or download manually from https://git.io/JLBHr (mkdir activatevenv; cd activatevenv) && curl -L --url https://git.io/JLBHr --output ./activatevenv/activatevenv.plugin.zsh ```` 2. Edit your `~/.zshrc`: ```sh … # Add activatevenv to your list of plugins and restart the terminal. plugins=(... , activatevenv) … ``` ### Manually 1. Simply copy and paste the script to the bottom of your `~/.bashrc` or `~/.zshrc` and restart your terminal. ## Usage For existing projects, simply `cd` into your any directory that contains either a `venv/`, `.venv/` virtualenv created and the script will activate it automatically (Just as you would do with source ./venv/bin/activate) If you are creating a new virtualenv run `python -m <venv|virtualenv> <venv|.venv>` in your root directory and to activate it manually use call `activatevenv` (or if you cd back into your project it will automatically activate it without the need of calling activatevenv). This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,3 @@ # Automatically activates venv if ./venv/ exists in curent directory # Go to your project folder, run "pip virtualenv <.venv|venv>", so your project folder # has a <.venv|venv> folder at the top level -
kishannareshpal revised this gist
Dec 18, 2020 . No changes.There are no files selected for viewing
-
kishannareshpal revised this gist
Dec 18, 2020 . No changes.There are no files selected for viewing
-
kishannareshpal revised this gist
Dec 18, 2020 . No changes.There are no files selected for viewing
-
kishannareshpal created this gist
Dec 18, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,39 @@ # Copy and paste these lines into your ~/.zshrc and restart the terminal. # Automatically activates venv if ./venv/ exists in curent directory # Go to your project folder, run "pip virtualenv <.venv|venv>", so your project folder # has a <.venv|venv> folder at the top level # . # ├── <other_project_files> # ├── ... # └── <.venv|venv> # ├── bin # ├── include # └── lib # # The virtualenv will be activated automatically when you enter the directory. # To deactivate run `deactivate` and to manually activate run `activatevenv` function activatevenv() { # Names of possible virtualenv directories VIRTUALENV_DIRS=("venv/" ".venv/" "${PWD##*/}") for dir in $VIRTUALENV_DIRS; do if [[ -d "${dir}" ]]; then # Found a possible venv directory # Try activating the venv if [[ -e "./${dir}/bin/activate" ]]; then source ./$dir/bin/activate echo "Virtual environment activated automatically" fi fi done } activatevenv # Extension for `cd` command in order to automatically acticate virtualenv function cd() { builtin cd $1 # Try activating venv activatevenv }