diff options
| author | Anton Bobov <anton@bobov.name> | 2023-08-05 23:35:05 +0500 |
|---|---|---|
| committer | Anton Bobov <anton@bobov.name> | 2023-08-05 23:35:05 +0500 |
| commit | 2fa96e8054078feae2016d922d47415eec002f6e (patch) | |
| tree | ac959cf66cde3ea248ab86630c4be2e7173ea113 /files/.zsh/rc/S50_functions | |
| parent | 5e90863365043bad15617abbd9a39bdd3d020eb5 (diff) | |
[zsh] Update aliases and functions
Diffstat (limited to 'files/.zsh/rc/S50_functions')
| -rw-r--r-- | files/.zsh/rc/S50_functions | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/files/.zsh/rc/S50_functions b/files/.zsh/rc/S50_functions index 4129fd6..b9bd045 100644 --- a/files/.zsh/rc/S50_functions +++ b/files/.zsh/rc/S50_functions @@ -62,14 +62,27 @@ alias calc="noglob calc" # Take from @garybernhardt activate_virtualenv() { - for name in venv env ; do - for up in . ../.. ../../.. ; do - if [ -f $up/$name/bin/activate ] ; then - . $up/$name/bin/activate - return - fi - done + local found_location="" + for name in venv env ; do + for up in . ../.. ../../.. ; do + if [ -f "$up/$name/bin/activate" ] ; then + found_location="$up/$name/bin/activate" + break + fi done + [ -n "$found_location" ] && break + done + + if [ -z "$found_location" ] ; then + # create + read -r "answer?Virtualenv not found, create? " + if [[ "$answer" =~ ^[Yy]$ ]] ; then + virtualenv venv + activate_virtualenv + fi + else + . "$found_location" + fi } edit-which() { |
