2

I would like to use ctrl + h as Left Arrow and so on (vim style) in whole OS (all apps). I use gnome 3.16.4.

xev result for ctrl+h press-release sequence is:

KeyPress event, serial 37, synthetic NO, window 0x3000001,
    root 0xf6, subw 0x0, time 8058713, (-860,225), root:(166,344),
    state 0x0, keycode 37 (keysym 0xffe3, Control_L), same_screen YES,
    XLookupString gives 0 bytes:
    XmbLookupString gives 0 bytes:
    XFilterEvent returns: False

KeyPress event, serial 37, synthetic NO, window 0x3000001,
    root 0xf6, subw 0x0, time 8058895, (-860,225), root:(166,344),
    state 0x4, keycode 43 (keysym 0x68, h), same_screen YES,
    XLookupString gives 1 bytes: (08) "
    XmbLookupString gives 1 bytes: (08) "
    XFilterEvent returns: False

KeyRelease event (...)

and for h one line is as follows:

XLookupString gives 1 bytes: (68) "h"

Left arrow is simple:

keycode 113 (keysym 0xff51, Left)

Actualization

Rationale for CTRL

Firstly I wanted assign fn + h,j,k,l but it seems to be imposible in software way. windows + l and windows + h are also in use as logout and minimal window respectively. Left Alt looks like the best option, but in some programs it works as additional letters (encoding) (e.g. vim and gvim see distinct keys when alt is pressed).

I know that I will lost some functionality using ctrl, but so far I've never use default ctrl + hjkl shortcuts in a terminal (I use vi-mode mapping set in .inputrc)

xev Alt + h version:

KeyPress event, serial 37, synthetic NO, window 0x1e00001,
    root 0xf6, subw 0x0, time 2180657, (434,71), root:(484,158),
    state 0x0, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyPress event, serial 37, synthetic NO, window 0x1e00001,
    root 0xf6, subw 0x0, time 2180851, (434,71), root:(484,158),
    state 0x8, keycode 43 (keysym 0x68, h), same_screen YES,
    XLookupString gives 1 bytes: (68) "h"
    XmbLookupString gives 1 bytes: (68) "h"
    XFilterEvent returns: False

2 Answers 2

1

If you're using bash, checkout set -o vi. fish_vi_key_bindings for fish. Actually most interactive shells have vi-like bindings.

Ctrl + h, j, k, l, ... are reserved for antiquated reasons. No, you won't make your computer worse by reassigning them.

Some combinations like ctrl-j exists because 50 years ago, not all key-boards had keys like enter, backspace, del, arrows, .... These are the combinations that are both the deepest encoded (eg. at the terminal emulator level), hardest to rebind, because they once were vital, and the most frustrating because they are common key combinations with useless redundant mapping.

No matter the terminal you're using, wezterm's documentation looks like a great place to start learning about the topic https://wezfurlong.org/wezterm/shell-integration.html

Some combinations, like Ctrl + c, send signals to the running process. There are other ways to send signals, but you probably don't want to remap them, at least as long as you're in a shell. It's easy to handle them on a software level (just interpret the signal like you want), but not at the configuration level (it is a signal they're receiving, not a regular key press).

Other combinations, like Ctrl-k, are part of the GNU readline library https://tiswww.case.edu/php/chet/readline/readline.html#Command-Line-Editing , or of a close emulation to it's behaviour and keybindings. Knowing they exist may save you a lot of time, but as stated above, they're not the only possibility, most interactive shell offer a vi-like alternative. They're usually easy to remp, or at least as easy as any other key of the application you're considering, and with good reason since they're only really meaningful in a command line prompt.

1

Control H, J, L already have well-established uses in terminals:

  • controlH for erase (except Linux)
  • controlJ is newline
  • controlL is a form-feed equated with clearing the screen

In bash, controlK is by default bound to kill-line.

It is possible to change these assignments, but your computer would be less useful thereafter.

1
  • 1
    Hi. Firstly I wanted assign "fn"+hjkl but it seems to imposible in software way. "windows" + l is also logout shorcut. Left Alt seems good enough but in some programs it works as additional letters (encoding). I know that I will lost some functionality using ctrl, but so far I've never use shortcuts you've written. For clear screen I have alias "c" in bashrc. For newline I use ENTER For erase - BACKSPACE Could you please write a tip to do it using CTRL or ALT?
    – Mesco
    Commented Sep 6, 2016 at 7:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .