Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Multiline mode exec remapping #370

Closed
Adventune opened this issue Nov 13, 2023 · 14 comments
Closed

Multiline mode exec remapping #370

Adventune opened this issue Nov 13, 2023 · 14 comments
Labels
question Question / Mis-usage

Comments

@Adventune
Copy link

Is it possible to remap the multiline execution key to another combination (eg. C-Enter)? I am using tmux-vim-navigator with C-j binded to navigate in the window and I am unable to execute multiline commands. I also couldn't find an option for the mapping.

@akinomyoga
Copy link
Owner

Is it possible to remap the multiline execution key to another combination (eg. C-Enter)?

Unless you use the vi editing mode, C-Enter is by default the same as C-j and thus can be used to run the command in the multiline mode without any additional configuration. If you are using the vi editing mode, you can change the binding by ble-bind -m vi_imap -f C-RET accept-line.

However, in order to use C-Enter, your terminal needs to support inputting C-Enter. What is your terminal? If your terminal sends the same code for C-Enter as Enter, it is impossible for the line editor to distinguish C-Enter from Enter. Some terminals support configuring the code sent to the application when a specific key combination is pressed. You may need to configure the code for C-Enter (C-RET) as described in a table in §3.6.4.

@akinomyoga akinomyoga added the question Question / Mis-usage label Nov 13, 2023
@Adventune
Copy link
Author

I am using tmux/bash. Does bash support CTRL+Enter I couldn't find anything online?

@akinomyoga
Copy link
Owner

akinomyoga commented Nov 20, 2023

I am using tmux/bash.

Thanks, What is the terminal outside tmux? The terminal that sends the key input is the outside terminal, but not tmux. Tmux just passes the key input from the outside terminal to the terminal application (Bash in this case).

Does bash support CTRL+Enter I couldn't find anything online?

The plain Bash with GNU Readline doesn't handle CTRL + Enter by default, so if you use the plain Bash without ble.sh, you need to manually set up a keybinding. However, ble.sh handles CTRL + Enter by default (in the Emacs editing mode, set -o emacs), so you don't need to manually set it up as far as the terminal supports it.

@Adventune
Copy link
Author

Outside tmux I have bash. Ble.sh is installed as per instructions in the readme. Ctrl+enter does not result in accepting the command

@akinomyoga
Copy link
Owner

Outside tmux I have bash.

Bash is not a terminal. What is the outside terminal? There should be a terminal (#1) that starts Bash (#2), and tmux (#3) is started inside #2, and tmux starts another Bash (#4). The resulting connection of streams becomes as follows:

[#1 outside terminal] --+--[#2 outside bash]
                        |
                        +--[#3 tmux]--[#4 bash]

I'm asking about the outside terminal sitting on #1. What is the terminal that starts the outer Bash (#2)?

@akinomyoga
Copy link
Owner

akinomyoga commented Nov 20, 2023

Could you give me the result of the following command?

$ ble/widget/display-shell-version

Edit: Could you run the above command in two cases: inside tmux and outside tmux?

@akinomyoga
Copy link
Owner

@Adventune Did you solve your problem?

Could you find what is the outer terminal in your setup? Or if you don't know what is your outer terminal, what is your operating system and how do you open the terminal window?

@Adventune
Copy link
Author

Adventune commented Dec 5, 2023

Sorry, forgot to get back to this. Here is the output of the command:

GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu) [Ubuntu 22.04.3 LTS]
ble.sh, version 0.4.0-devel4+3f13393 (noarch) [git 2.34.1, GNU Make 4.3, GNU Awk 5.1.0, API: 3.0 (GNU MPFR 4.1.0, GNU MP 6.2.1)]
bash-completion, version 2.11 (hash:b42f5d6a7ad6d4921ec73838ba54a96d6bd30936, 77071 bytes) (noarch)
locale: LANG=en_US.UTF-8 LC_ADDRESS=fi_FI.UTF-8 LC_IDENTIFICATION=fi_FI.UTF-8 LC_MEASUREMENT=fi_FI.UTF-8 LC_MONETARY=fi_FI.UTF-8 LC_NAME=fi_FI.UTF-8 LC_NUMERIC=fi_FI.UTF-8 LC_PAPER=fi_FI.UTF-8 LC_TELEPHONE=fi_FI.UTF-8 LC_TIME=fi_FI.UTF-8
terminal: TERM=xterm-256color wcwidth=14.0-west/15.1-2+ri, vte:6800 (65;6800;1)

Edit:
and inside tmux:

GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu) [Ubuntu 22.04.3 LTS]
ble.sh, version 0.4.0-devel4+3f13393 (noarch) [git 2.34.1, GNU Make 4.3, GNU Awk 5.1.0, API: 3.0 (GNU MPFR 4.1.0, GNU MP 6.2.1)]
bash-completion, version 2.11 (hash:b42f5d6a7ad6d4921ec73838ba54a96d6bd30936, 77071 bytes) (noarch)
locale: LANG=en_US.UTF-8 LC_ADDRESS=fi_FI.UTF-8 LC_IDENTIFICATION=fi_FI.UTF-8 LC_MEASUREMENT=fi_FI.UTF-8 LC_MONETARY=fi_FI.UTF-8 LC_NAME=fi_FI.UTF-8 LC_NUMERIC=fi_FI.UTF-8 LC_PAPER=fi_FI.UTF-8 LC_TELEPHONE=fi_FI.UTF-8 LC_TIME=fi_FI.UTF-8
terminal: TERM=screen-256color wcwidth=14.0-west/15.1-2+ri, tmux:0 (84;0;0), vte:6800 (65;6800;1)

@akinomyoga
Copy link
Owner

Thanks, the above result implies that your outside terminal is one of the VTE-based terminals. However, it is still difficult to identify which specific terminal of the VTE-based one is yours. Can you tell which is your outside terminal? Or can you describe how you start the terminal?

@Adventune
Copy link
Author

I run the default terminal application on Ubuntu. So I guess gnome-terminal?

@akinomyoga
Copy link
Owner

Thank you for your information.

I first checked the settings of the GNOME terminal, but there don't seem to be configuration options for the sequences sent by each keypress.

I also checked the source code of GNOME/vte, which does not seem to support Ctrl-Enter; They ignore all the modifier keys for Enter. The key input is processed in Terminal::widget_key_press (src/vte.cc), which calls another function _vte_keymap_map (src/keymap.cc). How each key is processed is determined based on the entries store in the array _vte_keymap. The entries for Enter is given by _vte_keymap_GDK_Return. However, both _vte_keymap and _vte_keymap_GDK_Return are specified to be in the static scope, so there is no way to modify the key processing from the application side (i.e., the terminal side such as the GNOME terminal).

There seems to be a Feature Request #2658 at the upstream VTE, which suggests a distinct key sequence for Shift-Enter.


To conclude, the terminal that you use does not support Ctrl-Enter (distinctly from Enter) and does not provide a way to customize it. You need to use another terminal that supports Ctrl-Enter or the feature called modifyOtherKeys or a terminal that provides the configuration for custom key sequences.

@Adventune
Copy link
Author

Adventune commented Dec 5, 2023

Thank you very much! Would you be able to recommend any terminals that would support Ctrl-Enter?

@akinomyoga
Copy link
Owner

akinomyoga commented Dec 5, 2023

Konsole would be one of the possible options. You may configure Konsole to send a proper sequence with Ctrl-Enter. The configuration is described in #187 (comment). You can specify \E[13;5u for Return+Ctrl-Shift. This is an example:

image

You can find other combinations in Manual §3.6.4.

xterm supports the modifyOtherKeys mode, where you don't need additional configurations. The recent terminals with the support for modifyOtherKeys include foot and zutty.

@Adventune
Copy link
Author

Thank you! I'll look into those!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question / Mis-usage
Projects
None yet
Development

No branches or pull requests

2 participants