From owner-freebsd-questions@freebsd.org Wed Oct 12 03:08:22 2016 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E8AB4C0E81F for ; Wed, 12 Oct 2016 03:08:22 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mx01.qsc.de (mx01.qsc.de [213.148.129.14]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B13B31A4D for ; Wed, 12 Oct 2016 03:08:22 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from r56.edvax.de (port-92-195-117-205.dynamic.qsc.de [92.195.117.205]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx01.qsc.de (Postfix) with ESMTPS id 0678A3CE0A; Wed, 12 Oct 2016 05:08:18 +0200 (CEST) Received: from r56.edvax.de (localhost [127.0.0.1]) by r56.edvax.de (8.14.5/8.14.5) with SMTP id u9C38HVB002225; Wed, 12 Oct 2016 05:08:18 +0200 (CEST) (envelope-from freebsd@edvax.de) Date: Wed, 12 Oct 2016 05:08:17 +0200 From: Polytropon To: James E Keenan 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: References: Reply-To: Polytropon Organization: EDVAX X-Mailer: Sylpheed 3.1.1 (GTK+ 2.24.5; i386-portbld-freebsd8.2) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 03:08:23 -0000 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, ...