From 4ca771ff81f0ad9da1b28b73b57006ff4f8dfcc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ha=CC=88cker?= Date: Thu, 7 Dec 2017 20:42:18 +0100 Subject: [PATCH 1/7] Support .project files in virtualenvs if they are available --- virtualfish/virtual.fish | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/virtualfish/virtual.fish b/virtualfish/virtual.fish index 9c8cd4c..376aa0c 100644 --- a/virtualfish/virtual.fish +++ b/virtualfish/virtual.fish @@ -80,6 +80,11 @@ function __vf_activate --description "Activate a virtualenv" emit virtualenv_did_activate emit virtualenv_did_activate:(basename $VIRTUAL_ENV) + + if test -e $VIRTUAL_ENV/.project + set project_path (cat $VIRTUAL_ENV/.project) + cd $project_path + end end function __vf_deactivate --description "Deactivate this virtualenv" From b6ee63ca74a11056cae45999fb64f9a1ce0d6edf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ha=CC=88cker?= Date: Wed, 27 Dec 2017 16:45:02 +0100 Subject: [PATCH 2/7] Fix completions if project folder is not available or not set. --- virtualfish/projects.fish | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/virtualfish/projects.fish b/virtualfish/projects.fish index f99154b..89aeb27 100644 --- a/virtualfish/projects.fish +++ b/virtualfish/projects.fish @@ -91,7 +91,7 @@ if set -q VIRTUALFISH_COMPAT_ALIASES end end - complete -x -c workon -a "(ls $PROJECT_HOME)" + complete -x -c workon -a "(vf lsprojects)" end -complete -x -c vf -n '__vfcompletion_using_command workon' -a "(ls $PROJECT_HOME)" +complete -x -c vf -n '__vfcompletion_using_command workon' -a "(vf lsprojects)" From 76c8f2429bf26dac53acf02509f16730ae2cce7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ha=CC=88cker?= Date: Wed, 27 Dec 2017 16:47:53 +0100 Subject: [PATCH 3/7] Move auto cd support into the projects plugin --- virtualfish/projects.fish | 3 +++ virtualfish/virtual.fish | 4 ---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/virtualfish/projects.fish b/virtualfish/projects.fish index 89aeb27..85c3362 100644 --- a/virtualfish/projects.fish +++ b/virtualfish/projects.fish @@ -17,6 +17,9 @@ function __vf_workon --description "Work on a project" if [ -d $PROJECT_HOME/$argv[1] ] cd $PROJECT_HOME/$argv[1] end + if test -e $VIRTUAL_ENV/.project + cd (cat $VIRTUAL_ENV/.project) + end # Matches a project name but not a virtualenv name else if [ -d $PROJECT_HOME/$argv[1] ] set -l project_name $argv[1] diff --git a/virtualfish/virtual.fish b/virtualfish/virtual.fish index 376aa0c..adad953 100644 --- a/virtualfish/virtual.fish +++ b/virtualfish/virtual.fish @@ -81,10 +81,6 @@ function __vf_activate --description "Activate a virtualenv" emit virtualenv_did_activate emit virtualenv_did_activate:(basename $VIRTUAL_ENV) - if test -e $VIRTUAL_ENV/.project - set project_path (cat $VIRTUAL_ENV/.project) - cd $project_path - end end function __vf_deactivate --description "Deactivate this virtualenv" From 96190f0c51ecfdc3d67a60a3c7974419d720e468 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ha=CC=88cker?= Date: Thu, 28 Dec 2017 22:58:50 +0100 Subject: [PATCH 4/7] Support cdproject if $venv/.project is available. --- virtualfish/projects.fish | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/virtualfish/projects.fish b/virtualfish/projects.fish index 85c3362..cff21a7 100644 --- a/virtualfish/projects.fish +++ b/virtualfish/projects.fish @@ -64,10 +64,15 @@ function __vf_lsprojects --description "List projects" end function __vf_cdproject --description "Change working directory to project directory" + + if test -e $VIRTUAL_ENV/.project + cd (cat $VIRTUAL_ENV/.project) + return + end + if [ ! -d $PROJECT_HOME ] return 2 end - if set -q VIRTUAL_ENV set -l project_name (basename $VIRTUAL_ENV) if [ -d $PROJECT_HOME/$project_name ] From 4875632f38ea8acb707f7477d494af8cadb58a98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ha=CC=88cker?= Date: Thu, 28 Dec 2017 22:59:30 +0100 Subject: [PATCH 5/7] Override `vf new` to support -a path/to/project/folder --- virtualfish/projects.fish | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/virtualfish/projects.fish b/virtualfish/projects.fish index cff21a7..15bd2bd 100644 --- a/virtualfish/projects.fish +++ b/virtualfish/projects.fish @@ -46,6 +46,15 @@ function __vf_project --description "Create a new project and virtualenv with th vf new $argv mkdir -p $project_path cd $project_path + +functions --copy __vf_new __vf__new_projects_original +function __vf_new --wraps=__vf_new + set -l options (fish_opt --short a --required) + # kill stderr as argparse throws errors on unknonw parameters + argparse --name 'vf new' $options -- $argv ^/dev/null + if __vf__new_projects_original $argv; and test -n $_flag_a + cd $_flag_a + and pwd >?$VIRTUAL_ENV/.project end end From d62d12403ebac7885b5560fd8e033e11821c83b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ha=CC=88cker?= Date: Thu, 28 Dec 2017 23:00:07 +0100 Subject: [PATCH 6/7] Modify `vf project` to support same `-a path/to/project/folder` syntax --- virtualfish/projects.fish | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/virtualfish/projects.fish b/virtualfish/projects.fish index 15bd2bd..8a4faea 100644 --- a/virtualfish/projects.fish +++ b/virtualfish/projects.fish @@ -37,15 +37,26 @@ function __vf_workon --description "Work on a project" end function __vf_project --description "Create a new project and virtualenv with the name provided" - set -l project_name $argv[-1] - set -l project_path "$PROJECT_HOME/$project_name" - if [ -d $project_path ] - echo "A project with that name already exists at: $project_path" - return 2 - else - vf new $argv - mkdir -p $project_path - cd $project_path + set -l options "(fish_opt --short a --required)" + # kill stderr as argparse throws errors on unknonw parameters + argparse --name 'vf project' $options -- $argv ^/dev/null + + if test -z $_flag_a # no porject path given, use plugin standard project path + set -l project_name $argv[-1] + set -l project_path "$PROJECT_HOME/$project_name" + if [ -d $project_path ] + echo "A project with that name already exists at: $project_path" + return 2 + else + vf new $argv + mkdir -p $project_path + cd $project_path + end + else if vf new $argv # -a $project_path given + cd $_flag_a + and pwd >?$VIRTUAL_ENV/.project + end +end functions --copy __vf_new __vf__new_projects_original function __vf_new --wraps=__vf_new From d181ab7fff2d2a7c7f34f8801554e4886d04c145 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ha=CC=88cker?= Date: Thu, 28 Dec 2017 23:00:54 +0100 Subject: [PATCH 7/7] Ignore cached eggs --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index accb26a..c12aad6 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ docs/_build +.eggs \ No newline at end of file