diff --git a/doc/manual/index.docbook b/doc/manual/index.docbook
--- a/doc/manual/index.docbook
+++ b/doc/manual/index.docbook
@@ -1013,6 +1013,7 @@
%D : current directory (long)
%h : local host (short)
%u : user name
+%B : user's Bourne prompt sigil ($, or # for superuser)
%w : window title set by shell
%# : session number
diff --git a/src/Session.cpp b/src/Session.cpp
--- a/src/Session.cpp
+++ b/src/Session.cpp
@@ -1115,6 +1115,7 @@
*
* The markers recognized are:
*
+ * - %B - User's Bourne prompt sigil ($, or # for superuser).
* - %u - Name of the user which owns the process.
* - %n - Replaced with the name of the process.
* - %d - Replaced with the last part of the path name of the
@@ -1128,6 +1129,20 @@
*/
QString title = tabTitleFormat(Session::LocalTabTitle);
// search for and replace known marker
+
+ int UID = process->userId(&ok);
+ if(!ok) {
+ title.replace(QLatin1String("%B"), QStringLiteral("-"));
+ } else {
+ //title.replace(QLatin1String("%I"), QString::number(UID));
+ if (UID == 0) {
+ title.replace(QLatin1String("%B"), QStringLiteral("#"));
+ } else {
+ title.replace(QLatin1String("%B"), QStringLiteral("$"));
+ }
+ }
+
+
title.replace(QLatin1String("%u"), process->userName());
title.replace(QLatin1String("%h"), Konsole::ProcessInfo::localHost());
title.replace(QLatin1String("%n"), process->name(&ok));
@@ -1143,17 +1158,15 @@
title.replace(QLatin1String("%d"), QStringLiteral("-"));
title.replace(QLatin1String("%D"), QStringLiteral("-"));
} else {
- if (title.contains(QLatin1String("%D"))) {
- const QString homeDir = process->userHomeDir();
- if (!homeDir.isEmpty()) {
- // Change User's Home Dir w/ ~ only at the beginning
- if (dir.startsWith(homeDir)) {
- dir.remove(0, homeDir.length());
- dir.prepend(QLatin1Char('~'));
- }
+ // allow for shortname to have the ~ as homeDir
+ const QString homeDir = process->userHomeDir();
+ if (!homeDir.isEmpty()) {
+ if (dir.startsWith(homeDir)) {
+ dir.remove(0, homeDir.length());
+ dir.prepend(QLatin1Char('~'));
}
- title.replace(QLatin1String("%D"), dir);
}
+ title.replace(QLatin1String("%D"), dir);
title.replace(QLatin1String("%d"), process->formatShortDir(dir));
}
diff --git a/src/TabTitleFormatButton.cpp b/src/TabTitleFormatButton.cpp
--- a/src/TabTitleFormatButton.cpp
+++ b/src/TabTitleFormatButton.cpp
@@ -36,7 +36,8 @@
{ QStringLiteral("%w"), I18N_NOOP("Window Title Set by Shell: %w") },
{ QStringLiteral("%#"), I18N_NOOP("Session Number: %#") },
{ QStringLiteral("%u"), I18N_NOOP("User Name: %u") },
- { QStringLiteral("%h"), I18N_NOOP("Local Host: %h") }
+ { QStringLiteral("%h"), I18N_NOOP("Local Host: %h") },
+ { QStringLiteral("%B"), I18N_NOOP("User's Bourne prompt sigil: %B") } // ($, or # for superuser)
};
const int TabTitleFormatButton::_localElementCount
= sizeof(_localElements) / sizeof(TabTitleFormatButton::Element);