My Mac Terminal configuration

Mac Terminal is the Non Plus Ultra. Let me share my configuration, in particular I want to remember that font! R.I.P. Steve.

Mac

Appearance

Ok, let me get this straight: I use the Pro terminal profile. I always loved transparency effect in terminals.

Then I want a nice monospace font, possibly with ligatures. Go for FiraCode by tonsky. Font size, of course, is up to you: mine is 14 pt. Turn on Antialias text.

Another default configuration that I suggest to change is:

I often use CTRL D to close the shell, and I mean it so no confirmation is required.

Latest bash

Bash version provided by default on a Mac, at the time of this writing (with Mojave) is still 3.2. Let’s install latest! With brew do

brew install bash

Edit /etc/shells and add this line

/usr/local/bin/bash

For instance you can do something like

sudo echo /usr/local/bin/bash >> /etc/shells

Now set it as you default shell

chsh -s /usr/local/bin/bash $USER

Now quit Terminal and re-open it! Check if all ok?

echo $BASH_VERSION

Git Aware Prompt

Thanks to jimeh/git-aware-prompt you can

Display current Git branch name in your terminal prompt when in a Git working directory.

Install with the following commands

mkdir -p ~/.bash
cd ~/.bash
git clone git://github.com/jimeh/git-aware-prompt.git

Then configure it adding to your .bash_profile

export GITAWAREPROMPT=~/.bash/git-aware-prompt
source "${GITAWAREPROMPT}/main.sh"
export PS1="\u@\h \[$txtgrn\]\$git_branch\[$txtred\]\$git_dirty\[$txtrst\]\$ "

Aliases

Cannot live without these aliases

alias ls='ls -G'
alias ',,'='cd .. && pwd'
alias ','='ls -Galrth'

alias ga='git add .'
alias gd='git diff'
alias gc='git commit '
alias gl='git log'
alias gpl='git pull '
alias gps='git push '
alias gs='git status'

alias ns='npm start'
alias nt='npm test'

Other tips

Switch language shortcut

I often need to switch language since the US keyboard is the best layout in my opinion for programming, so it is useful to have a shortcut. Go to System Preferences > Keyboard > Input Sources and flag Select the previous input source.

siwtch language shortcut

This is a good solution if you needd to switch on two languages, in my case US an IT: the shortcut CTRL SPACE will do the trick.

Screen recording

When I discover it I said:

Yes, I ❤ Mac!

On Mojave you have a native screen recorder, invoke it with COMMAND SHIFT 5. It also manage screeshots.