I’m using WSL 2 to run a Debian. I created a "ansible" on it. The thing I want to do is that when I open a new tab of this Debian, I want to see (ansible) XXXXX$:
I tried two things yet.
- Crontab (But it’s not appropriate with how WSL works as I understood it)
- Trying to modify my target of Debian as
wsl -e source /home/w123183/ansible/bin/activate
The tricky thing here is that it’s not it doesn’t work. It just that the shell closes immediately after it ran.
I believe that all this shell stuffs and how it is managed is still blurry for me.
I hope someone will be able to help me and I thank them in advance for that.
2
Answers
Ok I actually find a solution. I just added
"source ~/ansible/bin/activate"
to my .bashrc. It works as I wanted nowThat’s actually a tough one, but (courtesy this Unix & Linux answer), try:
That creates a temporary rc file from a combination of your:
activate
~/.bashrc
And starts bash with it as its rc file.
Worked for me (ironically also using my Ansible python-venv).
Of course, you can script this either on the PowerShell end of things, or in a shell script that you pass in on the
wsl
command-line.