I've searched for the correct file to edit to get the same look for each new pipenv shell, but I'm not having any luck finding the right file to copy my profile preferences to.
For bash, you can create and modify ~/.bashrc
.
The pipenv shell
command is a wrapper for virtualenv, which checks for a ~/.bashrc
file when it activates a virtual environment for a bash shell. Anything in the ~/.bashrc
file gets used in the spawned shell, including prompts, aliases, and other things you customized in your shell.
$ cat ~/.bashrc
cat: /Users/gino/.bashrc: No such file or directory
$ pipenv shell
Launching subshell in virtual environment…
bash-5.0$ . /Users/gino/.venvs/test-oiEjhH94/bin/activate
(test) bash-5.0$ ll
bash: ll: command not found
(test) bash-5.0$ exit
$ vim ~/.bashrc
$ cat ~/.bashrc
PS1='\[\e[1;33m\]\u@\W\$\[\e[0m\] '
alias ll="ls -Flh"
$ pipenv shell
Launching subshell in virtual environment…
gino@test$ . /Users/gino.mempin/.venvs/test-oiEjhH94/bin/activate
(test) gino@test$
(test) gino@test$ type ll
ll is aliased to `ls -Flh'
What you can do is to have a ~/.bash_prompt
file where you set all your prompt configs (PS1
) and a ~/.bash_aliases
file where you set all your aliases. Then, source them both in the ~/.bash_profile
(for the standard shell) and in the ~/.bashrc
(for the pipenv shell).
~/.bash_prompt
# Format the prompt
# Shows up as:
# machine-name@current-working-directory$
PS1='\[\e[1;33m\]\u@\W\$\[\e[0m\] '
# other prompt configs
~/.bash_aliases
alias ll="ls -FlhpG"
# other aliases
~/.bash_profile
# For "main" shell (i.e. Terminal, VS Code terminal)
. ~/.bash_prompt
. ~/.bash_aliases
~/.bashrc
# For `pipenv shell`
. ~/.bash_prompt
. ~/.bash_aliases
A better solution would be to tell pipenv shell
or virtualenv to reuse the configs in the ~/.bash_profile
, but I haven't got that successfully to work (Terminal, pipenv, VS Code).
- macOS 10.15
- bash 5.0 (installed via Homebrew)
- pipenv 2020.8.13