Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows Support #135

Closed
iquiw opened this issue May 17, 2021 · 8 comments
Closed

Windows Support #135

iquiw opened this issue May 17, 2021 · 8 comments

Comments

@iquiw
Copy link

iquiw commented May 17, 2021

First of all, Atuin solved annoyances of bash history for me. Thank you so much!

Slightly related to #84, but I want to use Atuin with MSYS2 bash on Windows.

I tried to build Atuin with the following changes and it works fine on Windows Terminal.

Unfortunately, it is not clear when/whether the MR is merged.
I think another option is to switch crossterm which already supports Windows. But it requires some code changes.

@ellie
Copy link
Member

ellie commented May 18, 2021

First of all, Atuin solved annoyances of bash history for me. Thank you so much!

Glad you like it! 😊

Sure, I don't see why we can't do this. I know it's different, but have you tried with WSL? I'm mostly interested in whether or not it works haha, I haven't yet had a chance to try.

I think wrt the termion change, I'd rather we have a go switching to crossterm. Using tui-rs we should be able to change backend, and hopefully we aren't using any/too many termion specific features so the switch could be pretty smooth.

May I ask what was up with the server + why it needed disabling?

In any case I'm totally up for supporting Windows, though I haven't worked on anything for Windows in a long time so would prefer someone make a PR 😂

Thanks for having a go at this anyway, really appreciate the work :)

@iquiw
Copy link
Author

iquiw commented May 18, 2021

Sure, I don't see why we can't do this. I know it's different, but have you tried with WSL? I'm mostly interested in whether or not it works haha, I haven't yet had a chance to try.

I'm not using WSL(2) as I'd like to work on Windows filesystem and WSL2 is known to be slow in the case.
I think there is no problem to run Atuin with WSL.

May I ask what was up with the server + why it needed disabling?

fork crate failed to be built.
And as I am not using server command right now, I just chose the fastest way to build Atuin.

In any case I'm totally up for supporting Windows, though I haven't worked on anything for Windows in a long time so would prefer someone make a PR 😂

OK, I will try crossterm and get back.

Thanks!

@iquiw
Copy link
Author

iquiw commented May 20, 2021

Trying crossterm.

I found crossterm's EnableAlternateScreen/LeaveAlternateScreen does not work well on MSYS2 bash, which seems to use Win32 API instead of ANSI escape sequence. (EDIT2: This looks also wrong.) Displayed texts are sometimes not cleared at initial screen and selected command is displayed above prompt. (EDIT: this turns out not a problem. I did atuin search -i instead of C-r)
I am checking this further...

Besides that, it seems most different part is termion::event::Key to crossterm::event::KeyEvent change.

        Key::Esc | Key::Ctrl('c') | Key::Ctrl('d') | Key::Ctrl('g') => {
            return Some(String::from(""))
        }

to be

        KeyEvent {
            code: KeyCode::Esc, ..
        }
        | KeyEvent {
            code: KeyCode::Char('c'),
            modifiers: KeyModifiers::CONTROL,
        }
        | KeyEvent {
            code: KeyCode::Char('d'),
            modifiers: KeyModifiers::CONTROL,
        }
        | KeyEvent {
            code: KeyCode::Char('g'),
            modifiers: KeyModifiers::CONTROL,
        } => return Some(String::from("")),

@iquiw
Copy link
Author

iquiw commented May 22, 2021

I found crossterm's EnableAlternateScreen/LeaveAlternateScreen does not work well on MSYS2 bash

Found it is caused by crossterm::terminal::enable_raw_mode instead.
There are several issues reported in crossterm repo related Windows (Terminal), checking them.

@iquiw
Copy link
Author

iquiw commented May 22, 2021

OK, I found what's going on.

On Windows, crossterm checks whether the environment supports ANSI escape sequences by
(1) TERM environment variable is set and not dumb.
or
(2) The console input can set ENABLE_VIRTUAL_TERMINAL_PROCESSING mode.
To execute (2) is required to make escape sequences work, but it is not executed if TERM is set.
Ref. ansi_support.rs

I won't write crossterm specific issues here any more as it is not Atuin's problem. Sorry for the noises.

@ellie
Copy link
Member

ellie commented Nov 17, 2021

I'm going to close this one for now, Windows isn't really something we can support unfortunately

@ellie ellie closed this as completed Nov 17, 2021
@iquiw
Copy link
Author

iquiw commented Nov 17, 2021

OK, thank you for the consideration.

@Magniquick
Copy link

commenting this here as this is still the first result when searching for atuin windows
I made a gh action that builds atuin on msys2 and throws out the binary as a release artifact
Needless to say, use at your own risk - this is something I cooked up within an hour or so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants