我有一堆带有空格的文件名:
[~/music]% ls
Acid Eater - Black Fuzz On Wheels.ogg Angel'in Heavy Syrup 4.mp3
Akalé Wubé - Akalé Wubé.opus Astor Piazzolla & Gary Burton - The New Tango.mp3
Allen Toussaint - The Bright Mississippi.mp3 B.B. King - Live at the Regal.mp3
Angel'in Heavy Syrup 1.opus Bar Kokhba Sextet - Lucifer.opus
Angel'in Heavy Syrup 2.opus Billy Bang - Vietnam the Aftermath.mp3
Angel'in Heavy Syrup 3.mp3补全为空格插入转义字符(这也意味着没有足够的空间在两列中显示它):
[~/music]% mpv <Tab>
Acid\ Eater\ -\ Black\ Fuzz\ On\ Wheels.ogg
Akalé\ Wubé\ -\ Akalé\ Wubé.opus
Allen\ Toussaint\ -\ The\ Bright\ Mississippi.mp3
Angel\'in\ Heavy\ Syrup\ 1.opus
Angel\'in\ Heavy\ Syrup\ 2.opus
Angel\'in\ Heavy\ Syrup\ 3.mp3
Angel\'in\ Heavy\ Syrup\ 4.mp3
Astor\ Piazzolla\ \&\ Gary\ Burton\ -\ The\ New\ Tango.mp3
B.B.\ King\ -\ Live\ at\ the\ Regal.mp3
Bar\ Kokhba\ Sextet\ -\ Lucifer.opus
Billy\ Bang\ -\ Vietnam\ the\ Aftermath.mp3这是有道理的,但也很难读懂;我想:
[~/music]% mpv <Tab>
Acid Eater - Black Fuzz On Wheels.ogg Angel'in Heavy Syrup 4.mp3
Akalé Wubé - Akalé Wubé.opus Astor Piazzolla & Gary Burton - The New Tango.mp3
Allen Toussaint - The Bright Mississippi.mp3 B.B. King - Live at the Regal.mp3
Angel'in Heavy Syrup 1.opus Bar Kokhba Sextet - Lucifer.opus
Angel'in Heavy Syrup 2.opus Billy Bang - Vietnam the Aftermath.mp3
Angel'in Heavy Syrup 3.mp3
[~/music]% mpv Acid<Tab>
# Completes to:
[~/music]% mpv Acid\ Eater\ -\ Black\ Fuzz\ On\ Wheels.ogg
# It's okay to type escapes on the cmdline; it's just the display.
[~/music]% mpv Angel\'in\ H<Tab>
Angel'in Heavy Syrup 1.opus Angel'in Heavy Syrup 3.mp3
Angel'in Heavy Syrup 2.opus Angel'in Heavy Syrup 4.mp3我花了一些时间阅读zshcompsys(1),但我并没有找到这样的方法。
发布于 2022-04-25 10:25:26
您可以始终键入mpv '<Tab> ( zsh将完成一个'...'引号字符串)。"或$'也是如此。如果这些字符中有需要转义的字符(比如文件名中的' ),您仍然会看到反斜杠。

看起来那些's也会影响颜色,很可能是个小虫子。双引号更好:

https://unix.stackexchange.com/questions/700276
复制相似问题