2

I have a bunch of filenames with spaces:

[~/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

Completion inserts escape characters for the spaces (which also means there isn't enough space to display it in two columns):

[~/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

This makes sense, but also hard to read; I would like:

[~/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

I spent some time reading through zshcompsys(1), but I don't really see a way to do this.

2
  • You can always type mpv '<Tab> (and zsh will complete a '...' quoted string). Same with " or $'. You'll still see backslashes if there are characters that need escaping in those. Commented Apr 25, 2022 at 10:11
  • Aha, I didn't know about that @StéphaneChazelas; somehow I never expected completion to work inside quotes, but it's smarter than I thought. It's a fine solution for me. Commented Apr 25, 2022 at 10:20

1 Answer 1

1

You can always type mpv '<Tab> (and zsh will complete a '...' quoted string). Same with " or $'. You'll still see backslashes if there are characters that need escaping in those (like the ' in some of your filenames).

screen shot with single quotes

Looks like those 's also affect the colouring; likely a bug. Better with double quotes:

screen shot with double quotes

1
  • Bash is also able to do that.
    – user232326
    Commented Apr 25, 2022 at 23:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .