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

use case: scroll up to the start of the command that was just executed or is currently still running #227

Closed
andrewrk opened this issue Aug 6, 2023 · 4 comments · Fixed by #229

Comments

@andrewrk
Copy link
Collaborator

andrewrk commented Aug 6, 2023

My status quo terminal is xfce4-terminal, which is not amazing but it gets the job done. One task that I need to do on a regular basis is go up to the previous command that I just ran, potentially after a lot of output scrolled by. With xfce4-terminal, there are two options for this:

  • shift+page up, shift+page down to quickly scroll the gui scroll bar up and down. I believe this is a pretty common keyboard shortcut amongst terminals that doesn't seem to be supported by ghostty. Although, I just took a peek at kitty and discovered that it does not support this shortcut.
  • ctrl+f to bring up the find window, type in my $PS1, enter, enter, escape.

image

I find both of these to be unsatisfactory, but that is what I currently resort to. Unfortunately, the situation with ghostty is even worse unless there is a feature I am unaware of.

So this issue is in hope of this use case being recognized as desirable to solve directly: I'd like there to be a quick way in the GUI to scroll the terminal to the previous command, ideally with a minimal number of keystrokes.

After arriving at the previous command, I'd like to be able to scroll down while reading the text.

@mitchellh
Copy link
Contributor

Ghostty supports this already but doesn’t bind the key on Linux by default. If there is a typical building I’ll add the default. The binding action: https://github.com/mitchellh/ghostty/blob/main/src/input/Binding.zig#L175

You can set it in your config like this:

keybind = shift+page_up=jump_to_scroll:-1

The numeric value is the number of prompts to jump backwards (negative) or forward (positive).

Looking at the source now I think I didn’t implement int parsing for this so that’s a bug that will block you.

Note this feature requires shell integration and on Linux this is not automatic (in Mac it is automatic). You’ll have to look at the “shell-integration” folder in src and copy that into your dotfiles. I will automate this soon for Linux.

As far as search goes: we’re tracking that here in #189 and I’m actually working on that now.

@mitchellh
Copy link
Contributor

Marked as bug so I can implement the int parameter parsing for this action.

@andrewrk
Copy link
Collaborator Author

andrewrk commented Aug 6, 2023

Thanks for the tips!

@mitchellh
Copy link
Contributor

mitchellh commented Aug 6, 2023

Big improvements for you in #229. The PR message is relevant:

This has three major changes to improve shell integration functionality on Linux.

You can now set the jump_to_prompt binding (on all platforms) to jump back/forward between prompts. You can change this binding by setting keybind = shift+whatever=jump_to_prompt:-1 where -1 is the amount to jump (negative is back).

On macOS, this was always automatically bound to Cmd+Shift+Up/Down. On Linux, this is now set to Shift+Page-Up/Down. The Linux binding is new in this PR.

This feature requires shell integration and shell integration on Linux is now easier (its automatic on macOS). On Linux, you can now set the GHOSTTY_RESOURCES_DIR env var to point to the zig-out/share directory from building Ghostty. Ghostty will detect this and set the proper terminfo and shell integration configs for fish and zsh.

So, the action you want is to set the GHOSTTY_RESOURCES_DIR env var as described in the PR. This will set you up with automatic shell integration assuming you're using zsh or fish. This will enable semantic prompts which now have keybindings by default on Linux. I also updated the README (see PR) for details on how to verify its all working.

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