You are not logged in.

#1 2024-03-08 23:58:58

V.N.G
Member
Registered: 2024-02-22
Posts: 10

Unable to see my keymaps [SOLVED]

I'm currently setting my bindkeys for Zshell so i need the keymap for multiple touch commands like CTRL+Left or CTRL+Shift+Right (for example).
I know 2 ways to know the keymap : cat command and CTRL+V.
It works fine but when my command start with CTRL or Shift then it shows nothing and i don't know what is the good keymap for zshell keybinding. I tried to use what people said they used on some forum but none seemed to work for me.

Is there another way to see the keymaps ?

Last edited by V.N.G (2024-03-10 23:46:08)

Offline

#2 2024-03-09 16:03:29

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 74,100

Re: Unable to see my keymaps [SOLVED]

This will hinge on the specific terminal emulator - if you don't get any output from "cat", there's a good chance it doesn't produce any input at all for those keys.
(What might or not be configurable, "will hinge on the specific terminal emulator")

Offline

#3 2024-03-09 18:02:52

V.N.G
Member
Registered: 2024-02-22
Posts: 10

Re: Unable to see my keymaps [SOLVED]

I'm sorry but it seems weird to me...
I will try to add more information.

So, my shell is Zsh and my terminal emulator is kitty.
BUT kitty configuration file understands CTRL+... and Shift+... commands because in the past I already configured it so that CTRL+Left/Right would backward/forward word.

Now i'm currently trying to do the same thing in Zsh for 2 reasons : not being dependant of kitty conf file and adding Shift+... commands for text selection.
I'm currently relying on this StackOverflow post (https://stackoverflow.com/questions/540 … -selection) for my implementation, but i made some modifications.
Here is my configuration (located in a separate file but imported in .zshrc) :

r-select() {
	((REGION_ACTIVE)) || zle set-mark-command
	local widget_name=$1
	shift
	zle $widget_name -- $@
}

r-deselect() {
	((REGION_ACTIVE = 0))
	local widget_name=$1
	shift
	zle $widget_name -- $@
}

r-delregion() {
	if ((REGION_ACTIVE)) then
		zle kill-region
	else 
		local widget_name=$1
		shift
		zle $widget_name -- $@
	fi
}

for   key      seq         mode       widget (
	# MOVE :
	  left     $'^[[D'     deselect   backward-char
	  right    $'^[[C'     deselect   forward-char
 
	  cleft    $'^[[1;5D'  deselect   backward-word
	  cright   $'^[[1;5C'  deselect   forward-word

	  aleft    $'^[[1;3D'  deselect   beginning-of-line
	  aright   $'^[[1;3C'  deselect   end-of-line

	# SELECT :
	  sleft    $'^[[1;2D'  select     backward-char
	  sright   $'^[[1;2C'  select     forward-char

	  csleft   $'^[[1;6D'  select     backward-word
	  csright  $'^[[1;6C'  select     forward-word

	  asleft   $'^[[1;4D'  select     beginning-of-line
	  asright  $'^[[1;4C'  select     end-of-line

	# DELETE :
	  del      $'^[[3~'    delregion  delete-char
	  cdel     $'^[[3;5~'  delregion  delete-word
	  bs       $'^?'       delregion  backward-delete-char
	  cbs      $'^H'       delregion  backward-delete-word
) {
	eval "key-$key() {
		r-$mode $widget \$@
	}"
	zle -N key-$key
	bindkey $seq key-$key
}


# restore backward-delete-char for Backspace in the incremental
# search keymap so it keeps working there:
bindkey -M isearch '^?' backward-delete-char 

When i look at the bindkeys in the terminal, they are indeed created with no errors and the same keymap as I indicated.
All DELETE commands, left, right, aleft, aright, asleft, asright are working but the others do nothing.
When testing with cat, doing Alt+... will work even if there is CTRL or Shift in it.
So the problem seems to be PRECISELY when i start a command with CTRL or Shift or both.

So why kitty is able to understands CTRL+Shift+... commands (see doc here : https://sw.kovidgoyal.net/kitty/overview/ + I use frequently commands like CTRL+Shift+T that works fine) but not Zsh ?

Thanks for your time and effort !

Offline

#4 2024-03-09 21:31:05

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 74,100

Re: Unable to see my keymaps [SOLVED]

If you're binding a key as some sort of kitty shortcut, kitty will no longer forward it to the shell.
=> Try the behavior w/ xterm or alacritty.

Offline

#5 2024-03-10 23:45:45

V.N.G
Member
Registered: 2024-02-22
Posts: 10

Re: Unable to see my keymaps [SOLVED]

OM*G I totally forgot that CTRL+Arrows and Shift+Arrows were already taken in the kitty configuration file when i configured the window arrangement (see https://sw.kovidgoyal.net/kitty/layouts/)

I changed these commands and deleted the one that were already used by kitty for other things and now it works completely fine, sorry for my stupidity x)

Offline

Board footer

Powered by FluxBB