Zsh
如何在沒有空格和特殊 shell 字元轉義的情況下顯示文件完成?
我有一堆帶空格的文件名:
[~/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),但我真的看不出有辦法做到這一點。
您始終可以鍵入
mpv '<Tab>
(並且 zsh 將完成一個帶'...'
引號的字元串)。與"
or相同$'
。如果其中有需要轉義的字元(例如'
在某些文件名中),您仍然會看到反斜杠。看起來那些
'
s 也會影響著色;可能是一個錯誤。雙引號更好: