guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: guix environment & PS1


From: 韋嘉誠
Subject: Re: guix environment & PS1
Date: Thu, 25 Jun 2015 22:40:58 +0200

On Thu, Jun 25, 2015 at 10:00 PM, Claes Wallin (韋嘉誠)
<address@hidden> wrote:
> On Thu, Jun 25, 2015 at 3:28 PM, Ricardo Wurmus
> <address@hidden> wrote:
>> Thompson, David <address@hidden> writes:
>>> On Thu, Jun 25, 2015 at 8:02 AM, Ricardo Wurmus
>>> <address@hidden> 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 via email to

[Prev in Thread] Current Thread [Next in Thread]