Giter Site home page Giter Site logo

xontrib-prompt-starship's Introduction

Starship cross-shell prompt in xonsh shell.

If you like the idea click ⭐ on the repo and tweet.

Additional features:

  • You can split the prompt to left, right and bottom parts.

Installation

To install use pip:

# You already have Starship installed. Then:
xpip install xontrib-prompt-starship
# or: xpip install -U git+https://github.com/anki-code/xontrib-prompt-starship

Usage

xontrib load prompt_starship

Recommendation

We suggest to use @ character to remember about you're using xonsh syntax and to potentially spread the word about xonsh if you make a screenshot or show your terminal to friends or collegues:

mkdir -p ~/.config/ && echo @("""
[character]
success_symbol = "[@](bold green)"
error_symbol = "[@](bold red)"
""".strip()) > ~/.config/starship_xonsh.toml

$STARSHIP_CONFIG = '~/.config/starship_xonsh.toml'
xontrib load prompt_starship

Configuration

You can set the different starship configs for left, right and bottom parts of prompt when your shell type is prompt-toolkit:

$XONTRIB_PROMPT_STARSHIP_LEFT_CONFIG = "~/.config/starship_xonsh_left.toml"
$XONTRIB_PROMPT_STARSHIP_RIGHT_CONFIG = "~/.config/starship_xonsh_right.toml"
$XONTRIB_PROMPT_STARSHIP_BOTTOM_CONFIG = "~/.config/starship_xonsh_bottom.toml"
xontrib load prompt_starship

In case of using starship as part of another prompt you can add starship prompt to $PROMPT_FIELDS without replacing the current prompt:

$XONTRIB_PROMPT_STARSHIP_REPLACE_PROMPT = False
xontrib load prompt_starship
print($PROMPT_FIELDS['starship_left']())

Prompt bar with starship:

Prompt bar with starship sections.

Known issues

Credits

xontrib-prompt-starship's People

Contributors

anki-code avatar cycomanic avatar eugenesvk avatar ofek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

xontrib-prompt-starship's Issues

multi-line prompt not taking up full terminal

I'm using a multi-line prompt in starship which works correctly in fish, however only takes up a fraction of the terminal size in xonsh.

Starship example setup

format = """
AA$fill\
$time\
$line_break\
$character
"""

[fill]
symbol = "."

[time]
disabled = false
style = "bold bright-black"
format = "[$time]($style)"

in fish this looks like this:

+-----------------------------------------------------------------------------------------------------------------------------------------------+
|AA........................................................................................................................................................11:45:31|
|❯

if I use the same in xonsh with xontrib-prompt-starship:

+-----------------------------------------------------------------------------------------------------------------------------------------------+
|AA......................................................................11:45:36 |
|❯

Note the prompt only fills up half the terminal window. I get similar behavior if I create a right prompt, which is also not aligned to the right of the terminal. If I use xontrib-prompt-bar I get the same issue, however if I specify #noesc it fixes the issue (however I loose the color in my prompt).

$STARSHIP_SESSION_KEY

I am not running this xontrib but I have starship running in xonsh

I needed to also set STARSHIP_SESSION_KEY

This is to give different logs for each terminal

In me .xonshrc I have

$STARSHIP_SESSION_KEY = $(starship session)

The default prompt arrow does not reflect the vi mode

In other shells (at least, in fish), when you activate vi mode, the starship prompt arrow reverses direction to indicate the difference between "insert" mode vs "command" mode. This does not appear to be working with the starship/xonsh integration.

Fails to format prompt when xonsh running from outside shell

i530566@C17ZL21PMD6M ~ $ xpip install xontrib-prompt-starship
Collecting xontrib-prompt-starship
  Using cached xontrib_prompt_starship-0.0.2-py3-none-any.whl (2.8 kB)
Requirement already satisfied: xonsh in ./.pyenv/versions/3.8.7/lib/python3.8/site-packages (from xontrib-prompt-starship) (0.9.27)
Installing collected packages: xontrib-prompt-starship
Successfully installed xontrib-prompt-starship-0.0.2
i530566@C17ZL21PMD6M ~ $ xontrib load prompt_starship
Failed to format prompt `<function <lambda> at 0x10469f9d0>`-> <class 'ValueError'>:expected '}' before end of string

%{%}~%{%} via %{%}🐍 %{%}%{%}%{%}%{%}v3.8.7%{%}%{%} %{%}
%{%}❯%{%}
%{%}❯%{%} xonfig
+------------------+----------------------+
| xonsh            | 0.9.27               |
| Git SHA          | 71fe9014             |
| Commit Date      | Jan 29 08:58:58 2021 |
| Python           | 3.8.7                |
| PLY              | 3.11                 |
| have readline    | True                 |
| prompt toolkit   | 3.0.16               |
| shell type       | prompt_toolkit       |
| pygments         | 2.8.0                |
| on posix         | True                 |
| on linux         | False                |
| on darwin        | True                 |
| on windows       | False                |
| on cygwin        | False                |
| on msys2         | False                |
| is superuser     | False                |
| default encoding | utf-8                |
| xonsh encoding   | utf-8                |
| encoding errors  | surrogateescape      |
| on jupyter       | False                |
| jupyter kernel   | None                 |
| xontrib 1        | abbrevs              |
| xontrib 2        | argcomplete          |
| xontrib 3        | autovox              |
| xontrib 4        | autoxsh              |
| xontrib 5        | avox                 |
| xontrib 6        | avox_poetry          |
| xontrib 7        | back2dir             |
| xontrib 8        | cmd_done             |
| xontrib 9        | commands             |
| xontrib 10       | coreutils            |
| xontrib 11       | direnv               |
| xontrib 12       | docker_tabcomplete   |
| xontrib 13       | fzf-widgets          |
| xontrib 14       | gitinfo              |
| xontrib 15       | histcpy              |
| xontrib 16       | prompt_starship      |
| xontrib 17       | sh                   |
| xontrib 18       | vox                  |
| xontrib 19       | voxapi               |
| xontrib 20       | z                    |
+------------------+----------------------+

Set `$STARSHIP_SHELL = "xonsh"` instead of "sh"

Xonsh is supported natively in starship now (see /usr/local/bin/starship init xonsh --print-full-init), and each supported shell sets the $STARSHIP_SHELL variable to the running shell. This project just defaults that variable to "sh", which is not ideal. It means that adding custom sections to the starship.toml file for different shells can't simply check this variable is "xonsh" as a conditional.

This issue is a proposal to change this line to use 'xonsh' instead of 'sh':

__xonsh__.env['STARSHIP_SHELL'] = 'sh' # Fix https://github.com/anki-code/xontrib-prompt-starship/issues/1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.