ltn100 / prompty

Prompty is a command prompt markup language.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Prompty Build Status Documentation Status Coverage Status PyPI version MIT license

Prompty is a command prompt markup language.

The language is loosely modelled on the LaTeX markup language, used for typesetting.

Here is an example of the sort of interactive command prompt that can be built using prompty:

prompty demonstration

Installation

The latest version can be installed from PyPI using pip:

sudo pip install prompty

You then need to insert a line at the end of your .bashrc file so that prompty is called from the PS1 environment variable:

prompty -b >> ~/.bashrc

Now re-source your updated .bashrc file:

source ~/.bashrc

(alternatively you can restart your shell session)

Tip: If you get an error like "bash: prompty: command not found", it is probably because you installed it locally, as a non-root user (without sudo). This is fine, but you will need to call the prompty executable from its local path:

~/.local/bin/prompty -b >> ~/.bashrc

Configuration

The configuration for prompty is defined in your ~/.local/share/prompty/prompty.cfg file:

[prompt]
prompt_file = default.prompty

The prompt_file variable specifies which prompty file is currently in use. The prompty files are located in ~/.local/share/prompty/. You can change the configuration to use one of the pre-defined ones, or write your own.

Examples

Simple example

You can define a simple .prompty file like this:

\green{\user}\space
\yellow{\hostname}\space
\blue[bold]{\workingdir}\space
\magenta[inverted]{(\repobranch )}\newline
\green[bold]{\unichar{0x27a5}}\space

And your prompt will end up looking like this:

example

A more verbose example

Here is a verbose example with comments to explain the syntax used:

% comments are allowed
% and white-space does not matter!

% first the username
\lightblue{\user}

% then an @ symbol
@

% followed by the machine name
\green{\hostname}

% if we want an actual space, we do this:
\space

% now the working directory in a nice yellow.
% lets also make it bold!
\yellow[bold]{\workingdir}
\space

% now for the VCS repository branch
(\repobranch )
\space

% and finally we have the special $ sign
% (which actually turns into a # when you're root)
\dollar\space

This prompty script will achieve the following prompt:

example

More

elite.prompty:

elite

red.prompty:

red

For a more elaborate example, see ~/.local/share/prompty/default.prompty (this is the one used for the animation at the top of this page).

Documentation

Documentation is available at readthedocs.

About

Prompty is a command prompt markup language.

License:MIT License


Languages

Language:Python 96.5%Language:TeX 2.5%Language:Makefile 1.0%