I'm trying to automate something that should be a fairly simple task, but I can't find the right flag / way to do it.
I'm automating a bunch of docker containers, and I want to know which shell I'm using in some human readable form.
So, I start/create a container:
docker run -v /home/igor/Downloads:/home/Downloads/ -h debian7 -p 8081:8080 -itd --name igorDebian72 debian:7
And then trying to get into its bash which has nicely changed prompt and colours:
sudo docker exec -ti igorDebian72 /bin/bash -c "`export PS1="\e[1;32m[\u@ \\H \\W \\@]\$ \e[m "`"
But, this seems to "run" the command and exit back to host, so it's not useful.
If I run these two things separately:
sudo docker exec -ti igorDebian72 /bin/bash
This get's me into the containers bash, and then:
export PS1="\e[1;32m[\u@ \\H \\W \\@]\$ \e[m "
Gives me exactly what I want. Bash prompt with visible container name and a different colour than host machine.
How to achieve that in a single line?
P.S. In a meantime and using comments from here I've tried this:
sudo docker exec -ti igorDebian72 bash --rcfile <(echo 'export PS1="\e[1;32m[\u@ \\H \\W \\@]\$ \e[m "')
sudo docker exec -ti igorDebian72 bash --rcfile <(export PS1="\e[1;32m[\u@ \\H \\W \\@]\$ \e[m ")
It remained in bash, but seems like the script was not executed.
I tried saving it in a .sh file, then doing this:
sudo docker exec -ti igorDebian72 bash --rcfile <(echo trueColors.sh)
Again, remains in the container, but does not run the script.