Skip to content

Commit

Permalink
Add auto virtualenv switcher.
Browse files Browse the repository at this point in the history
  • Loading branch information
matt2000 committed Jul 24, 2018
1 parent 11a167e commit b8d4cb1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
16 changes: 16 additions & 0 deletions autovenv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
# Activates a venv if found at ../.$PWD

function autovenv() {
cd $@

here=`pwd`
name=`basename $here`
venv="../.$name-venv"
if [ -d $venv ]; then
echo "Activating $venv"
source $venv/bin/activate;
elif [ ! -z $VIRTUAL_ENV ]; then
deactivate
fi
}
8 changes: 5 additions & 3 deletions bash_aliases
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ alias clip='xclip -sel clip'
alias randstr="cat /dev/urandom |base64 |head -3 | cut -b -32"
alias ll='ls -alh'
alias gist=gist-paste
alias py3='source ~/py3venv/bin/activate'
alias vim="py3 && nvim -c ':sp term://bash|wincmd J|8wincmd -|wincmd k'"
alias py3='source ~/py3/bin/activate'
alias vim="nvim -c ':sp term://bash|wincmd J|8wincmd -|wincmd k'"

source ~/.local_aliases
source ~/ninjatools/autovenv.sh
alias cd="autovenv"

source ~/.local_aliases

0 comments on commit b8d4cb1

Please sign in to comment.