[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] environment: Add a prompt-name argument.
From: |
Roel Janssen |
Subject: |
[PATCH] environment: Add a prompt-name argument. |
Date: |
Thu, 20 Oct 2016 13:09:45 +0200 |
User-agent: |
mu4e 0.9.17; emacs 25.1.1 |
Dear Guix,
Having multiple virtual terminals open, each running in their own
environment created with @code{guix environment} can become confusing to
the user. Therefore, I would like to add an option to pass a name to
the shell prompt. Currently we default to "[env]".
This patch adds a -p and --prompt-name argument to @code{guix
environment}, and puts the argument's value between the square brackets
instead of "env".
Examples:
address@hidden guix]$ guix environment --container --prompt-name="guile" guile
address@hidden ~/sources/guix [guile]#
address@hidden guix]$ guix environment --container -p "guile" guile
address@hidden ~/sources/guix [guile]#
address@hidden guix]$ guix environment --container guile
address@hidden ~/sources/guix [env]#
Now, I don't know what the correct naming for the argument is
(prompt-name). So, I have two questions:
0. Do you think we should apply this patch?
1. What name should the argument have?
Kind regards,
Roel Janssen
>From ea958e847019c94a2bde49285f1436dfec72e570 Mon Sep 17 00:00:00 2001
From: Roel Janssen <address@hidden>
Date: Thu, 20 Oct 2016 13:07:15 +0200
Subject: [PATCH] environment: Add a prompt-name argument.
* guix/scripts/environment.scm: Add --prompt-name (-p) argument.
---
guix/scripts/environment.scm | 29 ++++++++++++++++++++---------
1 file changed, 20 insertions(+), 9 deletions(-)
diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm
index 0c69bfc..e36c97e 100644
--- a/guix/scripts/environment.scm
+++ b/guix/scripts/environment.scm
@@ -149,6 +149,8 @@ COMMAND or an interactive shell in that environment.\n"))
--ad-hoc include all specified packages in the environment
instead
of only their inputs"))
(display (_ "
+ -p, --prompt-name use PROMPT-NAME in the command prompt of the
environment"))
+ (display (_ "
--pure unset existing environment variables"))
(display (_ "
--search-paths display needed environment variable definitions"))
@@ -237,6 +239,9 @@ COMMAND or an interactive shell in that environment.\n"))
(option '(#\N "network") #f #f
(lambda (opt name arg result)
(alist-cons 'network? #t result)))
+ (option '(#\p "prompt-name") #t #f
+ (lambda (opt name arg result)
+ (alist-cons 'prompt-name arg result)))
(option '("share") #t #f
(lambda (opt name arg result)
(alist-cons 'file-system-mapping
@@ -376,7 +381,7 @@ environment variables are cleared before setting the new
ones."
((_ . status) status)))))
(define* (launch-environment/container #:key command bash user-mappings
- profile paths network?)
+ profile paths network? prompt-name)
"Run COMMAND within a container that features the software in PROFILE.
Environment variables are set according to PATHS, a list of native search
paths. The global shell is BASH, a file name for a GNU Bash binary in the
@@ -434,7 +439,11 @@ host file systems to mount inside the container."
(symlink bash "/bin/sh")
;; Set a reasonable default PS1.
- (setenv "PS1" "address@hidden \\w [env]\\$ ")
+ (setenv "PS1" (string-append "address@hidden \\w ["
+ (if (not prompt-name)
+ "env"
+ prompt-name)
+ "]\\$ "))
;; Setup directory for temporary files.
(mkdir-p "/tmp")
@@ -525,13 +534,14 @@ message if any test fails."
;; Entry point.
(define (guix-environment . args)
(with-error-handling
- (let* ((opts (parse-args args))
- (pure? (assoc-ref opts 'pure))
- (container? (assoc-ref opts 'container?))
- (network? (assoc-ref opts 'network?))
- (bootstrap? (assoc-ref opts 'bootstrap?))
- (system (assoc-ref opts 'system))
- (command (or (assoc-ref opts 'exec)
+ (let* ((opts (parse-args args))
+ (pure? (assoc-ref opts 'pure))
+ (container? (assoc-ref opts 'container?))
+ (network? (assoc-ref opts 'network?))
+ (prompt-name (assoc-ref opts 'prompt-name))
+ (bootstrap? (assoc-ref opts 'bootstrap?))
+ (system (assoc-ref opts 'system))
+ (command (or (assoc-ref opts 'exec)
;; Spawn a shell if the user didn't specify
;; anything in particular.
(if container?
@@ -604,6 +614,7 @@ message if any test fails."
#:user-mappings mappings
#:profile profile
#:paths paths
+ #:prompt-name prompt-name
#:network? network?)))
(else
(return
--
2.10.0
- [PATCH] environment: Add a prompt-name argument.,
Roel Janssen <=