Prompto is dedicated to build your prompt the way you want it based on a simple and readable yaml file
You can clone the repository and then build prompto:
$ go build -o prompto cmd/prompto/prompto.go
Prompto takes its configuration file as parameter:
$ prompto $HOME/.prompto.yaml
Somewhere in your $HOME/.bashrc
(or any file your .barshrc
loads), write the following functions:
function _update_ps1(){
PS1="$(export STATUS=$?; /path/to/prompto /path/to/your/.prompto.yaml)"
}
if [ "$TERM" != "linux" ]; then
PROMPT_COMMAND="_update_ps1;$PROMPT_COMMAND"
fi
Take care of changing the path to the Prompto binary and to your configuration file.
The configuration file repeats the same pattern for each component:
prompters:
- kind: hostname
before: " | "
after: " "
bgcolor: blue
fgcolor: default
font: bold
side: left
- kind: text
content: ""
bgcolor: light-blue
fgcolor: blue
side: left
The yaml file describes a set of prompters composing your final prompt. Each prompter has a least the following configuration item:
kind
: the definition of the behavior.font
: the font to use. Available keywords depends on your terminal.bgcolor
/fgcolor
: the background/foreground color, accepting 8bits color code or equivalent name.before
/after
: any content to be put before/after the expected behavior.side
: the side of the screen to put the final content (left if not set).
Each prompter is set up in the order the appear, being "pushed" on the appropriate side as they are defined.
Defined behaviours:
username
: your usernamehostname
: the hostname of your computertext
: plain text you want to set up. It adds acontent
configuration item andbefore
/after
are deactivatedpath
: the current path. You can set up theseparator
to be used, and the displaymode
(default
,short
,elided
,initial
).newline
: put a newline to have multiple lines in your prompt. Prompters configured after will appear on a new line.ifgit
: content to be displayed if in a git repository (same configuration astext
).ifnotgit
: content to be displayed if not in a git repository (same configuration astext
).textifenv
: content to be displayed if a specific environment variable (env
) is displayed (same configuration astext
).gitrepo
: repository name (basename of the current git root)gitbranch
: branch name if in a git repository.gittag
: tag name if in a git repository. If no tag is defined,before
andafter
are not displayedcommand
: the result of the execution of acommand
(without leading/trailing spaces/newline). If thetimeout
(in ms) is reached, it prints "TIMEOUT". If any error happens, the error is explicitely printed.
The configuration file config/prompto-00.yaml
results in the following prompt: