Bug 298775 - Add search for tab functionality
Summary: Add search for tab functionality
Status: RESOLVED FIXED
Alias: None
Product: konsole
Classification: Applications
Component: tabbar (show other bugs)
Version: unspecified
Platform: Debian unstable Linux
: NOR wishlist
Target Milestone: ---
Assignee: Konsole Developer
URL:
Keywords: junior-jobs, usability
Depends on:
Blocks:
 
Reported: 2012-04-25 02:55 UTC by mchugh19@yahoo.com
Modified: 2024-12-09 20:52 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Kate Ctrl Tab Video (111.12 KB, video/mp4)
2020-10-23 00:26 UTC, Justin Zobel
Details

Note You need to log in before you can comment on or make changes to this bug.
Description mchugh19@yahoo.com 2012-04-25 02:55:22 UTC
Discussed in http://forum.kde.org/viewtopic.php?f=227&t=101711&p=220475

My workflow with konsole involves opening up a window with lots of tabs to various servers. I would like to be able to search for tab contents. Hitting ctrl-alt-/ or something and typing "cas-dev" would select the tab containing that string. This would allow me to quickly find the tab corresponding with the server I'm searching for. 

Reproducible: Always
Comment 1 Justin Zobel 2020-10-23 00:26:06 UTC
Created attachment 132649 [details]
Kate Ctrl Tab Video

Video attached of kate's Ctrl Tab feature

Perhaps something similar to kate's Ctrl Tab feature could be used, I'm not sure if this feature is a KDE module/plugin to apps or if it's only in kate. But either way it could be used.
Comment 2 Nicolas Girard 2020-11-07 22:32:53 UTC
The following command allows the user to select a session by searching through the session names, and returns the number of the chosen session:

  qdbus $KONSOLE_DBUS_SERVICE /Windows/1 sessionList|xargs -I{} sh -c 'printf "%s\t" {}; qdbus $KONSOLE_DBUS_SERVICE /Sessions/{} org.kde.konsole.Session.title 1'|fzf --with-nth 2  |cut -d$'\t' -f1

The only missing piece here is the ability to switch to the tab associated with a session number via D-bus.
Comment 3 Nicolas Girard 2020-11-07 22:40:36 UTC
I should add that, since `sessionList` only returns session numbers, we need to loop through all sessions to get their titles, which is awfully slow.

A dedicated `sessionListWithTitle` method would be much needed for that purpose.
Comment 4 Nicolas Girard 2020-11-07 23:19:58 UTC
> The only missing piece here is the ability to switch to the tab associated with a session number via D-bus.

This would be achieved by fixing bug 422262.
Comment 5 Gabor 2020-11-08 17:03:23 UTC
(In reply to Nicolas Girard from comment #4)
> > The only missing piece here is the ability to switch to the tab associated with a session number via D-bus.
> 
> This would be achieved by fixing bug 422262.

I filed that bug when I wanted to achieve the same thing. Currently I have an awful workaround which activates the tabs one by one and gets the current title while it founds the searched tab.
Comment 6 Nicolas Girard 2020-11-08 17:15:30 UTC
(In reply to Gabor from comment #5)

> 
> I filed that bug when I wanted to achieve the same thing. Currently I have
> an awful workaround which activates the tabs one by one and gets the current
> title while it founds the searched tab.

Yeah, I saw someone else getting that dirty here: https://debianforum.de/forum/viewtopic.php?t=178041 and didn't feel like trying.

How bad does it feel with a few tens of tabs ?
I might give it a try after all, if you don't mind pasting your code.
Comment 7 Gabor 2020-11-08 17:27:06 UTC
(In reply to Nicolas Girard from comment #6)
> (In reply to Gabor from comment #5)
> 
> > 
> > I filed that bug when I wanted to achieve the same thing. Currently I have
> > an awful workaround which activates the tabs one by one and gets the current
> > title while it founds the searched tab.
> 
> Yeah, I saw someone else getting that dirty here:
> https://debianforum.de/forum/viewtopic.php?t=178041 and didn't feel like
> trying.
> 
> How bad does it feel with a few tens of tabs ?
> I might give it a try after all, if you don't mind pasting your code.

Here you have it: https://pastebin.com/7HFThb5a
activates the tab if found else exits 0
Comment 8 Gabor 2020-11-08 17:38:25 UTC
Works with exact match, and I have not tried it more than about 10 tab.
Comment 9 Nicolas Girard 2020-11-08 18:46:56 UTC
> 
> Here you have it: https://pastebin.com/7HFThb5a
> activates the tab if found else exits 0

OK, so thanks to your input I tried `dbus-send` and adopted it as it seems roughly twice as fast as `qdbus`.

I took your "tab switch" loop from your code and incorporated into mine, reducing the sleep delay to 5ms.

I also revamped my code. The overall result is... well, not that bad for a temporary solution. It's crappy, but it does the job.

Since this has been pissing me off so long, and probably other people too, I think I'll create a proper repo on Github and put the code there.
Comment 10 Nicolas Girard 2020-11-09 17:17:12 UTC
> Since this has been pissing me off so long, and probably other people too, I think I'll create a proper repo on Github and put the code there.

Done: https://invent.kde.org/ngirard/konsole-tab-switch
Comment 11 Kurt Hindenburg 2024-03-27 22:49:54 UTC
I would agree having something like would be nice.    The link in  comment 10 looks like a nice alternative for now.
Comment 12 Bug Janitor Service 2024-11-03 23:04:34 UTC
A possibly relevant merge request was started @ https://invent.kde.org/utilities/konsole/-/merge_requests/1045
Comment 13 Kurt Hindenburg 2024-12-04 14:18:10 UTC
Git commit 74c648c0fc842af4746892205330a77377c90cbd by Kurt Hindenburg, on behalf of Troy Hoover.
Committed on 04/12/2024 at 14:18.
Pushed by hindenburg into branch 'master'.

Add search tab button to the tab bar

The button takes user input and sorts through a list of tab names for the tab that matches

SearchTabs pulls from Kate's similar tab sort
function called QuickOpen
GUI:

M  +3    -0    src/CMakeLists.txt
A  +318  -0    src/searchtabs/SearchTabs.cpp     [License: GPL(v2.0+)]
A  +68   -0    src/searchtabs/SearchTabs.h     [License: GPL(v2.0+)]
A  +69   -0    src/searchtabs/SearchTabsModel.cpp     [License: GPL(v2.0+)]
A  +68   -0    src/searchtabs/SearchTabsModel.h     [License: GPL(v2.0+)]
A  +431  -0    src/searchtabs/kfts_fuzzy_match.h     [License: LGPL(v2.0+)]
M  +115  -8    src/settings/TabBarSettings.ui
M  +8    -0    src/settings/konsole.kcfg
M  +34   -1    src/widgets/ViewContainer.cpp
M  +2    -0    src/widgets/ViewContainer.h

https://invent.kde.org/utilities/konsole/-/commit/74c648c0fc842af4746892205330a77377c90cbd