The first step is to install a compiler. The easiest way to install one is with the Xcode Command Line Tools package. So, to >do that, we need to open a terminal, and enter the following command …
xcode-select --install
Please note: This article assumes that you are configuring a MAC.
First thing is to install Homebrew.
If you don’t trust the command below, then please navigate to https://brew.sh
, and copy the install command, and paste that into your terminal.
Here it is:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
MacOS uses an older version of bash — the short version is that Apple won’t ship anything that’s licensed under GPL v3 on OS X. All you really need to know is the default version of bash on MacOS is v3.2 and you may want to upgrade to the latest version to take advantage of new features (v5, at time of writing).
More information on that here
bash -v // should get 3.2
brew install bash
Close your terminal, then open it back up, (or type exec $SHELL
) and type:
bash -v // you should get the newest version.
5.2 at the time of this writing.
We need to edit /etc/shells by adding the new bash to it, and then we need to make the newest version of bash our default shell.
The following code will add the new bash terminal to /etc/shells and then change to the new shell.
sudo sh -c 'echo /usr/local/bin/bash >> /etc/shells'
chsh -s /usr/local/bin/bash
Very Important : create .bash_profile, and edit it (unless you already have one).
touch .bash_profile
// Then add this code to the top:
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
Below this code, you need to add your path to your .bash_profile
To get your path, enter this code inside your terminal:
echo $PATH
renders: /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
now add that underneath the if statement inside your .bash_profile like this:
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
save the file, and then in the terminal enter: source ~/.bash_profile
on the terminal. This saves changes.
brew install iterm2 --cask
Zsh is a shell designed for interactive use, although it is also a powerful scripting language.
By default, macOs ships with zsh located in/bin/zsh. Let’s install zsh using brew and make iTerm2 use it.
brew install zsh
chsh -s which zsh
Oh My Zsh is an open source, community-driven framework for managing your zsh configuration.
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
Check the installed version
zsh --version
You can upgrade it to get the latest features it offers by entering the following command:
upgrade_oh_my_zsh
Restart iTerm2 to dive into the new experience of using Zsh. Now you are beginning to be a real CLI badass …
Oh My Zsh comes bundled with a lot of themes. The default theme is robbyrussell, but you can change it to any theme of your choice. In this scenario, I changed it to agnoster, an already pre-installed theme.
You then need to select this theme in your ~/.zshrc. To open the config file (.zshrc), run the command:
sudo nano ~/.zshrc
Once you have made agnoster the theme by modifying this line: ZSH_THEME=”agnoster” we need to install the powerline fonts.
I will be using Inconsolata. Get your preferred font out of these powerline fonts. Then, download and install it, or enter the following commands.
git clone https://github.com/powerline/fonts.git
cd fonts
./install.sh
To change the font, navigate to iTerm2 > Preferences > Profiles > Text > Change Font
.
Now, you can see Inconsolata listed as one of the fonts. Select your preferred font. For fonts that support ligatures like FiraCode, check the “Use ligatures” option to view your arrows and other operators in a stylish manner like ( → ).
Select a powerline font. I use Inconsolata-dz for Powerline.
Make sure to toggle Use ligatures, and Anti-aliased
This one is new for most people and it blew everyone's mind at work. It's called zsh-syntax-highlighting, inspired by Fish's syntax highlighting (another shell). It tells you if a command is valid before you hit the enter key.
To install it run:
cd ~/.oh-my-zsh && git clone git://github.com/zsh-users/zsh-syntax-highlighting.git
All that's left is enabling it. Fire up that editor again and open ~/.zshrc and add the following line to the end of the file.
source ~/.oh-my-zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
Restart your terminal or run source ~/.zshrc for the changes to take effect.
No this is not a typo, the last thing I want to show you is z. A script that makes navigating in the terminal much faster. On a mac you can just do brew install z. For Linux machines refer the the GitHub repo.
Once you've installed it, add the following to your .zshrc (including the . at the beginning).
. `brew --prefix`/etc/profile.d/z.sh
That was the last time I made you edit your .zshrc, seriously though !
Instead of doing cd ~/Somefolder/Anotherfolder/project/, you can just do z proj. It's that simple! Keep in mind that z is not a magic script that knows where every folder on your computer is. It keeps track of your cd to directories in a file called ~/.z - Once you've cd'd into a directory once, you can use z to navigate to it.
If you want to investigate, and add more plugins, please see this Github page: https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins
Now, we need to install NVM.
brew install nvm
Homebrew will automatically add the following code to your .bash_profile
export NVM_DIR="$HOME/.nvm"
[ -s "/usr/local/opt/nvm/nvm.sh" ] && . "/usr/local/opt/nvm/nvm.sh" # This loads nvm
[ -s "/usr/local/opt/nvm/etc/bash_completion" ] && . "/usr/local/opt/nvm/etc/bash_completion" # This loads nvm bash_completion
But please check it … if it doesn’t add it, then you have to so that NVM is available globally.
Now we can install our first version of node! Your mac may already have a version preinstalled, but we are going to install the latest stable release, and set it to the default whenever a new terminal is started.
nvm install stable
nvm alias default stable (this is the latest, please research the most appropriate version for your work)
That’s it!!
Christian