MrPicklePinosaur / shrs

The rusty shell toolkit for hackers
https://mrpicklepinosaur.github.io/shrs/
Apache License 2.0
301 stars 24 forks source link

[Feature]: windows native (not WSL support) #316

Open trajano opened 8 months ago

trajano commented 8 months ago

What would you like to see added?

I am thinking of tinkering with this, but I was wondering if the core part is executable in Windows natively? I'm not looking for a full POSIX compliance, but just enough for a usable shell that is more or less bash compatible

re: https://github.com/fish-shell/fish-shell/discussions/10123#discussioncomment-7938904

My imagination is something along the lines of

  1. use SQLite to manage the history so it can span across shell instances.
  2. simplified aliae
    • removal of aliases and just use functions al-throughout
  3. have a richer set of controls that can be leveraged by the most complicated oh-my-posh theme
    • right-side prompts
    • "ghost" prompts (not sure what those are called actually, but those that appear left behind)
  4. terminal capability detection
    • handle resolution change events
    • provide capability checks to see whether double-width fonts
    • somehow ... pass the font name to the environment variables.
  5. by default disable flow control and other multi-key constructs
  6. use Windows shortcuts if the TTY is detected to be Windows and such supports the full keyboard without ESC
    • Ctrl Left Right to change words
    • ESC to clear line
    • Pause (not Ctrl-S) to pause the terminal
    • Ctrl-Z still suspends
    • Ctrl-L still clears the screen, but starts a new prompt
    • Ctrl-End clears to the end of the line
    • Ctrl-Del deletes the word
    • End goes to the end of the line
    • Home goes to the beginning of the line
  7. use Mac shortcuts when the TTY is detected to be macOS (although I don't know much of the for shortcuts for MacOS, but assuming they had a proper keyboard (not a macbook one) then I think it would have similar shortcuts as Windows.
  8. history UI
    • up starts line history mode. (it's not the same as readline mode which sort of does weird things like if you change the text on one go up and down it retains it)
    • basically only append (no update)
    • special hook for oh-my-posh to display history
    • Typing then pressing up will search for the history for the entry
    • page up brings up the history as a popup window that allows searches
  9. command completion API that is bash compatible at minimum, but allows for more possibilities from there.
  10. ncurses based API to render some widgets like
    • command completions
    • history
MrPicklePinosaur commented 8 months ago

Thanks for the detailed issue! Currently not much cross platform support is taken into consideration during development since we are very much so prototyping and rapidly iterating on features. It is definitely worth taking other platforms into consideration though, to ease porting in the future. Since the shell process management use the standard library std::process the shell language itself should hopefully be quite portable. The one issue however is that a lot of the shell assume a unix like directory structure, so having some platform dependent code there might be useful.

A lot of the ideas that you brought up are quite interesting, especially tui based rendering (like ncurses), which I have being toying with for a bit. I can definitely make a couple of issues addressing some of your ideas!

Rodrigodd commented 2 months ago

I read the first point about the SQL database, got intrigued, and found this project: https://github.com/atuinsh/atuin. I didn't test it or anything, just putting it here as it appears to be relevant for this issue, and is also written in Rust.

MrPicklePinosaur commented 2 months ago

@Rodrigodd this may of be interest to you https://github.com/MrPicklePinosaur/shrs/issues/346 :)

atuin support will probably make the most sense as a third party plugin, if anyone is up to the task of implementing it