diff --git a/xterm/index.cgi b/xterm/index.cgi index 2e5cbb2a4..0104ad786 100644 --- a/xterm/index.cgi +++ b/xterm/index.cgi @@ -195,36 +195,18 @@ if ($user eq "root" && $in{'user'}) { } my @uinfo = getpwnam($user); @uinfo || &error(&text('index_euser', &html_escape($user))); -my $ushell_bash = $uinfo[8] =~ /\/bash$/; -# Terminal flavors +# Terminal flavors (commands) my (@cmds, $term_flavors); if ($config{'flavors'} == 1 || - $config{'flavors'} == 2 && $ushell_bash) { - my ($cmd_cls, $cmd_lsalias, $cmd_ps1) = ("clear", "alias ls='ls --color=auto'"); - - # Optionally add colors to the prompt depending on the user type - if ($user eq "root") { - # magenta@blue ~# (for root) - $cmd_ps1 = "PS1='\\\\[\\\\033[1;35m\\\\]\\\\u\\\\[\\\\033[1;37m\\\\]". - "@\\\\[\\\\033[1;34m\\\\]\\\\h:\\\\[\\\\033[1;37m\\\\]". - "\\\\w\\\\[\\\\033[1;37m\\\\]\\\\\$\\\\[\\\\033[0m\\\\] '"; - } - else { - # green@blue ~$ (for regular users) - $cmd_ps1 = "PS1='\\\\[\\\\033[1;32m\\\\]\\\\u\\\\[\\\\033[1;37m\\\\]". - "@\\\\[\\\\033[1;34m\\\\]\\\\h:\\\\[\\\\033[1;37m\\\\]". - "\\\\w\\\\[\\\\033[1;37m\\\\]\\\\\$\\\\[\\\\033[0m\\\\] '"; - } - # Store more efficient shell history - $ENV{'HISTCONTROL'} = 'ignoredups:ignorespace'; + $config{'flavors'} == 2 && $uinfo[8] =~ /\/bash$/) { + my ($cmd_cls, $cmd_lsalias) = ("clear", "alias ls='ls --color=auto'"); # Pass to run commands directly $term_flavors = "socket.send(\" $cmd_lsalias\\r\"); ". - "socket.send(\" $cmd_ps1\\r\");". "socket.send(\" $cmd_cls\\r\"); "; - # Pass to run commands by the theme later - push(@cmds, $cmd_ps1, $cmd_lsalias, $cmd_cls); + # Pass to run commands within theme later + push(@cmds, $cmd_lsalias, $cmd_cls); } # Check for directory to start the shell in diff --git a/xterm/shellserver.pl b/xterm/shellserver.pl index 12459e2f4..9f3a6302d 100755 --- a/xterm/shellserver.pl +++ b/xterm/shellserver.pl @@ -27,6 +27,38 @@ else { # Run the user's shell in a sub-process &foreign_require("proc"); &clean_environment(); + +# Terminal inbuilt flavors (envs) +if ($config{'flavors'} == 1 || + $config{'flavors'} == 2 && $uinfo[8] =~ /\/bash$/) { + + # Set shell history controls + $ENV{'HISTCONTROL'} = 'ignoredups:ignorespace'; + + # Set PS1, if flavors are forced or + # skip in auto mode, if already set + if ($config{'flavors'} == 1 || + $config{'flavors'} == 2 && !$ENV{'PS1'}) { + my $ps1; + + # Optionally add colors to the prompt depending on the user type + if ($user eq "root") { + # magenta@blue ~# (for root) + $ps1 = '\[\033[1;35m\]\u\[\033[1;37m\]@'. + '\[\033[1;34m\]\h:\[\033[1;37m\]'. + '\w\[\033[1;37m\]$\[\033[0m\] '; + } + else { + # green@blue ~$ (for regular users) + $ps1 = '\[\033[1;32m\]\u\[\033[1;37m\]@'. + '\[\033[1;34m\]\h:\[\033[1;37m\]'. + '\w\[\033[1;37m\]$\[\033[0m\] '; + } + $ENV{'PS1'} = $ps1; + } + } + +# Set terminal $ENV{'TERM'} = 'xterm-256color'; chdir($dir || $uinfo[7] || "/"); my ($shellfh, $pid) = &proc::pty_process_exec($uinfo[8], $uid, $gid);