In my terminal prompt definition in my .bashrc
file, among other things, I have this snippet of code:
${debian_chroot:+($debian_chroot)}
What does this do, and do I need it?
In my terminal prompt definition in my .bashrc
file, among other things, I have this snippet of code:
${debian_chroot:+($debian_chroot)}
What does this do, and do I need it?
The important part to answer this question is this snippet from /etc/bash.bashrc
:
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
It means if the variable $debian_chroot
is empty and the file /etc/debian_chroot
exists and is readable the variable is set to the content of the file.
Now what is this for? The file /etc/debian_chroot
is when you have a chrooted debian system inside another debian system (ubuntu is based on debian). So this is for a better overview. To distinguish whether you are in the chroot or not.
When you have a chroot of another system for example in /srv/nfs4/netboot/
you can set a name for this chroot in /srv/nfs4/netboot/etc/debian_chroot
(in my case it's a nfs4 pxe netboot drive):
user@host:~# echo "netboot" >/srv/nfs4/netboot/etc/debian_chroot
And then when you chroot inside:
chroot /srv/nfs4/netboot/
Your prompt looks like this:
(netboot)user@host:~#