Package: xontrib-prompt-bar
The bar prompt for thexonsh shellwith customizable sections.Screenshot made inKonsolewith$XONSH_COLOR_STYLE = "paraiso-dark".If you like the idea of bar theme click ⭐ on the repo andtweet.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.Installxpipinstall-Uxontrib-prompt-barecho'xontrib load prompt_bar'>>~/.xonshrc# Reload xonshDefault theme$XONTRIB_PROMPT_BAR_THEME={'left':'{hostname}{user}{cwd_abs#accent}','right':'{hist_status#section}{curr_branch#section}{env_name#strip_brackets#section}{date_time_tz}','bar_bg':'{BACKGROUND_#323232}','bar_fg':'{#AAA}','section_bg':'{BACKGROUND_#444}','section_fg':'{#CCC}','accent_fg':'{BOLD_#DDD}',}xontribloadprompt_barUse casesCustomize the fieldsSupported fields:xonsh default fields and colors notationscreens- list of the windows that created byscreen window manageri.e.screen -S mywin.cwd_abs- current absolute path (~disabled).date_time_tz- date and time with timezone i.e.21-12-25 18:00:00-01.hist_status- showhist offif history disabled byhistory offcommand.To customize the appearance of the fields on the bar you can use wrappers and chaining them:$XONTRIB_PROMPT_BAR_RIGHT='{hostname#accent#section} {date_time_tz#nocolorx}'xontribloadprompt_barBuiltin wrappers:section- add backlight for the text.accent- bold font and lighter color.noesc- remove the ANSI escape characters (colors).strip- remove the white spaces in the begin and end.strip_brackets- remove the white spaces in the begin and end and then remove the brackets()[]{}if the text begins from brackets.nonl- replace the new line symbols to spaces.nocolorx- remove the xonsh color tags i.e.{RED}or{#00ff00}.To create your own fields and wrapper see the section below.Add custom fields and wrappersHow to add two new fields calledmy_left_customandmy_right_customand one new wrapper calledbrackets.$PROMPT_FIELDS['my_left_custom']='Hello left!'$PROMPT_FIELDS['my_right_custom']=lambda:'>'*3+'{YELLOW}Hello right!'$XONTRIB_PROMPT_BAR_WRAPPERS={'brackets':lambdav: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#strip_brackets#section}{date_time_tz}'xontribloadprompt_barResult:Themes and colorsTo change the bar colors there is setting the theme:$XONTRIB_PROMPT_BAR_THEME={'left':'{hostname}{user}{cwd_abs#accent}','right':'{curr_branch#section}{env_name#strip_brackets#section}{date_time_tz}','bar_bg':'{BACKGROUND_#FF0000}','bar_fg':'{#AAA}','section_bg':'{BACKGROUND_#444}','section_fg':'{#CCC}','accent_fg':'{BOLD_#DDD}',}xontribloadprompt_barTo choose the colors there isHTML Color Picker.UsingStarshipcross-shell prompt to rendering right sections"Barship" usingxontrib-prompt-starship:# First of all create a starship config to return sections in one linemkdir-p~/.config&&echo@("""[character]success_symbol = ""error_symbol = ""[status]symbol = """"".strip())>~/.config/starship_xonsh_right.toml# Then just add the starship bar to right$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}'xontribloadprompt_starshipprompt_barResult:Usingxontrib-cmd-durationsThexontrib-cmd-durationsis to send notification once long-running command is finished and also show the execution time. Usage example:# Add `{long_cmd_duration}` section$XONTRIB_PROMPT_BAR_RIGHT='{long_cmd_duration}{curr_branch#section}{screens#section}{env_name#strip_brackets#section}{date_time_tz}'xontribloadcmd_doneHide return code in special casesSometimes it's needed to hide the return code. In this case you can use-8888return code i.e.:aliases['cdls'] = "cd @($arg0) && @(lambda: -8888 if len(g`./*`) > 100 else 0) && ls --group-directories-first -A --color"
cdls /
# return code is 0 and `ls` command was executed and return code is not shown
cdls /usr/sbin
# return code is -8888 and `ls` command was NOT executed and return code is not shownAdditional linksAsynchronous section renderingxonsh default fields and colors notationMeaning of git status symbols(●×+⚑✓↑↓)Awesome example of rewriting the theme from Jonathan SlendersCustomization the colors in the input lineEnvironment variables$XONTRIB_PROMPT_BAR_SHOW_RETURN- show return code. DefaultTrue.Known issuesSpaces in the copied and pasted command linePlease updateprompt_toolkitto 3.0.7+ version viapython -m pip install -U prompt_toolkit.CreditsThis package is the part ofrc-awesome- awesome snippets of code for xonshrc in xonsh shell.This package is the part ofergopack- the pack of ergonomic xontribs.This package was created withxontrib cookiecutter template.