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

The bar theme supports fields:

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

$XONTRIB_PROMPT_BAR_RIGHT = '{hostname#accent#section}'
xontrib load prompt_bar

Available wrappers:

  • section - add backlight for the text
  • accent - bold font and lighter color
  • noesc - remove ANSI escape characters (colors)
  • strip - remove white spaces in the begin and end
  • nonl - replace new line symbols to spaces
  • nocolorx - remove xonsh color tags i.e. {RED} or {#00ff00}
  • 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}{cwd_abs#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]

Theme and colors

To change bar colors there is setting the theme:

$XONTRIB_PROMPT_BAR_THEME = {
    'left': '{hostname}{user}{cwd_abs#accent}',
    'right': '{env_name#section}{gitstatus_noc#section}{date_time_tz}',
    'bar_bg': '{BACKGROUND_#FF0000}',
    'bar_fg': '{#AAA}',
    'section_bg': '{BACKGROUND_#444}',
    'section_fg': '{#CCC}',
    'accent_fg': '{BOLD_#DDD}',
}
xontrib load prompt_bar

Using Starship cross-shell prompt to rendering right sections

Barship using 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_PROMPT_BAR_RIGHT = '{starship_right#noesc#nonl#strip}'
xontrib load prompt_starship prompt_bar

Result:

Prompt bar with starship sections.

Additional links

Known issues

Spaces in the copied and pasted command line

Please update prompt_toolkit to 3.0.7+ version via python -m 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.3.4.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

xontrib_prompt_bar-0.3.4-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: xontrib-prompt-bar-0.3.4.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for xontrib-prompt-bar-0.3.4.tar.gz
Algorithm Hash digest
SHA256 7185feac175bbeb3dececcc1631e1bedfbcc59e2cf75338a26eca9805b13c399
MD5 cebaae776977809149efbd62de658a28
BLAKE2b-256 5881175f020b8685f088c3c24995803bda3c7355dc63e45201b4774b6aed6b34

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xontrib_prompt_bar-0.3.4-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for xontrib_prompt_bar-0.3.4-py3-none-any.whl
Algorithm Hash digest
SHA256 f6d717547d93da939c727282d029f241f332606638c6a27e0439bfdaad2af4da
MD5 139a72e6bbc37e990cd476a740e2a074
BLAKE2b-256 d62545dffc4bd1d0f98694c504d96a74437c591c9d8bb2154dc65d19edd171f7

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