From b3c00b70092b37798449f9ffc2283bbcab2c19a3 Mon Sep 17 00:00:00 2001 From: Literate Snow Date: Tue, 23 Jan 2024 23:22:30 +0100 Subject: [PATCH 1/2] Option to disable modification of the user's prompt. --- internal/devbox/shellrc.tmpl | 7 +++++-- internal/devbox/shellrc_fish.tmpl | 11 +++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/internal/devbox/shellrc.tmpl b/internal/devbox/shellrc.tmpl index 24a314e137c..6f0e5f521a8 100644 --- a/internal/devbox/shellrc.tmpl +++ b/internal/devbox/shellrc.tmpl @@ -38,8 +38,11 @@ ignore the existing value of HISTFILE. HISTFILE="{{ .HistoryFile }}" {{- end }} -# Prepend to the prompt to make it clear we're in a devbox shell. -export PS1="(devbox) $PS1" +# If the user hasn't specified they want to handle the prompt themselves, +# prepend to the prompt to make it clear we're in a devbox shell. +if [ -z "$DEVBOX_NO_PROMPT" ]; then + export PS1="(devbox) $PS1" +fi {{- if .ShellStartTime }} # log that the shell is ready now! diff --git a/internal/devbox/shellrc_fish.tmpl b/internal/devbox/shellrc_fish.tmpl index daf252adeca..a50b3fb2ea6 100644 --- a/internal/devbox/shellrc_fish.tmpl +++ b/internal/devbox/shellrc_fish.tmpl @@ -38,10 +38,13 @@ enough approximation for now. set fish_history devbox {{- end }} -# Prepend to the prompt to make it clear we're in a devbox shell. -functions -c fish_prompt __devbox_fish_prompt_orig -function fish_prompt - echo "(devbox)" (__devbox_fish_prompt_orig) +# If the user hasn't specified they want to handle the prompt themselves, +# prepend to the prompt to make it clear we're in a devbox shell. +if not set -q devbox_no_prompt + functions -c fish_prompt __devbox_fish_prompt_orig + function fish_prompt + echo "(devbox)" (__devbox_fish_prompt_orig) + end end {{- if .ShellStartTime }} From 30acd27e72e76819938952940b7166154beeb070 Mon Sep 17 00:00:00 2001 From: Literate Snow Date: Wed, 24 Jan 2024 08:25:16 +0100 Subject: [PATCH 2/2] Fix tests. --- internal/devbox/testdata/shellrc/basic/shellrc.golden | 7 +++++-- internal/devbox/testdata/shellrc/noshellrc/shellrc.golden | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/internal/devbox/testdata/shellrc/basic/shellrc.golden b/internal/devbox/testdata/shellrc/basic/shellrc.golden index ac2c2b2de20..9e110a4a68d 100644 --- a/internal/devbox/testdata/shellrc/basic/shellrc.golden +++ b/internal/devbox/testdata/shellrc/basic/shellrc.golden @@ -8,8 +8,11 @@ export simple="value"; export space="quote me"; export special="\$\`\"\\"; -# Prepend to the prompt to make it clear we're in a devbox shell. -export PS1="(devbox) $PS1" +# If the user hasn't specified they want to handle the prompt themselves, +# prepend to the prompt to make it clear we're in a devbox shell. +if [ -z "$DEVBOX_NO_PROMPT" ]; then + export PS1="(devbox) $PS1" +fi # End Devbox Post-init Hook diff --git a/internal/devbox/testdata/shellrc/noshellrc/shellrc.golden b/internal/devbox/testdata/shellrc/noshellrc/shellrc.golden index 10f6de23338..e7ac3d7ba06 100644 --- a/internal/devbox/testdata/shellrc/noshellrc/shellrc.golden +++ b/internal/devbox/testdata/shellrc/noshellrc/shellrc.golden @@ -2,8 +2,11 @@ -# Prepend to the prompt to make it clear we're in a devbox shell. -export PS1="(devbox) $PS1" +# If the user hasn't specified they want to handle the prompt themselves, +# prepend to the prompt to make it clear we're in a devbox shell. +if [ -z "$DEVBOX_NO_PROMPT" ]; then + export PS1="(devbox) $PS1" +fi # End Devbox Post-init Hook