From 328c1c13e326766a70e61a5639446e3e9f27d8c6 Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Fri, 3 Jun 2022 21:31:26 -0400 Subject: [PATCH] Fine grained control over prompt elements. Use `CSHENV_DISABLE_PROMPT_` env vars to control these. --- tcshrc.prompt.defs | 7 +----- tcshrc.prompt.final | 53 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 53 insertions(+), 7 deletions(-) diff --git a/tcshrc.prompt.defs b/tcshrc.prompt.defs index 52428e5..3e01620 100644 --- a/tcshrc.prompt.defs +++ b/tcshrc.prompt.defs @@ -122,12 +122,7 @@ if( $?CSHENV_DEBUG ) then endif -set depth_prompt=" ${depth_color_seq}(${shlvl})${text_color_seq}\- " -if( $?CSHENV_HIDE_SHELL_LEVEL_AT_ONE ) then - if( $shlvl == 1 ) then - set depth_prompt="${text_color_seq}\- " - endif -endif +set depth_prompt="${depth_color_seq}(${shlvl})" #we "convert" pts/$number entries to ttypK entries? set line_prompt="${line_color_seq}`tty | sed -e 's;/dev/tty;;' -e 's;/dev/pts/;p/;' -e 's;/dev/;;' -e 's/not a tty/${unknown_tty}/'`" diff --git a/tcshrc.prompt.final b/tcshrc.prompt.final index a43bc8b..3043893 100644 --- a/tcshrc.prompt.final +++ b/tcshrc.prompt.final @@ -142,7 +142,58 @@ else endif #set prompt_cool="%{\n%}${align_prefix}${battery_prefix}${battery_prompt}${date_prompt}${align_suffix}${git_prompt}${brace_color_seq}\[${prompt_reference}${line_prompt}${depth_prompt}${user_prompt}${at_color_seq}@${host_prompt}${text_color_seq}\: ${path_prompt}${brace_color_seq}\]${end_prompt}" -set prompt_cool="%{\n%}${align_prefix}${battery_prefix}${battery_prompt}${date_prompt}${align_suffix}${brace_color_seq}\[${prompt_reference}${line_prompt}${depth_prompt}${user_prompt}${at_color_seq}@${host_prompt}${text_color_seq}\: ${git_prompt}${path_prompt}${brace_color_seq}\]${end_prompt}" +set prompt_reference_view="" +set line_prompt_view="" +set depth_prompt_view="" +set user_prompt_view +set at_view="" +set host_prompt_view="" +set git_prompt_view="" +set path_prompt_view="" +set line_spacer_view="" + +if( ! $?CSHENV_DISABLE_PROMPT_SIGIL ) then + set prompt_reference_view="${prompt_reference}" +endif +if( ! $?CSHENV_DISABLE_PROMPT_TTY ) then + set line_prompt_view="${line_prompt}" + set line_spacer_view="${text_color_seq}\- " +endif +if( ! $?CSHENV_DISABLE_PROMPT_NESTING ) then + set depth_prompt_spacing="" + if( ! $?CSHENV_DISABLE_PROMPT_TTY ) then + set depth_prompt_spacing=" " + endif + set depth_prompt_view="${depth_prompt_spacing}${depth_prompt}" + if( $?CSHENV_HIDE_SHELL_LEVEL_AT_ONE ) then + if( ${shlvl} == 1 ) then + set depth_prompt_view="" + endif + endif +endif +if( ! $?CSHENV_DISABLE_PROMPT_USER ) then + set user_prompt_view="${user_prompt}" + if( ! $?CSHENV_DISABLE_PROMPT_HOST ) then + set at_view="${at_color_seq}@" + endif +endif +if( ! $?CSHENV_DISABLE_PROMPT_HOST ) then + set host_prompt_tail=": " + if( $?CSHENV_DISABLE_PROMPT_GIT && $?CSHENV_DISABLE_PROMPT_PATH ) then + set host_prompt_tail="" + endif + set host_prompt_view="${host_prompt}${text_color_seq}${host_prompt_tail}" +endif +if( ! $?CSHENV_DISABLE_PROMPT_GIT ) then + set git_prompt_view="${git_prompt}" +endif +if( ! $?CSHENV_DISABLE_PROMPT_PATH ) then + set path_prompt_view="${path_prompt}" +endif + +set prompt_cool="%{\n%}${align_prefix}${battery_prefix}${battery_prompt}${date_prompt}${align_suffix}${brace_color_seq}\[${prompt_reference_view}${line_prompt_view}${depth_prompt_view}${line_spacer_view}${user_prompt_view}${at_view}${host_prompt_view}${git_prompt_view}${path_prompt_view}${brace_color_seq}\]${end_prompt}" + + if( ! ${?cshenv_user_prompt_override} ) then set prompt="$prompt_cool"