Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

kitty terminal hints is awesome, Has anyone implemented it? #669

Open
yurenchen000 opened this issue Nov 2, 2022 · 14 comments
Open

kitty terminal hints is awesome, Has anyone implemented it? #669

yurenchen000 opened this issue Nov 2, 2022 · 14 comments
Labels
enhancement New feature or request

Comments

@yurenchen000
Copy link

Is your feature request related to a problem? Please describe.
N

Additional context

about kitty hints

It can input strings in screen (maybe output by previous cmd) with shortcuts (without mouse select, copy, paste things)

which is really convenience in daily command operations.

let me show you in several seconds video.

input file path

kitty_hints_file.webm

input file:line path

kitty_hints_file.line_.webm

input word

kitty_hints_word.webm

show last/all cmd output in less

to search keywords but Save unnecessary pipeline execution.

scroll by cmd prompt

to scroll over long long outputs very efficiently.


and so on..

that's really impressed me.

wanna (make) a terminator plugin
but I'm not sure I have enouth time.

@yurenchen000
Copy link
Author

kitty hints docs
https://sw.kovidgoyal.net/kitty/kittens/hints/#hints

// default shortcuts
ctrl+shift+p followed by:

  • f -- match & input file path
  • n -- match & input file:linenum
  • l -- match & input whole line
  • w -- match & input word
  • h -- match & input hash

@yurenchen000 yurenchen000 changed the title kitty terminal hints is awosome, Has anyone implemented this feature or plugin? kitty terminal hints is awosome, Has anyone implemented it? Nov 2, 2022
@yurenchen000 yurenchen000 changed the title kitty terminal hints is awosome, Has anyone implemented it? kitty terminal hints is awesome, Has anyone implemented it? Nov 2, 2022
@Vulcalien
Copy link
Member

That is quite impressive actually. It removes the need for a mouse action completely.

I agree on the feature being a plugin instead of the main application.

@Vulcalien Vulcalien added the enhancement New feature or request label Nov 9, 2022
@mattrose
Copy link
Member

Somewhere in the backlog is the concept of a command pallette, that would open up a window that would let you search through keybindings and available actions. This is that ++

@yurenchen000
Copy link
Author

yurenchen000 commented Nov 15, 2022

terminator_hints3_.webm

seems I made it work, with source modified.

I'm not sure is it possible in pure plugin, will try later

@yurenchen000
Copy link
Author

yurenchen000 commented Nov 22, 2022

Somewhere in the backlog is the concept of a command pallette, that would open up a window that would let you search through keybindings and available actions. This is that ++

@mattrose

That sounds cool
Expect new features in plugin system.

https://github.com/yurenchen000/terminator-hints-plugin

  • ctrl+shitf+p to input
  • show last/all cmd output in less
  • scroll by cmd prompt

@Vulcalien

I have implemented this feature with a plugin,
But lots of HACK things in it:

  • get Terminal instance
    //HACK method from mchelem
  • setup for each Terminal
    //HACK URLHandler handler_name getter
    //extract a new class (plugin type) for terminal hook/setup
  • setup for shortcut
    //HACK override terminal attr
  • setup for config page
    //not yet

Which heavy reliance on terminator internal implementation.

It feels not programming but cracking 😿

@phidebian
Copy link

@yurenchen000 I cloned your initial plugin, out of the box I guess there are minor glitches, but the overall idea seems in place. I still kiffe it a lot :)

I key binded go_prev to <Meta>p

Then <Meta>p do display this as hints.
PW$ <Meta>ph ex dec word line ip url

In the source I see the gen_hints() with the 1 key shortcuts, [pnlwhdiu] and the tip_hotkeys with [hdwlniu] may be there is a mismatch here. I also note that 'f' hotkey is not there, yet easy to add.

All in all it is a good start, needing a bit of tuning :)

@yurenchen000
Copy link
Author

yurenchen000 commented Mar 2, 2023

@yurenchen000 I cloned your initial plugin, out of the box I guess there are minor glitches, but the overall idea seems in place. I still kiffe it a lot :)

I key binded go_prev to p

Then p do display this as hints. PW$ ph ex dec word line ip url

In the source I see the gen_hints() with the 1 key shortcuts, [pnlwhdiu] and the tip_hotkeys with [hdwlniu] may be there is a mismatch here. I also note that 'f' hotkey is not there, yet easy to add.

All in all it is a good start, needing a bit of tuning :)

@phidebian

this plugin shortcuts not exactly same as kitty hints:
after press ctrl+shift+p will directly into path match mode (the kitty f match)
and other keys h d w l n i u can change match mode.
so p and f is not in tips_hotkeys.

when test it need some strings in terminal, for example
echo '/some/test/path/00aabb 1234'

//I can't set super+p in gnome (other occupied shortcuts may not work too), but I tested assign super+b works.
//you saw the hints seems the shortcut works,
did you have test strings in terminal? did you try other key h d ?

@phidebian
Copy link

phidebian commented Mar 2, 2023

Yes I have strings on the terminal, and I can hack your initial version :)

I just meant that looks like there are some discrepencies between.

hotkeys = 'pnhdlwiuf'
....
if kind == 'p':
elif kind == 'n':
elif kind == 'l':
elif kind == 'w':
elif kind == 'h':
elif kind == 'd':
elif kind == 'i':
elif kind == 'u':
... 
tip_hotkeys = '''
<span bgcolor="#006400" fgcolor="black" weight="bold">h</span>ex
<span bgcolor="#006400" fgcolor="black" weight="bold">d</span>ec
<span bgcolor="#006400" fgcolor="black" weight="bold">w</span>ord
<span bgcolor="#006400" fgcolor="black" weight="bold">l</span>i<span
      bgcolor="#006400" fgcolor="black" weight="bold">n</span>e
<span bgcolor="#006400" fgcolor="black" weight="bold">i</span>p
<span bgcolor="#006400" fgcolor="black" weight="bold">u</span>rl
'''

The later don't display 'f' as hint, the if/elif sequence don't process 'f', only hotkeys define 'f'
That's minor and easy to fix, I am contemplating the idea of doing something more of Meta-r doing an emacs like incremental search walk back on the frozen scroll area, and may be Meta-R for regex too.

There is as well a strange 'i' in the later looks like a cut/paste pb :-)

I will look as well to add something like 'e' hotkey for edit the file:num something that would paste $PAGE file +num :)

Well sky is the limit...

@yurenchen000
Copy link
Author

@phidebian
about scrollback search and navigate, do you mean those shortcuts in kitty ?
https://sw.kovidgoyal.net/kitty/overview/#scrolling

  • ctrl+shift+z //Previous shell prompt
  • ctrl+shift+x //Next shell prompt
  • ctrl+shift+h //Browse scrollback in less
  • ctrl+shift+g //Browse last cmd output

at first I want to implement them, but I encountered this libvte bug
https://launchpad.net/~nrbrtx/+archive/ubuntu/vte

cause this bug, libvte can't got all scrollback content but only last screen content.
and this copy-all plugin also breaked

so i put it aside for now.

@phidebian
Copy link

@yurenchen000 I don't know kitty, I meant really freeze the display as you did at ctrl+shift+p time, then walk back with an incremental search on the frozen are and would paste what we got, well may be just dreaming :)

@yurenchen000
Copy link
Author

@phidebian
did you mean like search in vim or less?
allow user instantly input match pattern instead of predefined pattern in code (or config)

I think it's easy to implement, maybe another / shortcut and match mode.

I also encountered other problem, for example gtk textview not always display text exactly same as vte dose
so I plan to replace textview by another vte for search display.

@phidebian
Copy link

phidebian commented Mar 3, 2023

@yurenchen000 Yes I meant an editor like search,

  • /?<pattern><ret> ala vi/more/less
  • ^r<char><char><tab><tab><ret> ala emacs

@yurenchen000
Copy link
Author

yurenchen000 commented Sep 16, 2024

Yes I meant an editor like search,

  • /? ala vi/more/less

@phidebian
I have implement the feature you mentioned, use / shortcut in Hints page.
https://github.com/yurenchen000/terminator-hints-plugin/tree/custom_re


It use py3 re.compile for regex string.
but I think typing regex has mental burden

  • if regex is invalid it will not work
    // indicated by fontcolor red
  • for input:
    // if I need to typing regex, I prefer select text with the mouse
  • for search: it only search last screen (without scrollback)
    // cause vte not support get full scrollback text anymore

@yurenchen000
Copy link
Author

@phidebian


The later don't display 'f' as hint, the if/elif sequence don't process 'f', only hotkeys define 'f'

I did that on purpose (Omit it in Tips).
Because after ctrl+shift+p the default mode is ⓕile_path match


There is as well a strange 'i' in the later looks like a cut/paste pb :-)

i is for ⓘp match, commonly used after ifconfig output

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants