Skip to main content

The bar theme for xonsh shell.

Project description

The bar prompt for the xonsh shell with customizable sections.

[Demo] Screenshot made in Konsole with $XONSH_COLOR_STYLE = "paraiso-dark".

If you like the idea of bar theme click ⭐ on the repo and stay tuned.

Features:

  • Zero dependencies. You don't need to install additional packages.

  • Clear concept. The bar is a delimiter and information panel. Three attention aspects: command line and path, output, sections with additional info.

  • The command beginning has fixed position to have a large command line every time and avoid mess of attention.

  • The sections placed to right but not in the same line as command and it allows you to copy the command and output without environmental disclosure.

  • Full customization. Change colors, add sections with info you need easily with Python.

Install

xpip install -U xontrib-prompt-bar
echo 'xontrib load prompt_bar' >> ~/.xonshrc
# Reload xonsh

Use cases

Fields and colors

The bar theme supports fields:

To customize the appearance of the fields on the bar you can use wrappers:

  • {hostname} - no wrapper
  • {hostname#section} - add backlight for the text
  • {hostname#accent} - bold font and lighter color
  • Also you can create your own fields and wrapper. See the section below.

Add custom fields and wrappers

How to add two new fields called my_left_custom and my_right_custom and one new wrapper called brackets.

$PROMPT_FIELDS['my_left_custom'] = 'Hello left!'
$PROMPT_FIELDS['my_right_custom'] = lambda: '>'*3 + ' {YELLOW}Hello right!'

$XONTRIB_PROMPT_BAR_WRAPPERS = {
    'brackets': lambda v: f'[{v}]'
}

$XONTRIB_PROMPT_BAR_LEFT = '{hostname}{user}{pwd#accent}{my_left_custom#brackets}'
$XONTRIB_PROMPT_BAR_RIGHT = '{my_right_custom#section}{env_name#section}{gitstatus_noc#section}{date_time_tz}'

xontrib load prompt_bar

Result:

[Demo custom fields]

Using Starship cross-shell prompt for rendering sections

Manual calling example:

# First of all create a starship config to return sections in one line
$STARSHIP_CONFIG = '~/.config/starship_right_sections.toml' 
$PROMPT_FIELDS['starship'] = lambda: __xonsh__.subproc_captured_stdout(['starship', 'prompt']).replace('\n', ' ').strip()
$XONTRIB_PROMPT_BAR_RIGHT = '{starship}'
xontrib load prompt_bar

Or for more complete support you can use xontrib-prompt-starship:

# First of all create a starship config to return sections in one line
$XONTRIB_PROMPT_STARSHIP_RIGHT_CONFIG = "~/.config/starship_xonsh_right.toml"
$XONTRIB_PROMPT_STARSHIP_REPLACE_PROMPT = False
xontrib load prompt_starship
$XONTRIB_PROMPT_BAR_RIGHT = '{starship_right}'
xontrib load prompt_bar

Additional links

Known issues

Spaces in the copied and pasted command line

Please update prompt_toolkit to 3.0.7+ version via pip install -U prompt_toolkit.

Credits

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xontrib-prompt-bar-0.2.8.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

xontrib_prompt_bar-0.2.8-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file xontrib-prompt-bar-0.2.8.tar.gz.

File metadata

  • Download URL: xontrib-prompt-bar-0.2.8.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for xontrib-prompt-bar-0.2.8.tar.gz
Algorithm Hash digest
SHA256 93189a04d3729137ce57728f4183891a9780332cb8f94439a33e8c5ccb5302c5
MD5 6869166f9fcfd459e25dfec8a12904aa
BLAKE2b-256 2bfdf81dfc3f5d3c3ac4b5e952c950f1f198ac90fc024798c65d9d22daa63ad7

See more details on using hashes here.

File details

Details for the file xontrib_prompt_bar-0.2.8-py3-none-any.whl.

File metadata

  • Download URL: xontrib_prompt_bar-0.2.8-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for xontrib_prompt_bar-0.2.8-py3-none-any.whl
Algorithm Hash digest
SHA256 3c250616905767a3ec3ccc2abfd6cd5161f341e4e99804b075efa6c05f01c9cf
MD5 7f163bde71b44f7489c8999a00d63944
BLAKE2b-256 086306662ace1c2bab2c28797b64217ddfef3e7c309cbff03791aa514faf2e66

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page