Minimal and versatile bash prompt
- Colored exit status
- Easily configurable
- Fully customizable: colors, symbols, the prompt itself, and more...
- Better history
- Better completion
- Directory colors support
- Trimming path
- Various extensions
- Git
- Kubernetes
- SSH
- IP address
- WIFI
- Package versions
- Extensions can be toggled on and off on the fly
Make sure you have the following programs installed in your system:
- GNU Make
git
npm
(for the npm installer)- General utilities like
grep
,sed
,awk
, ... - A patched Nerd Font (optional)
$ npm install --global miniprompt.sh
If it throws an error then run the command with
sudo
$ git clone [email protected]:Pocco81/MiniPrompt.git && cd MiniPrompt
$ make install
Installs the prompt under your local bins:
~/.local/bin
. Make sure this directory is in your$PATH
; if it's not, paste this into your~/.bashrc
:
export PATH=$PATH:"$HOME/.local/bin"
👷🛑 Under dev
Two things:
- Enable the prompt in your
~/.bashrc
- Configure it
To enable the prompt paste this into your ~/.bashrc
:
alias mp="source miniprompt"
mp
After that, feel free to customize the prompt to your like using the conf.toml
file (located under ${XDG_CONFIG_HOME}/miniprompt/conf.toml
. If the $XDG_CONFIG_HOME
env var is not set then it'll be assumed to be $HOME/.config/
).
Here is the default config:
# MiniPrompt's config file
[behaviour]
colored_exit_status = true # prettify the exit status of the previous command
dirtrim = 2 # trim the CWD to only show x number of dirs
enhanced_autocompletion = true # completion maps, tilde expansion, mark directories, ...
enhanced_history_format = true # better format for your shell history: [%Y-%m-%d %T]
dircolors = true # color directories
[primary_prompt]
prefix = "\[\e]0;\w\a\]" # prompt prefix
ps_content = "</yellow>\w</nc> " # the actual content of your prompt
ps_suffix = "</green>➜</nc> " # after the ps_content
normal_color = "nc" # the color text is defaulted to
error_symbol = "✗" # symbol to use after the previous command failed
failed = "red" # $error_mark's color after the previous command executed successfully
[extensions]
ext_git = false # enable git extension (shows current working branch)
ext_ssh = false # enable ssh expansion (shows <user>@<machine>)
ext_package = false # enable package expansion (shows project's current version)
ext_kubernetes = false # enable kubernetes extension (shows kubernetes' current context)
ext_ip = false # enable kubernetes extension (shows kubernetes' current context)
ext_wifi = false
git_struct = "</cyan> </unit> " # structure of the integration
ssh_struct = "</magenta> </unit> " # structure of the integration
package_struct = "</white> v</unit> " # structure of the integration
ip_struct = "</gray_br> </unit> " # structure of the integration
wifi_struct = "</blue>直 </unit> " # structure of the integration
hierarchy = "ssh, git, ip, wifi, package" # order in which the extensions are displayed
ps_content = "</yellow_it>\w </blue_re> \@ \n</magenta> \u</nc> "
ps_content = "</magenta></magenta_re>\A </cyan_re> \w</cyan></nc> "
ps_suffix = "</blue></nc> " # after the ps_content
[primary_prompt]
ps_content = "</yellow>\w</nc> " # the actual content of your prompt
ps_suffix = "\n</green>➜</nc> " # after the ps_content
[extensions]
git_struct = "</cyan></cyan_re> </unit></cyan> " # structure of the integration
package_struct = "</white></white_re> v</unit></white> " # structure of the integration
The prompt itself can be changed modifying the ps_content
and ps_suffix
variables. Apart from giving your prompt different colors using the tags, you can also modify the information displayed using the following built-in Bash options:
Opts | Description |
---|---|
\a |
A bell character |
\d |
Date (day/month/date) |
\D{format} |
Date but following the system's time format |
\e |
Escape character |
\h |
Hostname (short) |
\H |
Full hostname (domain name) |
\j |
Number of jobs being managed by the shell |
\l |
The basename of the shells terminal device |
\n |
New line |
\r |
Carriage return |
\s |
The name of the shell |
\t |
Time (hour:minute:second) |
\@ |
Time, 12-hour AM/PM |
\A |
Time, 24-hour, without seconds |
\u |
Current username |
\v |
BASH version |
\V |
Extra information about the BASH version |
\w |
Current working directory |
\W |
The basename of the working directory |
\! |
Lists this command’s number in the history |
\# |
This command’s command number |
\$ |
Specifies whether the user is root (#) or otherwise ($) |
\\ |
Backslash |
\[ |
Start a sequence of non-displayed characters |
\] |
Close or end a sequence of non-displayed characters |
Structs define the structure of the extensions. You can use tags to customize the structs further. However, there is an additional tag called </unit>
, which is the output of the extension. Say you are using the git extension:
git_struct = "</cyan> </unit> "
This will display:
dev
Because </unit>
, in this case, displays the current working branch.
Tag | Description |
---|---|
</gray> |
Makes text following it gray |
</red> |
Makes text following it red |
</green> |
Makes text following it green |
</blue> |
Makes text following it blue |
</cyan> |
Makes text following it cyan |
</yellow> |
Makes text following it yellow |
</magenta> |
Makes text following it magenta |
</white> |
Makes text following it white |
</nc> |
Removes the color of text following it |
You can also give some properties to the colors by using modifiers and appending them at the end of the color (e.g. <green_br>
):
Modifier | Description |
---|---|
_br |
bright |
_dm |
dim |
_it |
italic |
_un |
underlined |
_bl |
blinking |
_re |
inverted |
On the previous step we created the alias mp
, which we will be using to run commands for MiniPrompt. Use mp --help
to see the available commands. Here is a quick example enabling the Git extension:
$ mp git enable
# you can shorten it as: mp gt e
After changing the config file you can reload the prompt using the same alias, but without any flags:
$ mp
Extension | Dependencies |
---|---|
Git | git |
SSH | openssh |
Package | npm |
Wifi | nmcli |
IP | ip |
-
Q: "If I don't have a config file, will MiniPrompt create one for me?"
-
A: No, settings will simply be assumed from default values.
-
Q: "Why does the alias created for the prompt needs to be sourced?"
-
A: Because you can't export env vars from a shell script unless it's sourced, so this is the best solution.
MiniPrompt is released under the GPL v3.0 license. It grants open-source permissions for users including:
- The right to download and run the software freely
- The right to make changes to the software as desired
- The right to redistribute copies of the software
- The right to modify and distribute copies of new versions of the software
For more convoluted language, see the LICENSE file.
High Priority:
- Publish to the AUR?
Low Priority:
- None
Enjoy!