aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Löthberg <johannes@kyriasis.com>2015-07-16 22:21:54 +0200
committerJohannes Löthberg <johannes@kyriasis.com>2015-07-16 22:21:54 +0200
commit0765d636a0bdbd65c8c46925cd9bada131eba25e (patch)
tree741ca241a25d7ee9a4a3df48614c89342dfe4553
parent3df11f26478bde803755d1e2c84cfd2cdf97504f (diff)
downloaddotfiles-0765d636a0bdbd65c8c46925cd9bada131eba25e.tar.xz
zsh: update 5 aliases/functions
-rw-r--r--zsh/aliases.zsh54
-rw-r--r--zsh/completion/_5c2
-rw-r--r--zsh/completion/_5v2
3 files changed, 39 insertions, 19 deletions
diff --git a/zsh/aliases.zsh b/zsh/aliases.zsh
index 0546ce4..2f8a205 100644
--- a/zsh/aliases.zsh
+++ b/zsh/aliases.zsh
@@ -75,33 +75,51 @@ if have systemctl && [[ -d /run/systemd/system ]]; then
fi
function 5v {
- if [[ -d "$HOME"/5/venvs/"$1" ]]; then
- source "$HOME"/5/venvs/"$1"/bin/activate
+ if [[ -d "$HOME"/venvs/"$1" ]]; then
+ source "$HOME"/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"
+ printf "==> Python version? [23]: "
+ read venvver
+
+ if [[ "$venvver" == '2' ]]; then
+ virtualenv2 "$HOME"/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"/venvs/"$1"/bin/activate
+ pip install -r "$HOME"/venvs/5_requirements.txt
+
+ elif [[ "$venvver" == '3' ]]; then
+ virtualenv3 "$HOME"/venvs/"$1"
+ if (( $? == 0 )); then
+ print "\x1b[38;5;2m==> 5venv created successfully, activating environment.\x1b[0m"
+ print "==> Note that no requirements were installed due to version 3 was selected."
+ else
+ print "\x1b[38;5;1m==> Error: 5env creation failed. Exiting.\x1b[0m"
+ return 1
+ fi
+ source "$HOME"/venvs/"$1"/bin/activate
+
else
- print "\x1b[38;5;1m==> Error: 5env creation failed. Exiting.\x1b[0m"
- return 1
+ printf "==> virtualenv for version ‘%s’ not found.\n" "$venvver"
+ exit 1
fi
- source "$HOME"/5/venvs/"$1"/bin/activate
- pip install -r "$HOME"/5/venvs/5_requirements.txt
fi
fi
}
function 5c {
- if [[ -n "$1" ]]; then
- cd "$HOME"/5/code/"$1"
- else
- cd "$HOME"/5/code
- fi
+ cd "$HOME"/projects/"$1"
}
function 5clone {
@@ -109,11 +127,13 @@ function 5clone {
print "No repo name"
fi
- (cd "$HOME"/5/code
+ (cd "$HOME"/projects
git clone git@github.com:5m/"$1"
- cd "$1"
+ shift
+ cd -)
+
+ pushd "$HOME"/projects/"$1"
git config --local user.email johannes@5monkeys.se
- )
}
alias 5ssh='TERM=xterm ssh'
diff --git a/zsh/completion/_5c b/zsh/completion/_5c
index ca7eeac..5f309c7 100644
--- a/zsh/completion/_5c
+++ b/zsh/completion/_5c
@@ -1,4 +1,4 @@
#compdef 5c
_arguments \
- "1: :($(print $HOME/5/code/*(/) | xargs -n1 basename))"
+ "1: :($(print $HOME/projects/*(/) | xargs -n1 basename))"
diff --git a/zsh/completion/_5v b/zsh/completion/_5v
index 3958269..659bb1a 100644
--- a/zsh/completion/_5v
+++ b/zsh/completion/_5v
@@ -1,4 +1,4 @@
#compdef 5v
_arguments \
- "1: :($(print $HOME/5/venvs/*(/) | xargs -n1 basename))"
+ "1: :($(print $HOME/venvs/*(/) | xargs -n1 basename))"