envdir
envdir copied to clipboard
new feature: optional prompt for envshell
this sets a new env variable called ENVDIR_PS1
before running a new shell so for example in bash
it can be used to set a new shell prompt
(similar to virtualenv)
all you'd need to do is add a line similar to this at the bottom of your .bashrc
PS1=${ENVDIR_PS1:-${PS1}}
so after running envshell ./test/
you would get [envdir:test]
at the beginning of your prompt.
I like the idea (an indicator that an envshell is active) in general, but this approach requires PS1 to be exported.
Since I am using another method than PS1 anyway to setup my prompt, something like setting ENVDIR_PATH
or/and ENVSHELL_NAME
in general might make more sense.
FWIW, I am currently exporting ENVSHELL
myself for my prompt.
Yes. This PR was probably too bash-specific. So basically you give this idea a thumbs up ? I can change the PR but should we provide a whole path in ENVDIR_PATH
or just a basename in ENVSHELL_NAME
or both?
How about now? This should be shell/prompt agnostic :). Now you can have something like
if [ -n "$ENVSHELL_NAME" ]; then PS1=[envshell:$ENVSHELL_NAME]$PS1; fi
at the end of your .bashrc
.
:+1:
I've added some docs about those two new env variables.
I feel like this could do with a test to ensure the vars are set. @slafs would you be prepared to do that? Then I'll try to get this merged in.
Sure! Will try.
@slafs Any update on this?
Done :). Although we probably need #45 first.
Thanks!
#45 is merged - please rebase on master.
Done. Looks like appveyor failed on py26 (not on mine test though).
I would say by now that only ENVSHELL_PATH
is required, because ENVSHELL_NAME
can easily get derived from it in your shell (${ENVSHELL_PATH##*/}
).
I wouldn't say "easily". That's some serious bash-fu right there. I can remove it, but I'd "vote" it to stay.
I wouldn't say "easily".
I can see that it's not obvious, but should be known / easy to find if you're into shell scripting.
What about $(basename "$ENVSHELL_PATH")
?
We could also provide the code in the documentation.
What do others think?
Oh, right. I forgot that basename
is also present in bash. I'm ok with this then.
Merrrgggeeeeeeeee :beers:
@lwm
ENVSHELL_NAME
is still in the PR.
@slafs Do you want to remove it? Does everybody agree that a single env var is enough?
I'm really undecided on this myself.
yes, I'll remove it.