the corner office : tech blog

a tech blog, by Colin Pretorius

Caja File Sorting

I've been playing with MATE. Long story.

Caja does clever sorting of directories and files, so if you have a directory with an underscore, a la _todo, then Caja just sorts it inline. The reason I put the underscore there in the first place is to list it at the top. This annoyed me 10 years ago with Nautilus, has annoyed me regularly with Thunar, and annoyed me enough tonight with Caja to see if I could fix it.

Upshot: you can indeed fix it, by putting export LC_COLLATE=C into .profile.

Details: Caja sort order relies on the LC_COLLATE environment variable to determine sort order. The fancy sorting comes from the standard UTF_8 setting. Setting LC_COLLATE=C gives the more obvious strcmp() style sorting. This is covered in eg. this SO post and a few others.

The messy part was finding out where to set the environment variable. Some places which don't work:

  • .bashrc works for console sorting, where the same issue was happening, but not for Caja.
  • .gnomerc was mentioned in a few older online posts, but MATE no longer reads this.
  • I also saw mention of setting this in /etc/profile.d but that seems like overkill.

Update: after all that I discovered that setting the locale this way causes files and directories which start with capital letters to come before all files and directories starting with punctuation and lower-case. Grrr.

{2018.09.26 22:39}

« Linux Desktops circa 2018

» .Net 5