Xfce Forum

Sub domains
 

You are not logged in.

#1 2023-02-26 08:38:21

jt1122
Member
Registered: 2021-03-26
Posts: 240

Terminal keybindings

Hi,

Is it possible to bind in the xfce4-terminal a *sequence* of keys to simulate another keyboard input, for example:
ESC+left arrow would be mapped to ^L (so any app running in therminal would receive ^L once ESC+left arrow have been entered)
ESC-x ESC - y would be mapped to ^K

etc.

Thanks.

Offline

#2 2023-02-26 14:22:27

KBar
Moderator
Registered: 2021-11-05
Posts: 689

Re: Terminal keybindings

Sure it is.

If your shell is bash (if you don't know, then it most likely is), you can rebind those keys as long as there is a readline function for what you're looking for. So for clearing the screen, which is what the ^L control character does, you'd do the following:

# clear any existing binding first:
bind -r '\e\e[D'
# then bind it to a function
bind '"\e\e[D": clear-screen'

man readline & help bind for more.


Remember to edit the subject of your topic to include the [SOLVED] tag once you're satisfied with the answers or have found a solution (in which case, don't forget to share it as well), so that other members of the community can quickly refer to it and save their time. Pretty please! tongue

Offline

#3 2023-02-26 20:03:33

jt1122
Member
Registered: 2021-03-26
Posts: 240

Re: Terminal keybindings

Thanks.

I'm familiar with readline.

I'll clarify what I'm trying to achieve: some terminal apps (like text editors) don't support key sequences but only combinations like ctrl-<key> or alt-<key> where <key> is a letter (no special char or escape codes).

So I'm wondering if this example is doable:
esc+left arrow -> converted into ctrl-x -> fed into the terminal app-> app performs some actions

Cheers

Offline

#4 2023-02-27 12:34:50

jt1122
Member
Registered: 2021-03-26
Posts: 240

Re: Terminal keybindings

bump

Offline

Board footer

Powered by FluxBB