From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?B?Q2xhZXMgV2FsbGluICjpn4vlmInoqqAp?= Subject: Re: guix environment & PS1 Date: Thu, 25 Jun 2015 22:40:58 +0200 Message-ID: References: <1435182094-13537-1-git-send-email-tipecaml@gmail.com> <87fv5gj9je.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:36967) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z8DxM-0004eG-GW for guix-devel@gnu.org; Thu, 25 Jun 2015 16:41:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z8DxH-0007Dp-JK for guix-devel@gnu.org; Thu, 25 Jun 2015 16:41:08 -0400 Received: from mail.lysator.liu.se ([130.236.254.3]:52611) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z8DxH-0007De-Ck for guix-devel@gnu.org; Thu, 25 Jun 2015 16:41:03 -0400 Received: from mail.lysator.liu.se (localhost [127.0.0.1]) by mail.lysator.liu.se (Postfix) with ESMTP id 589DB4002C for ; Thu, 25 Jun 2015 22:41:01 +0200 (CEST) Received: from mail-oi0-f45.google.com (mail-oi0-f45.google.com [209.85.218.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.lysator.liu.se (Postfix) with ESMTPSA id D8D894000E for ; Thu, 25 Jun 2015 22:40:59 +0200 (CEST) Received: by oiyy130 with SMTP id y130so61452776oiy.0 for ; Thu, 25 Jun 2015 13:40:58 -0700 (PDT) In-Reply-To: List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: Ricardo Wurmus Cc: guix-devel On Thu, Jun 25, 2015 at 10:00 PM, Claes Wallin (=E9=9F=8B=E5=98=89=E8=AA=A0= ) wrote: > On Thu, Jun 25, 2015 at 3:28 PM, Ricardo Wurmus > wrote: >> Thompson, David writes: >>> On Thu, Jun 25, 2015 at 8:02 AM, Ricardo Wurmus >>> wrote: >>>> >>>> Would it be feasible to give "GUIX_ENVIRONMENT" the package name as a >>>> value instead of just "t"? >>> >>> Not really, because 'guix environment' accepts any number of packages. >> >> Oh, right. I forgot about ad-hoc environments and =E2=80=9Cguix environ= ment >> -l=E2=80=9D. >> >> I=E2=80=99m mostly using =E2=80=9Cguix environment=E2=80=9D with a singl= e package name, and for >> that purpose it would be nice if I could make the shell prompt indicate >> for what package this environment was created. I guess =E2=80=9Ct=E2=80= =9D as a value >> for =E2=80=9CGUIX_ENVIRONMENT=E2=80=9D will have to do then. > > As the variable is mostly meant for human-readable display, I think > setting it to "guix guile emacs" if those were the packages given, or > "mypackage.scm" if that was the file given, is strictly an improvement > over "t". People who just want to know if we're in a constructed > environment or not can check if the variable exists. On the other hand, this could all be done outside guix. I went ahead and did it for myself, because I have wanted it for a couple of days. function genv() { GUIX_ENVIRONMENT=3D$* guix environment "$@" } function __genv_ps1() { local format=3D$1; [ -v GUIX_ENVIRONMENT ] || return [[ -z $format ]] && format=3D" (%s)" printf "$format" "$GUIX_ENVIRONMENT" } ... and then just chuck a $(__genv_ps1) somewhere in your favorite $PS1 definition.