Skip to content

kekse1/prompt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

130 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


My notorious $PS1 prompt

By using the $PROMPT_COMMAND variable, this script dynamically creates the $PS1 prompt.


kinda logo


  • [2026-06-07] Fixed all the ANSI color glitches/artefacts.. see Details; v2.12.3!
  • [2026-06-07] New configuration variable $_LAST; really tiny, but it matters (at least for me); v2.12.2.
  • [2026-06-07] Two tiny fixes/updates; looks really better now! v2.12.1;
  • [2026-06-07] Finished the new $_SLASH option! No longer buggy, so enabled by default! v2.12.0;
  • [2026-01-31] $_LIST default changed to (0); ...
  • [2026-01-30] New setting $_CHANGE, v2.11.0;
  • [2026-01-08] Tiny color (and space) change, plus divided the load average; v2.10.3.
  • [2026-01-07] BIG design improvements; plus the new $_LINK setting; v2.10.0.
  • [2025-12-05] Update: now w/ $_NEWLINE setting, in v2.9.6;



Screenshot

This is the latest screenshot (v2.12.3). Click on it to open the full size view.

Example Screenshot; v2.12.3.



Installation

Copy this file to the /etc/profile.d/ directory. This should include it automatically when spawning a new shell etc. (via source or .).


Configuration

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
$_SUCCESS Boolean 0 Display success ($?), or only in case of errors?
$_SPACE Boolean 1 Spaces between the blocks?
$_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 0 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
$_DEPTH Integer 4 The amount of directories to show in your current working directory.. see the getBase() section
$_REST 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
$_NEWLINE Boolean 1 Start the prompt output with an empty line
$_LINK Boolean 1 Displays a warning symbol when your current working directory path is only a symbolic link (rather the realpath one)
$_CHANGE Boolean 1 A symbol when cwd changed (or it's symlink points to another location)
$_SLASH String Optional string to colorize and replace the path separators /. The pure / would be cause only white color, empty means doing nothing here.
$_LAST Boolean 0 IF you've configured $_SLASH, should the last path separator also be colorized (white) or not!?

The Boolean types are just Integer values with either 0 as false or 1 as true.


Details

It's also using ANSI Escape Sequences to colorize up the prompt (if you don't disable it via $_ANSI configuration variable).

# NOTIZ: wichtig hier war vor allem die richtige Anwendung
# der ANSI Escape Sequenzen.. in dem Sinne, dass wir fuer
# einen `$PS1` noch die beiden Strings `\[` und `\]` mit
# anwenden.. sie signalisieren der Bash, dass alle Strings
# dazwischen *keine* *visuelle* Breite haben!
#
# Wird das nicht richtig gemacht, so entstehen Artefakte
# und sonstige Glitches! Bitte niemals hier vergessen! Thx. ^_^

... in dem Sinne sind jetzt alle Fehler gefixt, denke ich.



getBase()

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 [ $_DEPTH, $_REST ];


cwd()

Query for the $PWD/pwd with resolving it's realpath.

This is for the $_LINK symbol which appears when you are inside a directory whose path is a symbolic link, not the real one (see man 1 realpath).



Contact

Copyright and License

The Copyright is (c) Sebastian Kucharczyk, and it's licensed under the MIT (also known as 'X' or 'X11' license).

Favicon

About

My notorious `$PS1` prompt

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages