I installed zsh and oh-my-zsh.
By default, when using tab completion zsh adds a trailing space for non-folder files.
For demonstration I created the following folders/files in a folder named test_files and cded into test_files:
test_files ├── dir1 │ └── file4 ├── dir2 │ └── file5 ├── file1 ├── file11 └── file111 First, I pressed l, s, Space, Tab, Tab, Tab, *, Enter in turn and got ls dir2/* as the 1st command. Second, I pressed l, s, Space, Tab, Tab, Tab, Tab, *, Enter in turn and got ls file1 * as the 2nd command. Please see the gif picture below:
For the 2nd command, since "file1" is not a folder, a space was added between "file1" and "*".
I don't want the space added between "file1" and "*", because when I mean to delete files staring with "file1" in their names I'll possibly press r, m, Space, -, r, f, Space, Tab, Tab, Tab, Tab, *, Enter in turn, and I think the command will be rm -rf file1*, but the command will actually be rm -rf file1 * and sometimes I may press 'y' without noticing the added space, so I may delete all the folders and files by mistake. Please see the gif picture below:
I used to delete many folders and files by mistake.
I googled many days for removing that space but have not succeed.
I found add-space from zsh document pretty looks what I want, then I tried zstyle ':completion:*' add-space false, but it seems that nonthing changed.
I tried only place the following lines in my .zshrc, it still adds that space:
autoload -U compinit && compinit zmodload -i zsh/complist zstyle ':completion:*' menu select zstyle ':completion:*' add-space false If I remove zstyle ':completion:*' menu select, the space is not added, but the cursor won't traverse the folders/files when pressing the tab key, so I want to keep menu select in configs. Please see the gif picture below:
I also tried many other configs.
Thanks in advance.


