-
Notifications
You must be signed in to change notification settings - Fork 473
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
Search scrollback #189
Comments
Would be cool to fake what terminal emulator in vim does -- where you can pause the existing session CleanShot.2023-07-07.at.00.09.42.mp4 |
Looking forward to this feature - I missed it yesterday when I had a lot of output from a command and wanted to search for the word "fail". |
Kitty has a a pretty novel approach here that I've actually really enjoyed - This also lets you take advantage of the pager's features and can be tailored to a certain user's preference without minimal load on our side. |
FYI Ghostty has this too, bound to It works slightly differently than Kitty in that it puts the temp file path to the captured scrollback on the command line rather than opening it in a pager directly. |
Once we have search, searching via regex would be really nice to have. I've been finding myself search for |
One nice thing about Kitty's implementation is you can even use it as a program is actively running and potentially still outputting text; new text doesn't automatically get fed into your pager but you don't need to wait until a command finishes to use the pager functionality. I'm not immediately sure if that would be equivalent in behavior to
|
I'm used to screen/tmux behavior here: ctrl-A,[ puts you into 'scrollback mode' where you can then use the keyboard (vi-keys) to scroll up and down, and then even hilight some text and put it into a clipboard where you can then paste it with ctrl-A,]. I don't think it updates the buffer while scrolling, though... but I don't see why it couldn't just extend it downward. |
Personally I'd rather this stuck to OS-native conventions for search functionality as well as look and feel. I don't think implementation-specific idiosyncrasies are a good idea since a lot of folks will have differing preferences and expectations. The implementation along the lines of what's provided by Terminal.app or iTerm would be fine since that easily lets you search the scrollback buffer in a way that doesn't affect any additional output. |
@qwerasd205 Are you working on this now? I'd be happy to help out on the macOS UI front. (I mentioned this in Discord but just surfacing it here too since I rarely check over there.) |
I am working on laying some groundwork for this with a basic implementation of the search functionality - focused mainly on proper threading for the search and creating a good interface for the UI code to talk to with minimal coupling, so that in the future we can improve the performance of the search (if necessary) by changing the algorithm and/or data structures used for the searching. I'll open a draft PR once I've got the first "technically functioning" version of the code. Right now it's in too early of a state to really create UI for. |
Personally, "native" in a terminal means "vi-like" to me :) I also think kitty's approach is pretty flexible and can probably be used along side a more classic But why I actually wanted to comment is related to generic search, but a bit more specific: sometimes you actually see what you need on screen, but want to quickly copy/paste/execute it without a mouse. Back when I was using kitty I used hints a lot, and in tmux I use tmux-butler. Behind the scenes these use cases could be regex-searches constrained to the currently visible text, although obviously the UI would be quite different. Imho especially quickly opening links in the browser and copying paths to the prompt without a mouse is really useful. |
I wanted to file a feature request for something like Kitty Hints like @ferdinandyb mentioned. However, after a bit of searching, I figured this issue is a prerequisite for such a hinting system. |
Re:
Mitchell confirmed on Discord that this issue isn't a prerequisite for a "hints" feature - so I've gone ahead and created a separate issue to specifically discuss that feature request: |
I got sidetracked from this shortly after starting work on it, but to summarize the architecture I landed on for the search thread: Search ThreadData
Messages
Whenever the surface is notified of new search results, it updates its display accordingly, reading from the results list should be thread safe. |
I just did a full grep of my file system looking for a breadcrumbs and then found out I can't search through my results. I was able to cmd+a cmd+c tab to vscode and cmd+p and then cmd+f. I am constantly using cmd+f on my terminal :( |
I wanted to provide some recipes for people waiting for this Searching by piping to fzf
Searching via NeovimMake sure that the default for xdg-open (linux) or open (mac) is set to nvim or whatever code editor you use Example in NixOs
Then create a new keybinding in ghostty
Using ZSH (Janky)This is essentially just looking for the most recent history file. Sometimes the most recent output isn't there since it's dependent on calls to write_scrollback_file. And that's not a simple binary you can call.
|
I've setup my new ghostty terminal and am really enjoying it. Unfortunately, wont be daily driving it until this functionality is ready. Key part of my workflow |
To elaborate on the earlier comment, a workaround for this currently exists in that you can bind keys to open an editor with all the text from the current terminal in it, which can then be searched through. The default keybinds related to this are:
The documentation for One slight downside with these, as they are now, is that they only write contents outside the visible area to the temporary file, so they don't help if you want your search to also include what is currently shown. If you want that included, you instead want to add a keybind that use the related I personally find
This allows me to press |
for the workarounds, is there any way to script the calls to Currently, if I add this keybinding for writing the name of the screen file to the terminal:
Then, I can manually type (on a Mac):
If there were some way to trigger those actions without having to press the keybinding, I could do something like:
and assign that to a script/alias That'd give me almost all the scrollback searchability I need |
see #3708 (comment) |
I find this feature in kitty very useful rather than using cmd+f. I have tried both and this was practically useful for me. (Genuinely want to understand how others feel about this also) When my unit test output is very long, i just open the last command output in LESS and troubleshoot. If the cmd's output I am looking for is few prompts before, in kitty, I would navigate to it using keyboard shortcuts (ghostty can also do this) and right click holding kitty_mod to open in LESS. (See here) In ghostty, it would be useful to redirect write_selection_file output to any program's STDIN. Like
|
Based on the previous comments - I'm currently using this on macOS:
This way it won't stop me from using Ghostty as a daily driver. |
I'm surprised For example, right now, if you have a TUI program or you're in an interactive state, the only option you can use is I'm personally rooting for #189 (comment). This seems like one of the nicest implementations for such feature Since this reply will ping a lot of people, I might as well just ask: Is there any workaround to still use open but to give it a custom program instead of it grabbing the default text editor? |
FYI you can use |
Yeah I second this. I've really being enjoying Ghostty but found the inability to do cmd+f pretty debilitating in my day to day workflow. It's like the only missing piece of the puzzle for me! I'm kinda sad to have to go back to iterm for now! |
this issue is the most thumbed several times over. There are likely hundreds of people subscribed to it. It's not helpful to post messages here simply saying it "doesn't fit your workflow". @mitchellh knows this is necessary. He'll work on it when he can I'm certain. Let's try to keep the discussion to helpful information. |
I was actually, primarily, complimenting the awesome terminal this is because it quite literally is almost perfect and I'm quite excited by that. As the issue has been open for 18 months I perhaps wrongly made an assumption that it probably wasn't moving forward (at least any time soon) so was just adding my perspective to it. I'm sorry for sharing my experience with Ghostty and I'm sorry you took such offence to that mistake. It's such a shame GitHub (and tech in general) is so hostile these days, people just seem to assume the worst in each other. Merry Christmas! |
I apologize if that came across as hostile, it was not meant to, nor what is it targeted at you since you're not the only one in recent days to have done this. My goal is simply to keep the discussion here helpful since it has a lot of eyeballs on it and we don't want to add to the noise. |
That is completely fair, and I understand - thanks. 🤝 |
Did anyone manage to get this to open in vim/nvim? I have nvim as my default editor on MacOS, but for some reason ghostty still opens the buffer in the default MacOS text edit. |
It uses the default editor of MacOS, not your |
Thanks @martensson ! I got it to work with Neovide by setting the default editor via Launch Services:
|
Great solution, officially daily driving it now. Here's the command for vscode, can be done for any editor.
|
Regarding the implementation of search in Ghostty. Different terminals have different approaches to search. For example, Wezterm has both Copy Mode and Quick Select Mode. I personally would really value something that emulated my (Lazy)Vim configuration - not just basic Vim motions but custom textobjects, seeking with flash.nvim etc. Obviously I can get part of the way there with Given that it would be bloated for Ghostty implement all the different approaches, could it instead hand over to an external tool for the search? That would allow experimentation and innovation in this area without affecting Ghostty's code. Perhaps there is something more streamlined than dumping the scrollback to a file then opening it in an editor... I haven't figured out the mechanics (a pointer? an emulated file?). Or is |
not sure if this applies more generally, but I needed to restart my Mac for this to take effect. thanks for the suggestion! |
On MacOS the |
For quick select mode, there is a feature request here (the title is based on the analogous feature in kitty): |
For some reason I couldn't get the commands above to work, but
I didn't need to log back in for this either. If you need to find the plist identifier for your desired app, do:
I failed to get it to open anything not installed as an |
ghostty-org/ghostty#189 It would be very nice if "open" took a parameter, so I could open "something" in ex. neovim. Could be as simple as: keybind = super+comma=open_config:myprogram.sh keybind = super+alt+shift+j=write_scrollback_file:open:myprogram.sh Where "myprogram.sh" would take the file as `$1`. I guess one problem is that where would "myprogram.sh" run? Maybe in an overlay? It can't run in the same terminal, since there might be another program already running there. Ex. tail, less, bat, ... What I really like: - Resizing splits feels a lot nicer than wezterm - Changing the font-size feels a lot nicer than wezterm ...still going to use wezterm for now though.
As a new user coming from iterm+tmux and trying to use ghostty as a replacement the main hangup I've run into is around scrollback management. With tmux I can use I would really love this modal capability in ghostty with the added benefit that whatever y'all do would also work well with the mouse where tmux tends to struggle. |
You can do this using Finder: 1/ select "Get Info" on any However, this doesn't work for |
I like the way kitty does it, it exposes the scrollback buffer and you pipe that to any program, like less and more importantly neovim so you can move around with vim bindings without creating a subpar version of them. |
FWIW, wezterm has a feature similar to kitty's which allows you to send the buffer to an external program. But also has it's own search and navigation modes. |
A major missing feature is the ability to search scrollback, i.e.
cmd+f
on Mac,ctrl+F
on Linux. This issue can be implemented in multiple steps, not just one giant PR:src/terminal
(Naive search internals (core only) #2885)We can also support search only in certain modes as long as the apprt glue is all there for someone to come along and finish it up. For example, only macOS, Linux+GTK, etc.
The text was updated successfully, but these errors were encountered: