unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Claes Wallin (韋嘉誠)" <gnu@clacke.user.lysator.liu.se>
To: Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de>
Cc: guix-devel <guix-devel@gnu.org>
Subject: Re: guix environment & PS1
Date: Thu, 25 Jun 2015 22:40:58 +0200	[thread overview]
Message-ID: <CAGv_=BpdUM8NVNPJJcsGY6DSwPVRsOL_hoVWJzHfEa8Y4fAr8g@mail.gmail.com> (raw)
In-Reply-To: <CAGv_=Bppa9ezyi9UDt=YPLkVvC=9Dx+sAQWhH0uP+jPQD957og@mail.gmail.com>

On Thu, Jun 25, 2015 at 10:00 PM, Claes Wallin (韋嘉誠)
<gnu@clacke.user.lysator.liu.se> wrote:
> On Thu, Jun 25, 2015 at 3:28 PM, Ricardo Wurmus
> <ricardo.wurmus@mdc-berlin.de> wrote:
>> Thompson, David <dthompson2@worcester.edu> writes:
>>> On Thu, Jun 25, 2015 at 8:02 AM, Ricardo Wurmus
>>> <ricardo.wurmus@mdc-berlin.de> 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 “guix environment
>> -l”.
>>
>> I’m mostly using “guix environment” with a single 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 “t” as a value
>> for “GUIX_ENVIRONMENT” 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=$* guix environment "$@"
}

function __genv_ps1() {
  local format=$1;

  [ -v GUIX_ENVIRONMENT ] || return

  [[ -z $format ]] && format=" (%s)"

  printf "$format" "$GUIX_ENVIRONMENT"
}

... and then just chuck a $(__genv_ps1) somewhere in your favorite
$PS1 definition.

  reply	other threads:[~2015-06-25 20:41 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-24 21:41 [PATCH] guix environment: add a '--env-name' option Cyril Roelandt
2015-06-25 11:45 ` guix environment & PS1 Ludovic Courtès
2015-06-25 12:02   ` Ricardo Wurmus
2015-06-25 13:04     ` Thompson, David
2015-06-25 13:28       ` Ricardo Wurmus
2015-06-25 20:00         ` Claes Wallin (韋嘉誠)
2015-06-25 20:40           ` Claes Wallin (韋嘉誠) [this message]
2015-06-29  8:41           ` Ludovic Courtès
2015-06-29 10:04             ` Claes Wallin (韋嘉誠)
2015-06-25 13:02   ` Thompson, David
2015-07-01 13:10     ` Ludovic Courtès
2015-07-01 13:59       ` Thompson, David
2015-07-01 17:07         ` Claes Wallin (韋嘉誠)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAGv_=BpdUM8NVNPJJcsGY6DSwPVRsOL_hoVWJzHfEa8Y4fAr8g@mail.gmail.com' \
    --to=gnu@clacke.user.lysator.liu.se \
    --cc=guix-devel@gnu.org \
    --cc=ricardo.wurmus@mdc-berlin.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).