skip to Main Content

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.

  1. Crontab (But it’s not appropriate with how WSL works as I understood it)
  2. 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


  1. Chosen as BEST ANSWER

    Ok I actually find a solution. I just added "source ~/ansible/bin/activate" to my .bashrc. It works as I wanted now


  2. That’s actually a tough one, but (courtesy this Unix & Linux answer), try:

    wsl ~ sh -c "cat ~/ansible/bin/activate > ~/.tmp_venvrc; cat ~/.bashrc >> ~/.tmp_venvrc; exec bash --rcfile ~/.tmp_venvrc"
    

    That creates a temporary rc file from a combination of your:

    • venv activate
    • Existing ~/.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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search