diff mbox series

[v6,4/4] package/environment-setup: adding custom PS1

Message ID 1588085161-28104-4-git-send-email-angelo@amarulasolutions.com
State Rejected
Headers show
Series [v6,1/4] package/environment-setup: new package | expand

Commit Message

Angelo Compagnucci April 28, 2020, 2:46 p.m. UTC
In order to simplify the usage of a buildroot toolchain within
the buildroot shell, a custom PS1 is optionally available.
This PS1 will show the sdk version actually loaded, this can
be useful to not confuse this shell with a normal one.

Signed-off-by: Angelo Compagnucci <angelo@amarulasolutions.com>
---
 package/environment-setup/Config.in.host       | 10 ++++++++++
 package/environment-setup/environment-setup.mk |  3 +++
 2 files changed, 13 insertions(+)

Comments

Thomas Petazzoni Nov. 3, 2020, 9:46 p.m. UTC | #1
On Tue, 28 Apr 2020 16:46:01 +0200
Angelo Compagnucci <angelo@amarulasolutions.com> wrote:

> In order to simplify the usage of a buildroot toolchain within
> the buildroot shell, a custom PS1 is optionally available.
> This PS1 will show the sdk version actually loaded, this can
> be useful to not confuse this shell with a normal one.
> 
> Signed-off-by: Angelo Compagnucci <angelo@amarulasolutions.com>
> ---
>  package/environment-setup/Config.in.host       | 10 ++++++++++
>  package/environment-setup/environment-setup.mk |  3 +++
>  2 files changed, 13 insertions(+)

I've marked this one as Rejected: since the beginning Yann has
expressed that changing the PS1 of the user was not acceptable, and we
believe indeed it shouldn't be changed. Also, it's probably not the
most important aspect of environment-setup.

Thanks,

Thomas
Angelo Compagnucci Nov. 3, 2020, 9:56 p.m. UTC | #2
Hi Thomas,

On Tue, Nov 3, 2020 at 10:46 PM Thomas Petazzoni
<thomas.petazzoni@bootlin.com> wrote:
>
> On Tue, 28 Apr 2020 16:46:01 +0200
> Angelo Compagnucci <angelo@amarulasolutions.com> wrote:
>
> > In order to simplify the usage of a buildroot toolchain within
> > the buildroot shell, a custom PS1 is optionally available.
> > This PS1 will show the sdk version actually loaded, this can
> > be useful to not confuse this shell with a normal one.
> >
> > Signed-off-by: Angelo Compagnucci <angelo@amarulasolutions.com>
> > ---
> >  package/environment-setup/Config.in.host       | 10 ++++++++++
> >  package/environment-setup/environment-setup.mk |  3 +++
> >  2 files changed, 13 insertions(+)
>
> I've marked this one as Rejected: since the beginning Yann has
> expressed that changing the PS1 of the user was not acceptable, and we
> believe indeed it shouldn't be changed. Also, it's probably not the
> most important aspect of environment-setup.

I honestly totally disagree. I consider having a custom PS1 quite
important, I had several funny moments understand why I was having a
python version on a shell and a totally different python version on
the next one.
Restoring your old PS1 is quite easy and people like Yann will not use
the buildroot shell anyway ;)
The feature was of course taught for the average daily programmer who
needs to know boldly where he is running what.

Anyway, I'm happy this series was finally accepted, I would post some
more things in the feature.

Thanks

>
> Thanks,
>
> Thomas
> --
> Thomas Petazzoni, CTO, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com
diff mbox series

Patch

diff --git a/package/environment-setup/Config.in.host b/package/environment-setup/Config.in.host
index 87f460d..1af826e 100644
--- a/package/environment-setup/Config.in.host
+++ b/package/environment-setup/Config.in.host
@@ -4,3 +4,13 @@  config BR2_PACKAGE_HOST_ENVIRONMENT_SETUP
 	  Install an helper script to setup a build environment
 	  based on buildroot. It's useful when you export an sdk
 	  and want to use buildroot to build an external project
+
+if BR2_PACKAGE_HOST_ENVIRONMENT_SETUP
+
+config BR2_PACKAGE_HOST_ENVIRONMENT_SETUP_PS1
+	bool "export custom PS1"
+	help
+	  Whan sourced, the script will replace the PS1 with a
+	  custom one reporting SDK version in use.
+
+endif
diff --git a/package/environment-setup/environment-setup.mk b/package/environment-setup/environment-setup.mk
index ba85691..b024983 100644
--- a/package/environment-setup/environment-setup.mk
+++ b/package/environment-setup/environment-setup.mk
@@ -34,6 +34,9 @@  define HOST_ENVIRONMENT_SETUP_INSTALL_CMDS
 	printf "export \"PATH=\$$SDK_PATH/bin:\$$SDK_PATH/sbin:\$$PATH\"\n" \
 		>> $(ENVIRONMENT_SETUP_FILE)
 
+	$(if $(BR2_PACKAGE_HOST_ENVIRONMENT_SETUP_PS1),\
+		printf "PS1=\"\[\e[32m\]buildroot-$(BR2_VERSION)\[\e[m\]:\[\e[34m\]\w\[\e[m\]\$$ \"\n" \
+		>> $(ENVIRONMENT_SETUP_FILE),)
 endef
 
 $(eval $(host-generic-package))