The Terminal (the shell) was always a fascinating place for me. But except writing some defaults, where I knew what I did from programming Cocoa apps, it was some kind of magic when I just typed in some commands I found on the web and it did what it should do, without me knowing what I really do.

A few weeks ago I bought a Synology NAS and while those magical little boxes are really easy to set up, you can do some advanced stuff if you ssh into them.
One of the reasons I did not only buy a cheap NAS but a more expensive Synology, was that I expected to learn a bit more about server administering and configuration. And I really did, but much more I learned about the shell and learned to feel comfortable in it.

Whenever I opened up Photoshop to do some batch image resizing, or Forklift for simple batch renaming, or just the Finder for moving some files around, I now open up Terminal (or iTerm most of the time) to finish those tasks.
As a designer I always try to optimise and customise the tools I work with and I learned much about the shell in doing so with my terminal. That’s where .dotfiles enter the game.

.dotfiles 101

Whenever you open a new shell (bash in my case) it loads up some files where you could tell it how it should look like and behave. For bash that’s .bashrc and/or .bash_profile. You noticed the dot in front of the filename? That's an UNIX convention for hidden or system files. Thats the reason for the name dotfiles.
I have to admit, I don’t know which one of these two files is prioritised, but as on my machine there was only a .bashrc and most online articles on this topic worked with the .bash_profile, I put my setup into .bash_profile and made sure that .bashrc sources (loads) it.
The things you want to tell your bash, among other things, are the look of the prompt, aliases for shortening long commands that you use regularly, or functions which work as more advanced aliases, where you can chain multiple commands. I for example use very often a function where a simple „gup“ (for git update) fires up the whole chain of git commands to add, commit, pull and push all the changes of my current working directory. (Especially Git is a great example of something, that is much better manageable with your command line, than with any GUI client.)

Now you could enter all your settings, aliases and functions into this file, but then it’ll be long and hard to maintain. Also I want to do the work only once and make it easy to use it on every machine I put my hands on. Therefor I followed the common practice of putting things like prompt styling and behaviour, like autocompletion etc., into a settings file, aliases into an aliases file and functions into a (you guessed it) functions file. In .bash_profile I just load them and echo it out if they were found.
As I wanted to share my dotfiles on github, I also made an "extras" file with aliases and functions that would expose private data if shared and that is not found in my public repository.

Now whenever I work on a new Mac, it's a thing of a minute till my Terminal looks like this

my terminal

And regarding the Synology, it's also usable on any Linux machine.


You can load my files from github

If you want to learn more on how to use the shell and make your own dotfiles here is an awesome article on it

If the shell is already your friend and you just want some inspiration on your own dotfiles try this article

A great index of all bash and os-x specific commands can be found here


macOS Catalina has switched its default shell to zsh
If you also want to make that move, you can find a great resource in the article moving to zsh.

Update 2:

As I migrated my blog to 11ty, there are no comments anymore. TODD commented back on 15. March 2018

You said, “I don’t know which one of these two files is prioritised, but as on my machine there was only a .bashrc and most online articles on this topic worked with the .bash_profile, I put my setup into .bash_profile and made sure that .bashrc sources (loads) it.”

.bashrc is executed if the shell is not a login shell, i.e. it’s not displaying a prompt to you.
.bash_profile is executed if the shell is a login shell.

Comme ci comme ça, as they say, except that you have to be careful not to set something in a file that does something interactive with a user, and then load that file in a non-login shell, where nobody is present to do anything. So, it’s better to have your .bash_profile load your .bashrc than the other way around. Then you can keep all your strictly non-login stuff in .bashrc and use your .bash_profile for anything, and there’s no chance you’ll accidentally cause yourself a problem.