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.
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
And regarding the Synology, it’s also usable on any Linux machine.
You can load my files from github https://github.com/brainseller/dotfiles
If you want to learn more on how to use the shell and make your own dotfiles here is an awesome article on it http://www.oliverelliott.org/article/computing/tut_unix/
If the shell is already your friend and you just want some inspiration on your own dotfiles try this article http://code.tutsplus.com/tutorials/setting-up-a-mac-dev-machine-from-zero-to-hero-with-dotfiles—net-35449
A great index of all bash and os-x specific commands can be found here http://ss64.com
macOS Catalina has switched its default shell to zsh
If you also want to make that move, you can find a great resource of information here