$PS1 does not render command-line prompt in color in a FreeBSD VM
James E Keenan
jkeen at verizon.net
Wed Oct 12 12:12:37 UTC 2016
On 10/11/2016 11:08 PM, Polytropon wrote:
> 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?
>
No, as stated above, I copied over the .shrc file from one FreeBSD VM to
another. I did so with all the other relevant config files. So I'm
trying to determine why that file is processed differently in the two
environments.
> Hint: It helps to "diff .shrc.works .shrc.doesnot" and look for
> the PS1 setting output (which there ideally should be none).
>
>
More information about the freebsd-questions
mailing list