oils-for-unix / oils

Oils is our upgrade path from bash to a better language and runtime. It's also for Python and JavaScript users who avoid shell!
http://www.oilshell.org/
Other
2.85k stars 159 forks source link

allow any custom prompts #1996

Closed dezren39 closed 5 months ago

dezren39 commented 5 months ago

can ysh support any custom user-provided prompts? i guess a script that runs on each new execution that could possibly include an external binary? eventually would want to be able to make starship work with ysh but first just wondering if i wanted my prompt to run a small script or just be whatever value i want is that possible?

i realized with the starship bug post you mentioned that starship probably works with osh? i can't quite get it to work but i'll play with it a bit. i'm specifically curious about improving the prompt for use with ysh. i'm looking to daily drive ysh.

i did see #1809 but that didn't seem like something one could use directly or customize, or maybe it is? it sounded like something straightforward to implement into the shell

dezren39 commented 5 months ago

https://github.com/oilshell/oil/blob/master/doc/ref/chap-plugin.md#renderprompt i found this, what i didn't quite understand was that i need to define the renderprompt myself and then i can use it. i'll try that out thanks

< io->promptVal('$') ; return ('hi') }
hi

still not 100% clear what it means to call io->promptVal, or what $ vs # does in promptVal. functions say they are pure but then i saw somewhere they are the same as proc?

<e | cowsay | lolcat ; return ('hi') }
/home/user
auth     charm   code  Desktop    Downloads  go.work1     Music     promptVal  Templates
bw.auth  charm2  data  Documents  go         go.work.sum  Pictures  Public     Videos
 ______________________________________
/ By trying, we can easily learn to    \
| endure adversity -- another man's, I |
| mean.                                |
|                                      |
\ -- Mark Twain                        /
 --------------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
hi
dezren39 commented 5 months ago

closing this because answered my own question. still confused by the arg to prompval and i guess functions can call external things?