Reputation: 1438
When I paste something into ranger with Ctrl+Shift+V I get strange characters. Here I pasted word "paste" into ranger:
And on the begining I have [200~
and at the end [201~
. I have no idea what could be the problem (ranger? fish shell? terminal? some config files?).
How to get rid of unwanted characters while pasting?
Some more info:
I use fish shell. Problem only persists when I start ranger with keyboard shortcut Ctrl+O. It works fine when I start ranger by manually entering commands ranger
or ranger_cd
or just by pasting text directly into fish shell (without starting ranger at all). Ctrl+O shortcut is defined by:
function fish_user_key_bindings
bind \co ranger_cd
end
My ranger_cd
is function:
function ranger_cd
set -l tempfile '/tmp/chosendir'
ranger --choosedir $tempfile (pwd)
if [ -f "$tempfile" ]; and [ (cat -- $tempfile) != (echo -n (pwd)) ]
cd (cat $tempfile)
end
rm -f -- $tempfile
end
(its purpose is to save last dir chosen in ranger and cd into it after exiting ranger)
I also noticed that Ctrl+V doesn't work in ranger (it pastes only ^V
), but it works properly directly in fish shell (it pastes what I copied earlier, just as Ctrl+Shift+V).
Any ideas what could be wrong? Thank you in advance. I use:
Upvotes: 4
Views: 5740
Reputation: 1790
If anyone else is searching for this and isn't using fish shell, I just realised that if I accidentally try to paste into terminal with Ctrl-V it doesn't work and then remember to paste with Ctrl-Shift-V then that next paste will have
^[[200~
at the start and ~
at the end. If I paste with just Ctrl-Shift-V it works fine.
Upvotes: 4
Reputation: 15914
That's bracketed paste mode indeed.
Fish enables it mainly to not execute multi-line pastes immediately. It disables it when you execute a command via the commandline and reenables it when you gain control again.
It's not typical to start interactive things via bindings, so fish doesn't disable it there.
To disable it manually, use __fish_disable_bracketed_paste
and __fish_enable_bracketed_paste
:
function ranger_cd
set -l tempfile '/tmp/chosendir'
__fish_disable_bracketed_paste
ranger --choosedir $tempfile (pwd)
__fish_enable_bracketed_paste
if [ -f "$tempfile" ]; and [ (cat -- $tempfile) != (echo -n (pwd)) ]
cd (cat $tempfile)
end
rm -f -- $tempfile
end
Upvotes: 6