Kos*_*sak 3 linux terminal copy-paste fish
当我将某些内容粘贴到Ranger中时,Ctrl+Shift+V我会得到奇怪的字符。这里我将“粘贴”一词粘贴到 Ranger 中:
在开始时我有[200~,在结束时我有[201~。我不知道可能是什么问题(ranger?fish shell?终端?一些配置文件?)。
粘贴时如何去掉不需要的字符?
更多信息:我用鱼壳。仅当我使用键盘快捷键启动 Ranger 时,问题仍然存在Ctrl+O。ranger当我通过手动输入命令或ranger_cd直接将文本粘贴到 Fish shell 中(根本不启动 Ranger)来启动Ranger 时,它工作得很好。Ctrl+O快捷方式定义为:
function fish_user_key_bindings
bind \co ranger_cd
end
Run Code Online (Sandbox Code Playgroud)
我的ranger_cd功能是:
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
Run Code Online (Sandbox Code Playgroud)
(其目的是保存在 Ranger 中选择的最后一个目录,并在退出 Ranger 后将其 cd 到其中)
我还注意到这Ctrl+V在 ranger 中不起作用(它只粘贴^V),但它直接在 Fish shell 中正常工作(它粘贴我之前复制的内容,就像Ctrl+Shift+V)。
有什么想法可能是错的吗?先感谢您。我用:
这确实是括号粘贴模式。
Fish主要使它不立即执行多行粘贴。当您通过命令行执行命令时,它会禁用它,并在您再次获得控制权时重新启用它。
通过绑定启动交互式事物并不常见,因此 Fish 不会在那里禁用它。
要手动禁用它,请使用__fish_disable_bracketed_paste和__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
Run Code Online (Sandbox Code Playgroud)