By using the $PROMPT_COMMAND
variable, this script dynamically created the $PS1
prompt.
- Version v2.6.2 (updated 2025-03-10)
- [2025-03-10] Also updated the example screenshot;
- [2025-03-10] v2.6.2 w/ some changed colors. Looks a bit better now (imho);
- [2025-03-05] v2.6.1 w/ correct
local
everywhere; plus better listings - [2025-03-03] Update to v2.5.2: new config variable
$_CODE
! - [2025-03-01] Update to v2.4.0: new
_TTY
configuration; - [2025-03-01] Update to v2.3.0: including
ls
output if$PWD
changed (see$_LIST
config); - [2024-07-12] New v2.1.5. Both 'root' colors (UID+GID) have changed;
Copy this file to the /etc/profile.d/
directory. This should include it automatically
when spawning a new shell etc. (via source
or .
).
The configuration is located on top of the file (as simple variables, which will be enforced into your environments where you include this script).
Tip
If you want to test them, or just change the config during usage, you can easily
change the variables in your console! Example given: _LIST=0
will
temporarily disable the directory listings. After/with the next login
the values will be the original ones, right as defined in the script/file.
Variable name | Type | Default | Description |
---|---|---|---|
$_CODE |
Boolean | 1 | Instead of indicating errors (return values != 0) with an ✘, the real error code is being displayed. |
$_TTY |
Boolean | 1 | Includes the currently used tty in it's output |
$_LIST |
Boolean | 1 | When directory changes(!), you'll get to see it's contents. |
$_TERMUX |
Boolean | 0 | Will enforce some settings to fit better to the Termux Linux (for Android phones) |
$_ANSI |
Boolean | 1 | Here you could also disable all ANSI Escape Sequences (for colors and styles) |
$_MULTI_LINE |
Boolean | 1 | Looks better when using a two line prompt |
$_SLASHES |
Integer | 4 | The amount of directories to show in your current working directory.. see the getBase() section |
$_REST_STRING |
String | ... |
Also for the getBase() function: the cut off parts of your current working directory are replaced by this string |
$_COUNT |
Boolean | 1 | Will also show the amount of directories and regular files in the current working directory |
$_HOSTNAME |
Boolean | 1 | Also show your machine's hostname (if set, directly at the username) |
$_USERNAME |
Boolean | 1 | Would also include your username in the output (if set, directly at the hostname) |
$_LOAD |
Boolean | 1 | The load average (parsing the /proc/loadavg ; if not readable or available, it'll be ignored) |
$_DATE |
Boolean | 1 | Depends on the both variables below [ $_DATE_FORMAT_ONE and $_DATE_FORMAT_TWO ] |
$_DATE_FORMAT_ONE |
String | %H:%M:%S |
First date format; by default only the current time (the date in the $_DATE_FORMAT_TWO ) |
$_DATE_FORMAT_TWO |
String | %j |
Second date format; by default the number of current days in the year |
The Boolean
types are just Integer
values with either 0
as false
or 1
as true
.
It's also using ANSI Escape Sequences to colorize up the prompt (if you don't disable it via $_ANSI
configuration variable).
It also has a getBase()
function to reduce the amount of slash /
separators in the directory depth..
with a bit of intelligence. See also the configuration variables [ $_SLASHES
, $_REST_STRING
];
The Copyright is (c) Sebastian Kucharczyk, and it's licensed under the MIT (also known as 'X' or 'X11' license).
