Skip to content

Instantly share code, notes, and snippets.

@jcasadella
Last active September 9, 2021 15:55
Show Gist options
  • Save jcasadella/b8c73489330edcd250bd0eb2d006a6ab to your computer and use it in GitHub Desktop.
Save jcasadella/b8c73489330edcd250bd0eb2d006a6ab to your computer and use it in GitHub Desktop.
Bootstrap Mac

Remove all installed versions of IntelliJ IDEA for MacOS

There's an oficial documentation with the paths where all files are stored, but not enough: https://www.jetbrains.com/help/idea/tuning-the-ide.html?_ga=2.212787218.746653765.1596784189-1872990392.1561121338#logs-directory

Complete list of commands to clean all previous IntelliJ IDEAs:

rm -rf ~/Library/Application\ Support/JetBrains/Idea*

rm -rf ~/Library/Application\ Support/IdeaIC*
rm -rf ~/Library/Application\ Support/Intelli*
rm -rf ~/Library/Preferences/IntelliJ*

rm -rf ~/Library/Application\ Support/Intelli*
rm -rf ~/Library/Caches/JetBrains/Idea*
rm -rf ~/Library/Logs/JetBrains/Idea*

rm -rf /Applications/IntelliJ\ IDEA\ CE.app/

rm -rf ~/.idea-build

rm -rf ~/Library/Preferences/Idea*
rm -rf ~/Library/Logs/Idea*
rm -rf ~/Library/Caches/Idea*

Terminal

Watch

brew install watch

Example to execute every 5 seconds a command highlighting the differences

watch -n5 --differences <COMMAND>

BAT

Better cat

brew install bat

Set alias to replace cat

echo "alias cat='bat'" >> .zshrc

JSON tools

Create a JSON

brew install jo

Usage: jo var1=foo var2=2.5

Print JSON

brew install jq

Usage: cat foo.json | jq .

Documentation

tldr

A replacement for man pages

brew install tldr

Languages

Java 8

See: https://sdkman.io/

Scala

Install SBT

sdk install sbt

(Optional) Configure Artifactory credentials

Add these lines to your .zshrc (or .bashrc)

export ARTIFACTORY_USER=<USERNAME>
export ARTIFACTORY_PWD=<PASSWORD>

launchctl setenv ARTIFACTORY_USER $ARTIFACTORY_USER
launchctl setenv ARTIFACTORY_PWD $ARTIFACTORY_PWD

Python

brew install pyenv
echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n  eval "$(pyenv init -)"\nfi' >> ~/.zshrc

Prevent Python from writing .pyc files

echo "# Prevent Python from writing .pyc files" >> ~/.zshrc
echo "export PYTHONDONTWRITEBYTECODE=1" >> ~/.zshrc

Install Zlib, required for some packages to be installed

brew install zlib

Add this flags to ~/.zshrc:

# For compilers to find zlib you may need to set:
export LDFLAGS="${LDFLAGS} -L/usr/local/opt/zlib/lib"
export CPPFLAGS="${CPPFLAGS} -I/usr/local/opt/zlib/include"

# For pkg-config to find zlib you may need to set:
export PKG_CONFIG_PATH="${PKG_CONFIG_PATH} /usr/local/opt/zlib/lib/pkgconfig"

In case of trouble, pyenv recommends installing these packages for MacOSX:

brew install readline xz

List all Python versions and example of installation

pyenv install --list
pyenv install 3.6.8
pyenv install 2.7.15

Select version

pyenv versions
pyenv global 3.6.8

Create virtualenv

brew install pyenv-virtualenv
pyenv virtualenv 2.7.15 venv
pyenv activate venv

More info: https://github.com/pyenv/pyenv-virtualenv

Other tools

Install asdf

brew install asdf
echo 'source /usr/local/opt/asdf/asdf.sh' >> ~/.zshrc

Install different versions of kubectl

asdf plugin-add kubectl https://github.com/Banno/asdf-kubectl.git
asdf list-all kubectl
asdf install kubectl 1.9.11
asdf global kubectl 1.9.11
asdf current kubectl

Other Kubernetes tools

brew cask install minikube
brew install kubernetes-helm
brew cask install lens

Fubectl: An improved kubectl

https://github.com/kubermatic/fubectl

AWS

brew install awscli

Tmux

brew install tmux

Persist Tmux sessions

Install tmux-resurrect.

Final ~/.tmux.conf file

# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'

# https://github.com/tmux-plugins/tmux-resurrect
set -g @plugin 'tmux-plugins/tmux-resurrect'

# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'

Configure mouse scroll in Tmux

To use your mouse in this mode (called copy mode) press ^b + : and enter following:

setw -g mouse on

Info from: https://superuser.com/questions/210125/scroll-shell-output-with-mouse-in-tmux

Setup terminal in Mac

Credit to: https://medium.com/the-code-review/make-your-terminal-more-colourful-and-productive-with-iterm2-and-zsh-11b91607b98c

Install Homebrew

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

iTerm2

Using iTerm2 instead of the default MacOS Terminal.

brew install --cask iterm2

Zsh

Install Zsh

brew install zsh

Set Zsh as default

chsh -s /bin/zsh

Add syntax highlighting and auto suggestions

brew install zsh-syntax-highlighting
brew install zsh-autosuggestions

Nerd fonts

Install Nerd fonts using brew

brew tap caskroom/fonts
brew cask install font-hack-nerd-font

Setup Nerd font

iTerm2 -> Preferences -> Profiles -> Text -> Font -> Change Font -> Hack Regular Nerd Font Complete

Powerlevel9k

Define nerd font for powerlevel9k

echo "POWERLEVEL9K_MODE='nerdfont-complete'" >> ~/.zshrc

Install Powerlevel9k

mkdir ~/cli
git clone https://github.com/bhilburn/powerlevel9k.git ~/cli/powerlevel9k
echo 'source  ~/cli/powerlevel9k/powerlevel9k.zsh-theme' >> ~/.zshrc

Complete ~/.zshrc file:

POWERLEVEL9K_MODE='nerdfont-complete'
source  ~/cli/powerlevel9k/powerlevel9k.zsh-theme

# Customise the Powerlevel9k prompts
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ssh dir_writable dir vcs)
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status root_indicator background_jobs command_execution_time)
POWERLEVEL9K_PROMPT_ADD_NEWLINE=true
POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=3
POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=2

# Load Zsh tools for syntax highlighting and autosuggestions
HOMEBREW_FOLDER="/usr/local/share"
source "$HOMEBREW_FOLDER/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
source "$HOMEBREW_FOLDER/zsh-autosuggestions/zsh-autosuggestions.zsh"

For more prompt elements see https://github.com/bhilburn/powerlevel9k#available-prompt-segments

Color themes

Color schemes defined here: https://iterm2colorschemes.com/

iTerm -> Preferences -> Profiles -> Colors -> Color Presets -> Import

Color your ls with an alias to ls -G

echo "alias ls='ls -G'" >> ~/.zshrc

Syntax highlighting in vim

echo syntax on >> ~/.vimrc

Add history

Configure history limit (default=0), history file and other params. Credit to https://gist.github.com/matthewmccullough/787142 Add to .zshrc:

# History
HISTSIZE=5000               #How many lines of history to keep in memory
HISTFILE=~/.zsh_history     #Where to save history to disk
SAVEHIST=5000               #Number of history entries to save to disk
#HISTDUP=erase               #Erase duplicates in the history file
setopt    appendhistory     #Append history to the history file (no overwriting)
setopt    sharehistory      #Share history across terminals
setopt    incappendhistory  #Immediately append to the history file, not just when a term is killed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment