-
-
Notifications
You must be signed in to change notification settings - Fork 85
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
[kitty] ble.sh not working with the kitty terminal #110
Comments
Hello! Thank you for the report! It seems there is no problem in my Kitty on Ubuntu 20 LTS in VirtualBox. I have questions:
$ echo "$TERM"
$ tput cols; echo $?
$ echo "$MACHTYPE"
$ uname -a
$ cat /etc/*-release # if you are in Linux
$ INPUTRC=/dev/null bash --norc --noprofile
$ source /path/to/ble.sh |
Hi @akinomyoga |
Hmm, thank you. Maybe it is related to the prompt.
|
The problem is still there when I set PS1 to this sadly 😢 |
Thank you! Hmm...
$ env -i INPUTRC=/dev/null bash --norc --noprofile
$ source /path/to/ble.sh --norc --noinputrc Edit: Maybe you have already set up something in |
Still does not work. It seems to happen when I reach the end of the screen with the prompt, or with the first two lines. |
Thanks. It still doesn't reproduce in my environment with a long prompt (though I found an unrelated problem) and also at the top and bottom lines of Kitty.
|
$ kitty --version
kitty 0.20.3 created by Kovid Goyal
$ cat ~/.config/kitty/kitty.conf
font_family Ubuntu Mono
bold_font auto
italic_font auto
bold_italic_font auto |
I have created a commit 2e14354 for testing and pushed it to
|
My kitty terminal was outdated- and after updating to kitty 0.20.3, the problem was fixed 😄 However, there is still this output from the noah@noahs-ubunto[±|debug110 → noah ✓]:~/open-source/ble.sh $ echo bababa
bababa
[U1][U2][U2a][U2b]bash: [: =: unary operator expected
[U2c][U2d][U3][U4][I1][I2][I3][I3a][I3b][I4][I4d][U5]
[U6]
[R.W1][R.W2][R.W3][R.W4a][R.W5]
noah@noahs-ubunto[±|debug110 → noah ✓]:~/open-source/ble.sh $ [U1][U2][U2a][U2b]bash: [: =: unary operator expected
[U2c][U2d][U3][U4][I1][I2][I3][I3a][I3b][I4][I4d][U5]
[U6]
[R.W1][R.W2][R.W3][R.W4a][R.W5]
noah@noahs-ubunto[±|debug110 → noah ✓]:~/open-source/ble.sh $ echo bobo
bobo
[U1][U2][U2a][U2b]bash: [: =: unary operator expected
[U2c][U2d][U3][U4][I1][I2][I3][I3a][I3b][I4][I4d][U5]
[U6]
[R.W1][R.W2][R.W3][R.W4a][R.W5]
noah@noahs-ubunto[±|debug110 → noah ✓]:~/open-source/ble.sh $ |
Oh, OK! Great.
OK. It means that it was actually a combined problem of two problems. It's confusing!
This indicates that
$ PROMPT_COMMAND=
$ declare -p PROMPT_COMMAND
$ bash # start new session
$ source /path/to/ble.sh --noattach |
So, after debugging the problem a bit: declare -- PROMPT_COMMAND="__bp_precmd_invoke_cmd
preexec_set_exit;preexec_invoke_cmd
__bp_interactive_mode" I saw that running scm_prompt() {
CHAR=$(scm_char)
if [ $CHAR = $SCM_NONE_CHAR ]
then
return
else
echo "[$(scm_char)$(scm_prompt_info)]"
fi
} It seemed like the There is another problem that I encountered. When you call |
OK!
Hmm... is it really I'm also wondering why it didn't reproduced with the plain Bash but only reproduced in
You're welcome!
Oh, thank you for the information! Hmm... again it doesn't reproduce in my environment. Do you use |
I indeed use Seems like another kitty problem, yet this time it is with the latest version 😢 |
Hmm, interesting. There is no problem with $ stty sane; exec bash Also, $ ble-detach
[ble: detached]
Please run `stty sane' to recover the correct TTY state.
$ stty sane;
$ exec bash |
It happens after ble-detach, so I can not run |
OK, I could partially reproduce the issue. This is a bug of Kitty or a quirk of Kitty. I added a work around f599525.
So, this doesn't mean something trivial like |
This commit indeed fixed the problem. Maybe this is something we should report to kitty? Thanks for all of your help @akinomyoga! your dedication is truly amazing 😄 |
By the way, by adding Closing this issue now, expect a PR with a new plugin in Bash-it soon 😃 |
OK! Thank you for your confirmation!
Maybe, but I'm not sure if Kovid will change the behavior of Kitty. The problem is the behavior of the terminal feature called
Oh! Thank you very much! When you add Fix (2021-11-23): Fix typos |
kitty will no longer respond to CSI > 4; 1 m And FYI if you want proper key support in kitty, see https://sw.kovidgoyal.net/kitty/keyboard-protocol/ (also being implemented in foot and iterm2 kovidgoyal/kitty#3248) |
@kovidgoyal Thank you for the information! ble.sh currently uses CSI > 4 m to turn off
I have added the support for the kitty keyboard protocol (using CSI > 1 u and CSI < u) in commit ec91574. Now ble.sh uses the kitty protocol for kitty version 0.23+. The older kitty may have also been supported the kitty protocol, but I haven't tested ble.sh against the older versions of kitty, so the support is currently only enabled from 0.23. Question on the number range reserved by kitty in the DA2 response@kovidgoyal I have a question on the terminal identification of kitty. Currently, kitty (of the version 0.XX.Y) responds to DA2 request with the response of the form CSI > 1; 4000; XX c. Is there any plan that the number "4000" will be changed (for example, when kitty version becomes 1.XX.Y)? I'd like to know the possible range of the number used by kitty such as 4000--4010 or 4000--4100, etc. I'm currently accepting 4000--4100 as kitty, but a wider range increases the chances of mistakenly recognizing other terminals as kitty, so I'd like to minimize the range if possible. Question/suggestion on ctrl+shift+* keybindings of kitty@kovidgoyal In testing the behavior of ble.sh in kitty, I was first confused by the fact that the most of the key events of ctrl+shift+* cannot be captured by ble.sh even when Another possibility might be to provide an option for a kind of kitty-UI modifier key just like the prefix key used in tmux and GNU screen. If you don't like all of them, I would like to have a configuration of disabling kitty-UI keybindings by a couple of lines (instead of a bunch of lines of ctrl+shift+a..ctrl+shift+z, ctrl+shift+0...ctrl+shift+9, ...). Something like
|
On Mon, Nov 22, 2021 at 09:36:11PM -0800, Koichi Murase wrote:
@kovidgoyal Thank you for the information! ble.sh currently uses <kbd>CSI > 4 m</kbd> to turn off `modifyOtherKeys` for kitty as a workaround, so it does not use <kbd> CSI > 4; 1 m</kbd> inside kitty.
~~It seems kitty still responds to <kbd>CSI > 4 m</kbd> and <kbd> CSI > 4 ; 2 m</kbd> (in kitty 0.23.1), but will the support for <kbd>CSI > 4 m</kbd> and <kbd>CSI > 4; 2 m</kbd> also be removed as well as that for <kbd>CSI > 4; 1 m</kbd>?~~ --> OK, I found the commit kovidgoyal/kitty@d6a43a7. <kbd>CSI > <i>Pm</i> m</kbd> will be completely removed in the next release version, kitty 0.24?
Yes, the xterm protocol will be completely ignored by kitty.
I have added the support for the kitty keyboard protocol (using <kbd>CSI > 1 u</kbd> and <kbd>CSI < u</kbd>) in commit ec91574. Now ble.sh uses the kitty protocol for kitty version 0.23+. The older kitty may have also been supported the kitty protocol, but I haven't tested ble.sh against the older versions of kitty, so the support is currently only enabled from 0.23.
### Question on the number range reserved by kitty in the DA2 response
@kovidgoyal I have a question on the terminal identification of kitty. Currently, kitty (of the version 0.*XX*.*Y*) responds to DA2 request with the response of the form <kbd>CSI > 1; 4000; *XX* c</kbd>. Is there any plan that the number "4000" will be changed (for example, when kitty version becomes 1.XX.Y)? I'd like to know the possible range of the number used by kitty such as 4000--4010 or 4000--4100, etc. I'm currently [accepting 4000--4100](https://github.com/akinomyoga/ble.sh/blob/a6b4e2ca108d81019dd90313cc57847e00a757cc/src/util.sh#L5506) as kitty, but a wider range increases the chances of mistakenly recognizing other terminals as kitty, so I'd like to minimize the range if possible.
It's not going to change. However, if you want to do terminal detection
via escape code use XTGETTCAP with which you can query the actual
terminal name instead of DA2. kitty even implements extensions to
XTGETTCAP to query the values of various user settable options.
https://sw.kovidgoyal.net/kitty/kittens/query_terminal/
### Question/suggestion on ctrl+shift+* keybindings of kitty
@kovidgoyal In testing the behavior of ble.sh in kitty, I was first confused by the fact that the most of the key events of <kbd>ctrl+shift+\*</kbd> cannot be captured by ble.sh even when `modifyOtherKeys` or kitty's comprehensive keyboard mode is enabled. I finally realized that actually most of the key combinations of <kbd>ctrl+shift+\<xxxx\></kbd> are already used by kitty UI. I have finally tested the behavior of ble.sh by putting a bunch of `map ctrl+shift+<xxxx> no_op` in `.config/kitty/kitty.conf`, but I think it is useful to provide an option to turn off these kitty UI bindings when the comprehensive keyboard mode is enabled. What do you think?
|
Oh and since ble.sh is a readline substitute, you may want to add support for the upcoming shell integration in kitty, see kovidgoyal/kitty#3948 (read the shell_integration.rst docs to learn how to support it in your code) |
OK, thank you! Probably I will narrow the range to something like 4000..4009.
Hmm, actually I'm willing to switch to a new terminal-identification scheme once the standard one is settled and most terminal supports the scheme. However, it seems like the new terminal identification protocol doesn't converge well in the mintty discussion and the Terminal WG discussion (I thought XTVERSION CSI > 1 q implemented by mintty and xterm will be supported by other terminals, but still many terminals don't support them). Unfortunately, currently the terminal identification scheme that the terminals implement most is still DA2, so ble.sh uses it at present (Of course, we might combine multiple schemes, but I don't want to unnecessarily increase the round trips). Oh! Thank you for the pointer! I haven't noticed the option! This is exactly what I imagined from the prefix keys of tmux and screen.
OK! I'd later look at it. I'd expect the integration code for Bash |
You dont need multiple round trips. What you do is send all the queries you want, the last being a DA or DA2. Then you wait till you get the response for the last one. And check to see if you have responses for any others as well. So only one roundtrip is needed. And yes 4000...4009 should be fine for a long time. Though I stronly encourage you to use XTVERSION, XTGETTCAP and friends in additions to DA2 |
Ah, maybe you're right for most practical cases. The problem is that still some old terminals and kernel consoles print the unrecognized control sequences on the screen, in which case modern control sequences can be sent only when DA2 is ambiguous. Also, ble.sh (which is implemented by shell script) is slow, so I'm afraid the parsing time of many control sequences might affect the user experience on the shell startup. But, yeah, I can evaluate the impact after I implement the multiple terminal-identification sequences, but I just don't have time to test them in various terminals. Thank you for your advice. |
On Mon, Nov 22, 2021 at 10:32:38PM -0800, Koichi Murase wrote:
> You dont need multiple round trips. What you do is send all the queries you want, the last being a DA or DA2. Then you wait till you get the response for the last one. And check to see if you have responses for any others as well. So only one roundtrip is needed.
Ah, maybe you're right for most practical cases. The problem is that still some old terminals and kernel consoles print the unrecognized control sequences on the screen, in which case modern control sequences can be sent only when DA2 is ambiguous. Also, ble.sh (which is implemented by shell script) is slow, so I'm afraid the parsing time of many control sequences might affect the user experience on the shell startup. But, yeah, I can evaluate the impact after I implement the multiple terminal-identification sequences, but I just don't have time to test them in various terminals.
Just FYI, @dankamongmen recently improved the parser for the linux
kernel console and some other terminals so that he could implement
exactly this strategy in notcurses.
Thank you for your advice.
Most welcome, all the best and feel free to ping me anytime you
have any questions.
|
@kovidgoyal Thank you! |
this isn't generally a problem, because you can:
the |
@dankamongmen Thanks! Yeah, that is also a valid approach. Actually, Also, maybe I can say it is related to the current structure of ble.sh, i.e., the code to print something to the terminal and the code to identify the terminal are currently placed in different modules ( Anyway, I may implement XTVERSION, etc. if I have enough time, but the priority is currently low because there are no real problems with DA2 now. Probably, I will finally become to need to implement them in future for the proper grapheme-cluster support (cf #117), etc., where every terminal seems to have slightly different behavior as far as I have tested several months before. |
best of luck; i would recommend you simply use Notcurses, which i have zealously optimized with regards to the initial terminal detection (and most other things), but i understand your project is aiming for an all-shell implementation =]. it makes me wonder whether it would make sense to publish a little utility with notcurses which simply exported all detected capabilities (using queries or terminfo or both) in a machine-readable form, saving projects like yours the dirty work therein. would you have any interest in such a tool, or are you determined to use only your own scaffolding? |
Thank you.
I believe that would be definitely useful in general.
Specifically for ble.sh, I think I won't add dependencies on external non-POSIX tools (other than Bash). The reason for the all-shell implementation of ble.sh is that I wanted to reduce the barrier of the introduction [Sorry, I'm not sure what is the proper word choice in English] of ble.sh. So, anyway I implement necessary terminal things with shell script. Nevertheless, when ble.sh detects the Notcurses version of Oh, I think I can use the utility from Notcurses as another implementation of |
i shall hack it up, then! |
ble version: 0.4.0-devel3+750ca38
Bash version: 5.0.17(1)-release
Hello there!
I tried to use ble.sh with the kitty terminal, but when ble.sh was loaded, the terminal got messed up. Ran commands, yet I could not see any output, or any line executed..
If you want, I can try to add screenshots. In any case, I think it is easily reproducible by running kitty and loading ble.sh
In any case, this seems like a very cool project. I think about adding it as a plugin for bash-it 😄
The text was updated successfully, but these errors were encountered: