-
Notifications
You must be signed in to change notification settings - Fork 522
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. |
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. |
I just want this to work like warp :) |
@leo-paz you should share a video of it |
I think it's really nice that ghostty does tabs via UI like most other software (file explorer, browser etc.) using the common OS hotkey for it, rather than pushing users towards something like tmux or zellij. Similarly I'd prefer if scrollback search was done via UI as well, so It's just nice to have common functionality work the same across all software in my opinion, makes things intuitive to use. But I suppose nothings speaks against also exposing the scrollback buffer for piping in addition to that. |
iTerm highlights the searched pattern in live mode. This is handy when tailing some log and want to highlight something important but also not throw away the rest of the log as grep would do it. |
Thanks @m4saurabh for the hint on this Kitty functionality. From there I also discovered this incredible Neovim plugin which integrates with the Kitty scrollback buffer and provides some extra handy functionality. Here is part of a demo by the author (starting at 9:05) showing switching seamlessly between live Kitty and the scrollback buffer within Neovim. Note the little flash of the text redrawing but other than that you wouldn't know that you had left the terminal! Most relevant to this discussion is that the author also details here (same video from 4:50) various approaches to getting the scrollback buffer into Neovim, starting with writing to a file then eventually settling on Kitty's built-in remote calls like get-text. It will be great if Ghostty can also allow for this kind of deep integration which offers the best of both worlds of native terminal and your raw custom Neovim power, plugins and all.
I completely agree this kind of capability should be alongside rather than instead of built-in search. In the meantime thanks to the great discussion in this thread I think I'm switching to Kitty for a while :-) |
Indeed, with how much time i spend SSHd into servers, this feature pairs well with all of the other bazillions of utilities i have to use on live tailing of screaming logs. On OSX, i had to go back to iTerm2. Still using Ghostty on my personal laptop. |
Another use for scrollback search is to highlight matching strings to make screenshots that I send to colleagues. This is extra useful with regex search, to allow highlighting different types of strings. I use this often – here's an example screenshot. |
The ability to search scrollback and the ability to pipe scrollback to arbitrary commands are two different pieces of functionality. It would be nice to have both but this card is specifically about the former. |
use(d) this all the time, currently trying to main ghostty tho 🤓 and hit the missing search feature pretty quickly 😅 |
agreed. this is a very common use case. |
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: