-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
Adding has_virtualenv function which will look for a .venv file in the directory. If it exists, it will attempt to `workon` the project whose name is written in the file. For instance, if my .venv file contains the text: oebfare It will attempt to `workon oebfare`. As there shouldn't be a .venv file in a directory that doesn't have a virtual env, there is no error handling. This should be fixed.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -222,6 +222,15 @@ PS1="${RED}:${NORMAL}\@${RED}: ${CYAN}(${NORMAL}\w${CYAN})${GREEN} \$(parse_svn_ | |
|
||
source $HOME/bin/virtualenvwrapper_bashrc | ||
|
||
has_virtualenv() { | ||
if [ -e .venv ]; then | ||
workon `cat .venv` | ||
fi | ||
} | ||
venv_cd () { | ||
cd "$@" && has_virtualenv | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
cjerdonek
|
||
} | ||
alias cd="venv_cd" | ||
|
||
# Welcome Message | ||
echo -e "" | ||
|
1 comment
on commit 04899f0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, so that you don't override Mac OS X's behavior of preserving the current working directory when opening a new terminal window (or any other existing prompt behavior), it looks like you want to replace:
PROMPT_COMMAND='prompt'
with:
export PROMPT_COMMAND="${PROMPT_COMMAND};prompt"
This is dangerous because, if you put this in your bashrc and source it more than once, it'll create an infinite loop -- alias
cd
will call a function that hits the aliascd
.I fixed this by using:
builtin cd
inside thevenv_cd
function