Skip to content

Instantly share code, notes, and snippets.

@fisadev
Last active February 25, 2021 03:38

Revisions

  1. fisadev revised this gist Feb 25, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion put_inside_config.fish
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@
    # but stored under ~/venvs/
    # e NAME --> create and/or activate a virtualenv with the specified name, stored under ~/venvs/

    # you should replace `\/home\/fisa\/devel\/` (scaped text for `/home/fisa/deve/`) with the folder in which most
    # you should replace `\/home\/fisa\/devel\/` (scaped text for `/home/fisa/devel/`) with the folder in which most
    # of your projects live, so a venv for a project /home/fisa/devel/company_x/project_y/ will be named just
    # "company_x_project_y", without the full path as part of the name. It's kind of a default prefix.

  2. fisadev created this gist Feb 25, 2021.
    28 changes: 28 additions & 0 deletions put_inside_config.fish
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    # usage:
    # e --> create and/or activate a virtualenv, named in a way that's unique and related to the current folder
    # but stored under ~/venvs/
    # e NAME --> create and/or activate a virtualenv with the specified name, stored under ~/venvs/

    # you should replace `\/home\/fisa\/devel\/` (scaped text for `/home/fisa/deve/`) with the folder in which most
    # of your projects live, so a venv for a project /home/fisa/devel/company_x/project_y/ will be named just
    # "company_x_project_y", without the full path as part of the name. It's kind of a default prefix.

    function e
    if count $argv > /dev/null
    set env_name $argv
    else
    set env_name (pwd | sed "s/\/home\/fisa\/devel\///g" | sed "s/\//_/g")
    end

    set env_dir ~/venvs/$env_name

    if not test -d $env_dir
    echo "No virtualenv named $env_name, creating a new one..."
    python3 -m venv $env_dir
    echo "Upgrading pip..."
    $env_dir/bin/pip install pip --upgrade
    echo "Done"
    end
    . $env_dir/bin/activate.fish
    end