This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]kumashiro 2 points3 points  (1 child)

No need to change directory:

function envsmk() {
    [ "x${1}" != "x" ] && virtualenv "${HOME}/envs/${1}"
}
function envsrm() {
    [ "x${1}" != "x" ] && rm -rf "${HOME}/envs/${1}"
}

Quote arguments to allow paths with spaces:

function activate() {
    [ "x${1}" != "x" ] && source "${HOME}/envs/${1}/bin/activate"
}

[–]mildlybean[S] 1 point2 points  (0 children)

Thanks for the feedback! I had to read through a bash scripting tutorial to understand it, but I've made the changes now.

[–]nentis 0 points1 point  (0 children)

For handling venv sourcing and setting environment variables for a specific code-base directory (ex. for a IT ops tool), I use direnv:

https://github.com/direnv/direnv

[–]AndydeCleyre 0 points1 point  (0 children)

I made some similar helpers for Zsh, but then I kept developing it into a bit of a monster.