Giter Site home page Giter Site logo

Comments (4)

anki-code avatar anki-code commented on May 12, 2024

Try to cut empty line here:

return __xonsh__.subproc_captured_stdout([
'starship', 'prompt',
'--status', str(int( __xonsh__.history[-1].rtn)) if len(__xonsh__.history) > 0 else '0',
'--cmd-duration' , str(int((__xonsh__.history[-1].ts[1] - __xonsh__.history[-1].ts[0])*1000)) if len(__xonsh__.history) > 0 else '0',
'--jobs', str(len(__xonsh__.all_jobs))
])

i.e. "Using starship cross-shell prompt to rendering right sections" in xontrib-prompt-bar

from xontrib-prompt-starship.

StanSvec avatar StanSvec commented on May 12, 2024

Oh so simple, thanks!
I came up with a naive solution:

_FIRST_PROMPT = True

def _starship_prompt(cfg=None):
    global _FIRST_PROMPT
    with __xonsh__.env.swap({'STARSHIP_CONFIG': cfg} if cfg else {}):
        prompt = __xonsh__.subproc_captured_stdout([
            'starship', 'prompt',
            '--status', str(int( __xonsh__.history[-1].rtn)) if len(__xonsh__.history) > 0 else '0',
            '--cmd-duration' , str(int((__xonsh__.history[-1].ts[1] - __xonsh__.history[-1].ts[0])*1000)) if len(__xonsh__.history) > 0 else '0',
            '--jobs', str(len(__xonsh__.all_jobs))
        ])
    if _FIRST_PROMPT:
        _FIRST_PROMPT = False
        return prompt.lstrip()
    return prompt

Works fine unless the screen is cleared (Ctrl + L). Is there a way how to detect execution of the clear command, so I could add one more condition for the left strip?
Thanks!

from xontrib-prompt-starship.

anki-code avatar anki-code commented on May 12, 2024

I think you're using prompt toolkit for $SHELL and the first way is to search there.

from xontrib-prompt-starship.

StanSvec avatar StanSvec commented on May 12, 2024

Hmm, I didn't even know that prompt toolkit provides shell functionality, because I don't have any experience with this library. Is it possible to access ptk's API somehow from the prompt_starship.py file please?

from xontrib-prompt-starship.

Related Issues (7)

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.