Closed danfe closed 6 months ago
Hi @danfe! Thanks for reporting. Those are bracketed paste escape codes, so I'm pretty sure (though I've haven't reproduced the issue) that the thing is related to readline's config. Try this:
Edit readline's config file (~/.config/clifm/readline.clifm
) and disable enable-bracketed-paste
as follows:
set enable-bracketed-paste off
Or just comment out the line.
Restart clifm.
set enable-bracketed-paste off
This worked, thanks, nice and quick fix, albeit well-behaved programs should not leave the terminal in a troubled state regardless of the settings. :-)
Or just comment out the line.
This didn't work for some reason (tried it first).
Great! To be honest, I don't remember why this setting was set to on by default (indeed, the comment above -I mean, in the config file, clearly says "disable").
With the latest commit, bracketed-paste is disabled by default.
Thanks (referenced commit is fec3892). FWIW, issuing printf '\033[?2004l'
can help one to disable bracketed paste mode if their terminal ended up in it for whatever reason.
well-behaved programs should not leave the terminal in a troubled state regardless of the settings
@danfe, you're right of course. Could you please give the following a try?
The latest commit makes clifm reset the terminal to its previous state immediately before quitting.
Make sure the issue is gone.
Hmm, it's not gone, I still need to reset the terminal by hand.
Ok. I'm using tcsetattr(3) to reset the terminal to its original state, saved at startup. This works fine and gives us a more consistent behavior. I guess thereby that this bracketed paste thing is a readline-specific feature/issue (maybe some readline internal function might work, but I'm not sure).
Of course, I can always print \033[?2004l
at exit -as you suggested- to disable the feature (as far as I know this is what the nano
editor does). But, to make this the right way I should find out first whether the running terminal supports it, and secondly, print it only if the feature was actually enabled.
I'll keep this in mind. For the time being, keeping the thing off by default is quite safe.
For the time being, keeping the thing off by default is quite safe.
Fair enough, I agree.
Be it as it may, I still need to reproduce the issue. Could you please report the exact steps you take? How are you pasting to the terminal from the clipboard?
Running FreeBSD/amd64 14.0, Clifm 1.16.1 (tried also 1.14.6), on XTerm 385.
Personally, I'm using this on my .Xresources
:
XTerm*VT100.Translations: #override \
Ctrl Shift <Key>V: insert-selection(CLIPBOARD) \n\
Ctrl Shift <Key>C: copy-selection(CLIPBOARD)
I can copy to the clipboard via Ctrl-C as always (in Leafpad, say) or with Ctrl-Shift-C in XTerm itself, and then Ctrl-Shift-V, either on clifm itself or, after exiting, on XTerm: works fine in both cases.
How are you pasting to the terminal from the clipboard?
I select the text with LMB, it goes to X11 primary selection buffer (others are: clipboard, secondary, buffer-cut). In the example below, I double-click on the word "true":
$ true
$ xclip -selection primary -o
true$ _
The above xclip(1) command yields the same result as clicking the MMB or pressing Shift-Insert. Now, if I run and exit CliFM:
$ true
$ xclip -selection primary -o
true$ hd
^[[200~true^[[201~
00000000 1b 5b 32 30 30 7e 74 72 75 65 1b 5b 32 30 31 7e
Interestingly, xclip(1) returns undecorated string, but not when pasting with keyboard or mouse. That being said, I do have a bunch of non-standard XTerm-related settings in my ~/.Xdefaults
, I'll redo the tests in clean environment.
Reproduced! It depends on how you exit clifm though: it happens when you exit with Ctrl-D or F12, but not with the q/quit/exit
command. Briefly put, the issue is triggered when you exit via a keybinding.
it happens when you exit with
Ctrl-D
orF12
, but not with theq/quit/exit
command.
Confirmed (I always exit with ^D
from everywhere so long it's supported).
We're on the right track, very close! Give me a few minutes.
Done! Give it a try now.
Yup, commit 2262496 no longer exhibits the problem for me, thanks!
Thanks for your help @danfe! Closing.
I've noticed that after quitting CliFM, text in the clipboard would be pasted as
^[[200~SOME-TEXT^[[201~
where^[
is your usual ESC\033
. This makes it hard to work with (on command line, in the editor it's just unusable). Naïve tricks liketput reset
orstty sane
do not bring the terminal back to normal, however, starting and quittingmc
(Midnight Commander) does. This is observed on FreeBSD/amd64 13.2, CliFM 1.16 (1.15 as well), and XTerm 382.