Dotfiles

What are the dotfiles?

Dotfiles are a reference for files that start with a full stop, what aims to hidden files. They are generally used for configuration.

We will focus on the files used to configure the OSX and the bash terminal (some may apply to Linux system).

To use the bash terminal, you can use the default app that comes with OSX, but I recommend to use iTerm.

If you want to take a good look, you can go to GitHub where people share their own personal configurations. I recommend you to get one of the more popular and install it, I used the Mathias’s dotfiles and I am really happy with it.

Go ahead and install personalized dotfiles. You will get a good configuration and control over many of the features of the system.

Among the ability to set up any computer with your personal settings, one of the most interesting things is the learning process you have ahead.

Later you can create your own fork like I did so you can have them saved in a safe place with your latest changes.

How to install.

At Mathias’s you can find the instructions. Here are the details.

Go to the directory where you want your dotfiles repository stored. In my case, I decided to create a hidden folder called ~/.dotfiles.

So once you are in the folder where you wish to create the dotfiles folder, you just have to clone them with git.

1
git clone https://github.com/mathiasbynens/dotfiles.git

Now we have cloned the repository and we need to get into the directory and execute the update command

1
cd dotfiles && source bootstrap.sh

Alias.

A useful feature is the ability to use your own alias. I suggest a look to the well documented .aliases, it is real easy to get used to the alias created.

if you want to create your own alias, Mathias has thought of that with the .extra file. You need to create it and add it to your dotfiles directory. They will spread with the rest of the dotfiles when you source bootstrap.sh.

Here are some of the alias I have:

1
2
3
4
alias c="clear"

# List all files and recursive directories and sort by size
alias dus='du -hs ./* | sort --n'

Bash Prompt

I like a lot how Mathias has personalized the prompt but I needed a couple of additions.

Here is my prompt:

prompt

Adding the time.

I added the time, it is not a live timer, it just prints the time when the terminal prints the prompt.

You can do this adding the following line

1
PS1+="\[${blue}\]\t "; # The time when the line was printed.

to the .bash_prompt file at the line 111 after

1
PS1+="\[${bold}\]\n"; # newline

And before

1
PS1+="\[${userStyle}\]\u"; # username

Adding the Node Version.

If you develop with Node.js, knowing the version you are using is important. I added the version you can see at the end of the prompt.

To do it you can add a couple of lines

1
PS1+=" ⬡ \$(node -v)" # Node version

At the place where you want to see the node version, in my case I have it in the last place, so I add it before the line 117

1
PS1+="\n";

I hope this will help you. However if you have any doubts, please don’t hesitate to drop me a line.

bye.