From 7a5e917d342be36f8f8ea1a5e393c763f6d65e59 Mon Sep 17 00:00:00 2001 From: iliajie Date: Fri, 4 Nov 2022 21:01:34 +0200 Subject: [PATCH] Add automatic option for command prompt color customization --- xterm/config | 2 +- xterm/config.info | 2 +- xterm/index.cgi | 7 +++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/xterm/config b/xterm/config index 25b687c4a..3dad60653 100644 --- a/xterm/config +++ b/xterm/config @@ -1,2 +1,2 @@ base_port=555 -flavors=0 \ No newline at end of file +flavors=2 \ No newline at end of file diff --git a/xterm/config.info b/xterm/config.info index 440521e9c..3dd6190bb 100644 --- a/xterm/config.info +++ b/xterm/config.info @@ -1,3 +1,3 @@ base_port=Base port number for WebSockets connections,0,5 size=Terminal width and height in characters,3,Automatic,5,,,Static (80x24) -flavors=Enable inbuilt command prompt color customization,1,1-Yes,0-No +flavors=Enable inbuilt command prompt color customization,1,2-Automatic,1-Yes,0-No diff --git a/xterm/index.cgi b/xterm/index.cgi index 15c831b2d..ab4a202a3 100644 --- a/xterm/index.cgi +++ b/xterm/index.cgi @@ -198,10 +198,14 @@ if ($user eq "root" && $in{'user'}) { &error(&text('index_euser', &html_escape($in{'user'}))); $user = $in{'user'}; } +defined(getpwnam($user)) || &error(&text('index_euser', &html_escape($user))); +my @uinfo = getpwnam($user); +my $ushell_bash = $uinfo[8] =~ /\/bash$/; # Terminal flavors my (@cmds, $term_flavors); -if ($config{'flavors'}) { +if ($config{'flavors'} == 1 || + $config{'flavors'} == 2 && $ushell_bash) { my ($cmd_lsalias, $cmd_ps1) = ("alias ls='ls --color=auto'"); # Optionally add colors to the prompt depending on the user type @@ -231,7 +235,6 @@ my $shellserver_cmd = "$module_config_directory/shellserver.pl"; if (!-r $shellserver_cmd) { &cron::create_wrapper($shellserver_cmd, $module_name, "shellserver.pl"); } -defined(getpwnam($user)) || &error(&text('index_euser', &html_escape($user))); my $tmpdir = &tempname_dir(); $ENV{'HISTCONTROL'} = 'ignoredups:ignorespace'; $ENV{'SESSION_ID'} = $main::session_id;