Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 12 Oct 2016 05:08:17 +0200
From:      Polytropon <freebsd@edvax.de>
To:        James E Keenan <jkeen@verizon.net>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: $PS1 does not render command-line prompt in color in a FreeBSD VM
Message-ID:  <20161012050817.0f11b749.freebsd@edvax.de>
In-Reply-To: <d2b31340-dac9-fb6a-ba31-1ec8ac3707e2@verizon.net>
References:  <d2b31340-dac9-fb6a-ba31-1ec8ac3707e2@verizon.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 11 Oct 2016 21:56:05 -0400, James E Keenan wrote:
> This question concerns display of colors in the command-line prompt on 
> two different FreeBSD installations.
> 
> For a couple of months I have been using VirtualBox 5.1.2 to run 
> FreeBSD-10.3 as a guest on an Ubuntu Linux 16.04 LTS host.  When working 
> in this VM I have been trying to avoid Linuxisms so as to better learn 
> how to work in a BSD environment.  One case:  I'm using Bourne shell 
> rather than Bash as the shell for my own user.

Side note: the Bourne shell (/bin/sh) is FreeBSD's default scripting
shell, but it's a poor dialog shell, that's why this task is usually
reserved for the C shell (a tcsh in fact), which is recommended for
interactive use (and not as bad as people often assume).



>  In my .shrc file, I have 
> this assignment for the spelling and color of my command-line prompt:
> 
> PS1="[^[[31m\W^[[0m] \$ "
> 
> ... where in each of two cases the '^[' is the ESCAPE character \033. 
> This produces a prompt which I can verbally describe as:
> 
> open-bracket in white; basename of pwd in red; close-bracket, space, 
> dollar-sign, space in white
> 
> ... which in the terminal looks like:
> 
> [jkeenan] $
> 
> where 'jkeenan' is in red and all the rest is in white.  So far so good.
> 
> Yesterday I installed FreeBSD-11 as a VM on the same Linux host -- only 
> this time I switched to using VMWare to house the VM.  I brought over my 
> .profile, .shrc, .vimrc, etc., files from the 10.3 VM to this new one. 
> I expected them to Just Work.  However the terminal inside the VMWare 
> console seems to be unable to digest the codes for color in the 
> assignment to $PS1.  That value for $PS1 is rendering as:
> 
> [[31mjkeenan[0m] $
> 
> ... all rendered in white; nothing in red.  The control sequences to 
> change from white to red and back again are simply being literally 
> displayed.
> 
> I should note that the VMWare console is perfectly capable of rendering 
> different colors.  Vim gets nice colors in syntax highlighting for both 
> sh and perl.
> 
> Does anyone have a clue as to why $PS1 DWIMs on FreeBSD-10.3 in 
> VirtualBox while FreeBSD-11.0 does not in VMWare?

Has there been a change to the shell, is the configuration file
somehow "damaged", or are you using some nonstandard $TERM setting
(or other setting in a relevant file) in that specific combination?

Hint: It helps to "diff .shrc.works .shrc.doesnot" and look for
the PS1 setting output (which there ideally should be none).


-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20161012050817.0f11b749.freebsd>