After migrating my dotfiles over to Mac M3 I stumbled into roadblock issue for my neovim setup. Every time I saved a PHP file, a lot of garbled data got prepended at the beginning of said file. If you remember so far back, my setup uses prettier for formatting everything, mostly via coc-prettier, but since @prettier/plugin-php is just a plugin anot not part of the mainline, I use vim-prettier specifically only for .php files. The setup works well for my needs, required little to no tweaking once it gotten to place.

So back to the garbage, it looked exactly like this:


// rest of the file ...

Here a verbatim output of the ChatGPT that explains what the sequences mean, as I could not provide such information by heart, not even produce a relevant search query:

  • ]4;N;rgb:RR/GG/BB ␇ sets the color for palette entry N to the specified RGB color
  • ]10;rgb:RR/GG/BB ␇ sets the foreground (text) color
  • ]11;rgb:RR/GG/BB ␇ sets the background color

And examples of the above:

  • ]4;1;rgb:cc/24/1d ␇ sets color 1 to RGB(204, 36, 29)
  • ]10;rgb:eb/db/b2 ␇ sets the text color to RGB(235, 219, 178)
  • ]11;rgb:28/28/28 ␇ sets the background color to RGB(40, 40, 40)

Pinpointing the issue

To be fair, I have spent quite a lot of time pinpointing this issue, but it was quite fun, to be honest. Part of my switch from Arch to Mac was changing zsh to fish shell. I cannot tell right now if that was a good or a bad decision, and also if the timing was correct, but this probably deserves a separate article.

First thing I tried was getting sure the issue is somehow really connected to prettier as it was only my unverified thought at this point. After commenting out my "autosave" line in my ~/.config/nvim/init.vim:

autocmd BufWritePre *.php PrettierAsync

The garbage was not present at the beginning of the file, but running :PrettierAsync in neovim manually produced it again. As you can see, this made the prettier for PHP completely unusable. Thus I tested if native Prettier formats did the same. But the result was negative. Fixing formatting for example markdown .md file did not produce any garbage. This made me pretty confident that the issue lies in plugin-php, thus I tried it manually:

npx prettier --write file.php

To my great surprise, there was no garbage in such file. I was out of lead at this point, so I went on a looked for any open issues in these tools, but nothing produced any results. Also, as I said already, it is very hard to produce relevant search query for such issue.


After poking around a little longer, I tried running the above directly in neovim via execute using :!

:!npx prettier --write %

This produced a surprise as the exact same garbled data were in the result (and not yet in the file). I had another hint, but still not sure what exactly was causing the issue. I still thought plugin-php was the culprit at this point, results of my tests:

  • neovim with my config in fish produced issue, but in zsh and bash tools
  • neovim with -u NONE (no extra config) produced the issue in all three shells
  • pure vim in any shell did not produce the issue, another hint

Since plugin-php did not produce issue via npx directly, nor in vim and only in neovim, I shifted my focus there. I was still clueless as running it in any shell and even without my config produced the issue. There was no recent neovim update, I was running v0.9.5 for some quite time, even though v0.10.0 was released three days ago, I have not yet updated there as there are some breaking changes announced and I could not be sure if they affect me or not. Better wait a week or two for the most obvious bugs get ironed out.

The lead

I have no idea how it occured to me, maybe out of desperation, but I tried running the following:


This produced the same garbage before the actual ls output in neovim. Gotcha, the problem did not lie in prettier nor plugin-php at all! Now funnily the search term vim dumb shell got me to this stackoverflow answer that had an actual solution to my problem.

Adding this statement into my init.nvim:

set shell=/bin/bash

Produced no garbage. I believe the problem is in fish shell color formatting. Neovim probably reads the default shell and uses it inside, no matter which shell it is being run from. Enjoy!