[Feature Request] Vim-like Navigation in Scrollback & Option to Open Output in a New Tab #3708
Replies: 7 comments 10 replies
-
I'm not sure it even needs to open into a new tab. In reality if the current tab/panel/window turned into an editor. That could config easily with $EDITOR. If it turned into an editor with no line numbers and no active indicators. You wouldn't know the difference of it going into a copy mode. It's in theory, the same as going into a copy mode. On something like tmux or screen. Allowing you to move around and copy what you need. Which allows for your own person customization per editor. But having a default to something like vi or nano over TextEditor. Where it stays in the same terminal surface it's called on. Cause popping up a completely new window isn't a nice flow for someone who wants to stay in the terminal. You can currently do this with |
Beta Was this translation helpful? Give feedback.
-
I agree with you, @ScriptAlchemist, that it is one step to many to have to switch to a new window or tab. The ideal solution, as you rightly say, would be to use the same terminal surface and have the niceties of a fully featured editor of choice inside it, although I don't know how complex that would be to implement. From what I was told, the main challenge is that Ghostty currently avoids "stealing" input from the shell like Alacritty and WezTerm does to implement this feature. Implementing this feature similarly would probably require hooking specific keybindings in a scrollback context and something tells me that it is not ideal. One possible approach might be to integrate a lightweight "scrollback editor" that runs inside the same Ghostty surface or open the scrollback in a TUI-based editor but reuse the same Ghostty instance instead of launching an entirely new window. But, I know too little to know if any of this is technically possible. And, I agree with you that any solution should remain optional and customizable so users who prefer default keybindings or rely on shell vi modes are not disrupted. |
Beta Was this translation helpful? Give feedback.
-
For example. I just put a solution into my .bashrc and now I probably won't think about this until the update for now my solution to add to to a .bashrc for the time being. but it runs the commands and adds it directly into the terminal input and presses enter for me. Which just opens up my vi instance with the returned path from ghostty. Which activates with ctrl + a + [ like my tmux would move to copy mode. run_vi_with_filepath() {
osascript -e 'tell application "System Events" to keystroke "vi + "'
osascript -e 'tell application "System Events" to keystroke "j" using {command down, option down, shift down}' # keybind = super+alt+shift+j=write_screen_file:paste
osascript -e 'tell application "System Events" to key code 36' # Key code 36 is 'Enter' on macOS
}
bind -x '"\C-a[":run_vi_with_filepath'
I updated this with a commend on what keybinding to add to the ghostty config. To make the keybinding use the write_screen_file because it seems to be working better than the scroll history command at the moment. |
Beta Was this translation helpful? Give feedback.
-
I think that the “best of both worlds” would be to just have both options available. While opening the scrollback in an editor can be nice, I've found that editors aren't great at dealing with files with 100k+ lines (which I often get to when compiling stuff), in which case having a built-in modal keyboard-oriented scrollback navigation and selection mode would be nice. This would also combo well with #189, by allowing searching within the navigation mode. |
Beta Was this translation helpful? Give feedback.
-
I would really love to see this added to ghostty. Vim movements in the terminal is the main reason I switched to Alacritty. |
Beta Was this translation helpful? Give feedback.
-
Related: #3488. |
Beta Was this translation helpful? Give feedback.
-
I'm just opening a full screen nvim builtin terminal for now to move around freely, you can hardly see the difference tbh... |
Beta Was this translation helpful? Give feedback.
-
In terminals like Alacritty and WezTerm, you can freely navigate the visible text, make selections, and copy/paste using standard Vim keybindings (e.g.,
j
,k
,v
,y
,p
, etc.).Currently, Ghostty does not offer this. However, users can use
write_scrollback_file:open
orwrite_screen_file:open
to open the scrollback in an external editor. While this is less convenient, it provides access to a fully featured editor, complete with navigation features like line numbers, etc.Proposed Solution
Getting the best of both approaches might be challenging. Still, one potential improvement could be allowing the user to open the temporary file in a new tab within Ghostty (via configuration). This could combine some of the benefits of both methods in a user-friendly way that does not create unnecessary technical complexity early in the Ghostty project.
Beta Was this translation helpful? Give feedback.
All reactions