Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--prompt . : the dot causes the basename of the current directory to be used #2215

Closed
okken opened this issue Oct 19, 2021 · 5 comments · Fixed by #2220
Closed

--prompt . : the dot causes the basename of the current directory to be used #2215

okken opened this issue Oct 19, 2021 · 5 comments · Fixed by #2220

Comments

@okken
Copy link

okken commented Oct 19, 2021

What's the problem this feature will solve?

I'd like an easy way to have the prompt reflect the directory the env was created in.

Describe the solution you'd like

I'd like --prompt . to use the basename of the current directory for the prompt, similar to what venv does.
More specifically, the prompt should be the directory in parentheses.

$ mkdir foo
$ cd foo
$ virtualenv venv --prompt .
$ source venv/bin/activate
(foo) $ 

Alternative Solutions

We could change the default prompt to be this. that'd be cool.

Additional context

This as been in the venv implementation of Pyhon since Python 3.9.something.

Python 3 documentation: https://docs.python.org/3/library/venv.html#api

prompt – a String to be used after virtual environment is activated (defaults to None which means directory name of the environment would be used). If the special string "." is provided, the basename of the current directory is used as the prompt.

@gaborbernat
Copy link
Contributor

If anyone puts in a PR with tests I'd be happy to accept, merge and release it. Thanks!

@rkm
Copy link
Contributor

rkm commented Oct 19, 2021

I could attempt a PR, unless you were planning on working on it @okken?

@okken
Copy link
Author

okken commented Oct 19, 2021

@rkm Go for it. I'd love to see it implemented.

@okken
Copy link
Author

okken commented Oct 23, 2021

So close.. May I ask if we could include parentheses and a space, so it could be (foo) $ instead of foo$?

@gaborbernat
Copy link
Contributor

So you want to change how the bash activation scripts renders prompts? You know the drill: open an issue and then a PR. 😎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants