Add automatic option for command prompt color customization

This commit is contained in:
iliajie
2022-11-04 21:01:34 +02:00
parent 3b86ebed97
commit 7a5e917d34
3 changed files with 7 additions and 4 deletions

View File

@@ -1,2 +1,2 @@
base_port=555
flavors=0
flavors=2

View File

@@ -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

View File

@@ -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;