Cleaning $HOME on macOS

Apple computers ship with a custom operating system - macOS, which has a few annoying features. Among the annoyances a special place has to be reserved for the inability to remove or rename the folders located in $HOME. Here I describe my way of dealing with this problem.

Hiding default folders

If you search the net you will find countless macOS users searching for answers to the same question: “How can I get rid of ‘Desktop’, ‘Documents’, ‘Downloads’, ‘Library’, ‘Movies’, ‘Music’, ‘Pictures’, and ‘Public’ folders?” There are multitude of different suggestions given as answers to this question. You can replace the folders with files; you can hide the folders from ‘Finder’ and make them inaccessible; or you can learn to live with them, as the system will recreate those folders by itself anyway.

I decided to hide. But getting them out of view is not an easy task, specially if you are working in a command line. These folder names tend to appear in a few different contexts. From my experience, dealing with three separate instances, presented below, is quite enough.

  1. hide from Finder adding a hidden flag

    chflags hidden ~/Desktop ~/Documents ~/Downloads ~/Library
    chflags hidden ~/Movies ~/Music ~/Pictures ~/Public
    
  2. hide from ls by creating an alias in .bashrc

    alias ls='ls -I Desktop -I Documents -I Downloads -I Library\
                 -I Movies -I Music -I Pictures -I Public'
    
  3. hide from tab completion by setting a special bash FIGNORE variable.

    export FIGNORE=Desktop:Documents:Downloads:Library:Movies:Music:Pictures:Public
    

That is it, the folders should mostly be out of view. And if for whatever reason we need to temporary see them again a simple \ls would bypass the alias and provide us the full list.

Creating a new hierarchy

With the folders out of view we can now move onto creating our own home hierarchy. This part mostly depends on the needs of the user. But I would like to offer two additional points of advice. 1) using lowercase letters will offer extra protection against interference by the default folders, which all start with uppercase characters. 2) selecting the words that start with different letters will allow you to complete the folder names after typing a single character.

In my case the new hierarchy looks like this:

├── base
│   ├─── bin
│   ├─── etc
│   ├─── src
│   └─── var
│
├── desk
│
├── file
│   ├─── articles
│   ├─── books
│   ├─── documents
│   ├─── essays
│   ├─── photos
│   └─── videos
│
└── work
    ├─── active_project_one
    ├─── active_project_two
    └─── zzz
         ├─── inactive_project_one
         ├─── inactive_project_two
         ├─── inactive_project_three
         ├─── inactive_project_four
         └─── ...

'base' is my '.local'.
'desk' takes the place of the 'Desktop' and 'Downloads'.
'file' is an aggregate of 'Documents', 'Music', 'Pictures', and 'Movies'.
'work' stores various active and completed projects.

Linking Downloads and Desktop

There is one detail remaining: macOS has a useful 'Desktop' and now its hidden from us. On top of that some third party applications put various acquired data into the 'Downloads' folder. Hence, we want to see the contents of those folders within our new file hierarchy. We achieve this with symbolic links.

  1. make 'Desktop' be a symbolic link for our new folder 'desk'

    sudo rm -rf Desktop
    ln -s desk Desktop
    
  2. make 'Downloads' be a symbolic link for 'Desktop'

    sudo rm -rf Downloads
    ln -s Desktop Downloads
    

And now whenever a file is put into the, now hidden, 'Downloads' or 'Desktop' folders, it will be placed in our 'desk' instead. Moreover, since 'Desktop' is a link to 'desk', whatever is put into the 'desk' directory will be visible on the actual desktop on a screen.

The result

$ ls ~/
base desk file work

$ cd ~/D<tab>
$ cd ~/D

$ cd ~/d<tab>
$ cd ~/desk

Summary

Getting rid of default macOS home directories is hard. Hiding, instead of trying to delete, seems like an easier and safer solution. The tricks presented in this article, while not being 100% effective, go along way. I’ve been using this approach for a few years without accidentally seeing any reminder of those folders during this whole time.


  1. ◦  Answer 1 on apple.stackexchange.com

  2. ◦  Answer 2 on apple.stackexchange.com

  3. ◦  Answer 3 on discussions.apple.com

  4. ◦  Bash variable documentation on gnu.org