0.1.2 • Published 2 years ago

miniprompt.sh v0.1.2

Weekly downloads
-
License
GPL-3.0
Repository
github
Last release
2 years ago

About

🎁 Features

  • 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
  • Extensions can be toggled on and off on the fly

🤖 Usage

📦 Installation

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

$ npm install --global miniprompt.sh

If it throws an error then run the command with sudo

Manual

$ git clone git@github.com: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"

AUR

👷🛑 Under dev

🔧 Setup

Two things:

  1. Enable the prompt in your ~/.bashrc
  2. 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

Customizing!

Prompt

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:

OptsDescription
\aA bell character
\dDate (day/month/date)
\D{format}Date but following the system's time format
\eEscape character
\hHostname (short)
\HFull hostname (domain name)
\jNumber of jobs being managed by the shell
\lThe basename of the shells terminal device
\nNew line
\rCarriage return
\sThe name of the shell
\tTime (hour:minute:second)
\@Time, 12-hour AM/PM
\ATime, 24-hour, without seconds
\uCurrent username
\vBASH version
\VExtra information about the BASH version
\wCurrent working directory
\WThe 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

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.

Tags
TagDescription
</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>):

ModifierDescription
_brbright
_dmdim
_ititalic
_ununderlined
_blblinking
_reinverted

🌿 Utilization

On the fly commands

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

Reloading the prompt

After changing the config file you can reload the prompt using the same alias, but without any flags:

$ mp

Dependencies for extensions

ExtensionDependencies
Gitgit
SSHopenssh
Packagenpm
Wifinmcli
IPip

🙋 FAQ

  • 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.

📜 License

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.

📋 TO-DO

High Priority:

  • Publish to the AUR?

Low Priority:

  • None