Posts

Showing posts from September, 2011

Protecting your shell prompt when accessing a chroot

If you run any chroot environments such as schroot, they will generally set your prompt as a reminder that you are actually running within a chroot. For example with schroot, I have: $ schroot -c oneiric (oneiric):~$ echo hello hello (oneiric):~$ exit $ When you're in the chroot, you get the chroot name prepended to the prompt (here " (oneiric) "). But if you play tricks with your prompt variables ( PS1 , PS2 , etc) using maybe the magic bash PROMPT_COMMAND variable, you need to take care. I use screen , tmux , or byobu so need to take twice the amount of care since: I modify my prompt quite extensively I only have 1 window which multiplexes all my terminals (it's easier to make a mistake :) The problem is that if you forget which window you're in, you may end up modifying the wrong environment - installing packages in a minimal chroot rather than in your main (non-chroot) environment, or maybe trashing your live system rather than a throw-away chroot