diff options
author | Johannes Löthberg <johannes@kyriasis.com> | 2015-04-16 11:18:52 +0200 |
---|---|---|
committer | Johannes Löthberg <johannes@kyriasis.com> | 2015-04-16 11:21:43 +0200 |
commit | a3d2bd68a134117da405f93aa8947312e9af7e19 (patch) | |
tree | 898156370bcce8906554befb20a7b7ab0780e03b /zsh | |
parent | 70e254153d495703edb5108bed340e8871c934de (diff) | |
download | dotfiles-a3d2bd68a134117da405f93aa8947312e9af7e19.tar.xz |
zsh/aliases: Add function for activating/creating a 5venv
Diffstat (limited to 'zsh')
-rw-r--r-- | zsh/aliases.zsh | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/zsh/aliases.zsh b/zsh/aliases.zsh index 8636a5d..e3058eb 100644 --- a/zsh/aliases.zsh +++ b/zsh/aliases.zsh @@ -71,3 +71,25 @@ if have systemctl && [[ -d /run/systemd/system ]]; then usls() { cgls "/user.slice/user-$UID.slice/$*"; } psls() { cgls "/user.slice/user-$UID.slice/session-$XDG_SESSION_ID.scope"; } fi + +function 5v { + if [[ -d "$HOME"/5/venvs/"$1" ]]; then + source "$HOME"/5/venvs/"$1"/bin/activate + printf "\x1b[38;5;2m==> 5venv ‘%s’ activated successfully.\x1b[0m\n" "$1" + else + printf "==> 5venv ‘%s’ not found\n" "$1" + printf "==> Create? [yN]: " + read yn + if [[ "$yn" == 'y' || "$yn" == 'yes' ]]; then + virtualenv-2.7 "$HOME"/5/venvs/"$1" + if (( $? == 0 )); then + print "\x1b[38;5;2m==> 5venv created successfully, installing basic requirements.\x1b[0m" + else + print "\x1b[38;5;1m==> Error: 5env creation failed. Exiting.\x1b[0m" + return 1 + fi + source "$HOME"/5/venvs/"$1"/bin/activate + pip install -r "$HOME"/5/venvs/5_requirements.txt + fi + fi +} |