On Sun, Apr 1, 2018 at 10:54 PM, <the...@sys-concept.com> wrote: > On 03/30/2018 11:10 AM, Bas Zoutendijk wrote: >> On Fri 30 Mar 2018 at 10:33:45 -0600, the...@sys-concept.com wrote: >>> >>> I'm using a scrip to log-in/boot strap the system over NFS >>> >>> ----- >>> #!/bin/sh >>> >>> HOST=${0##*/} >>> HOST=${HOST#*-} >>> ROOT=/mnt/${HOST} >>> ... >>> exec chroot '${ROOT}' /bin/bash -l >>> --- >>> >>> When I'm presented with bash prompt, it is the same as the one I logged >>> IN from. So to eliminate the confusion I would like to change (add to) >>> the bash prompt the "HOST' name I log-in to. >>> >>> When I log-in I'm presented with: "syscon3 #" >>> I would like it to be: ROOT+HOST >>> eg.: syscon3-eden >> >> To change the prompt you want to set $PS1. For example: >> >> echo 'export PS1="some string"; exec </dev/tty' | exec chroot $ROOT >> /bin/bash -i >> >> This command tells the Bash inside the chroot to first execute >> >> export PS1="some string" >> >> and then to continue as a regular log-in shell. The special syntax of >> the $PS1 string in described in the Bash man page. If you just want to >> prepend a string, you do not even have to bother with crafting a syntax: >> >> echo 'export PS1="(chroot '$HOST') $PS1"; exec <dev/tty' | exec chroot >> $ROOT /bin/bash -i > > The above syntax produced an error: > > chroot-eden: line 30: syntax error near unexpected token `(' > chroot-eden: line 30: `echo 'export PS1="(chroot '$HOST') $PS1"; exec > <dev/tty' | exec chroot $ROOT /bin/bash -i' > > I've tried it without brackets "()" no effect.
You have "dev/tty". It should be "/dev/tty". Also, I'd expect "'$HOST'" to print out "'hostname'" rather than "hostname". Is this what you want? This is a snippet from the default Debian bashrc. You have to edit "/etc/debian_chroot" and use a similar PS1 in the to-be-chrooted system for this to take effect. if [ -z "$debian_chroot" ]; then PS1h="\h" else PS1h="($debian_chroot)" fi # Set options depending on terminal type if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then # The terminal supports colour: assume it complies with ECMA-48 # (ISO/IEC-6429). This is almost always the case... # Make ls(1) use colour in its listings if [ -x /usr/bin/dircolors ]; then alias ls="ls -v --color=auto" eval $(/usr/bin/dircolors --sh) fi # Set the terminal prompt if [ $(id -u) -ne 0 ]; then PS1="\[\e[42;30m\]\u@$PS1h\[\e[37m\]:\[\e[30m\]\w\[\e[0m\] \\\$ " else # Root user gets a nice RED prompt! PS1="\[\e[41;37;1m\]\u@$PS1h\[\e[30m\]:\[\e[37m\]\w\[\e[0m\] \\\$ " fi else # The terminal does not support colour PS1="\u@$PS1h:\w \\\$ "