Mac-Configuration

This is collections/ways to configure mac for development

View on GitHub

forthebadge But it is forthebadge

Configurations



:arrow_up:

Iterm2/Terminal configurations

Note: Make sure you have local admin rights before you proceed with the following installations.

Following site will help you setup your mac.

  1. Install iterm2 from https://www.iterm2.com/ and Install Homebrew from https://brew.sh/

  2. Install software listed in file brew-leaves.txt
    brew install $(< brew-leaves.txt)

  3. Add theme to iterm2: Oh-my-Z
    sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)""

  4. Add additional plugins, themes and fonts to iterm2

    Zsh plugins

    You can add additional plugins in zsh at .oh-my-zsh/custom/plugins location

    cd $ZSH/custom/plugins;git clone https://github.com/zsh-users/zsh-syntax-highlighting.git && git clone https://github.com/zsh-users/zsh-autosuggestions && git clone https://github.com/zsh-users/zsh-completions
    
    Install Fonts

    source-code-pro

    powerline fonts

    awesome-terminal-fonts

    nerd-fonts

    nerd-fonts

  5. Install powerlevel9k theme(choose Option 2: Install for Oh-My-ZSH) https://github.com/bhilburn/powerlevel9k/wiki/Install-Instructions#step-1-install-powerlevel9k
  6. Update .zshrc file as show in here
  7. change fonts for iterm2: iTerm2 -> Preferences -> Profiles -> Text -> Font -> Change Font to hack-nerd
  8. Execute compaudit | xargs chmod g-w,o-w /usr/local/share/zsh ;compaudit | xargs chmod g-w,o-w /usr/local/share/zsh/site-functions
  9. change font settings as shown in image
    image
  10. Vim Customization
git clone https://github.com/amix/vimrc.git ~/.vim_runtime && sh ~/.vim_runtime/install_awesome_vimrc.sh
  1. Customize iterm2 shortcut
    image

⌘← “SEND HEX CODE” 0x01
⌘→ “SEND HEX CODE” 0x05
⌥← “SEND ESC SEQ” b
⌥→ “SEND ESC SEQ” f

  1. Bonus: If you want terminal app to be similar to iterm2 do following settings
    • terminal -> preference -> Basic theme ->Background -> change color from white to black,
    • Text -> change color from black to white
    • Font -> change for to Hack bold nerd font

More info:

nicolashery/mac-dev-setup

donnemartin/dev-setup

sourabhbajaj/mac-setup/

andreafrancia/trash-cli

pimpyourterminal/blob/master/.zshrc

zsh-users

help.github

Following are other changes require to make iterm more customizable and solutions to some problem I have encountered so far.

Get better version of man pages

https://tldr.sh/

Install Ruby
brew install rbenv ruby-build

# Add rbenv to bash/zsh (.bash_profile/.zshrc) so that it loads every time you open a terminal
echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile
source ~/.bash_profile

echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.zshrc
source ~/.zshrc

# If you're using Zsh
echo 'export PATH="$HOME/.gem/ruby/2.7.2/bin:$PATH"' >> ~/.zshrc
echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.zshrc

# If you're using Bash
echo 'export PATH="$HOME/.gem/ruby/2.7.2/bin:$PATH"' >> ~/.bash_profile

# Install Ruby
rbenv install 2.7.2
rbenv global 2.7.2
ruby -v

rbenv rehash

# to check outdated gems
gem outdated

#update all outdated gems
sudo gem update

# delete older gems
sudo gem cleanup

The first thing you want to do after installing a new Ruby version is to install Bundler.
This tool will allow you to set up separate environments for your different Ruby projects, so their required gem versions won’t conflict with each other.
Install Bundler with:

gem install bundler

In a new Ruby project directory, create a new Gemfile with: like venv of python environment
bundle init

Make ls, ll commands colorful

colorls

$sudo gem install colorls

or faster than colorls:

exa

brew install exa

Snapshots of my configurations:

+ — uncommitted changes in the index;
! — unstaged changes;
? — untracked changes;
$ — stashed changes;
⇣ — unpulled commits;
⇡ — unpushed commits

normal-prompt

auto-complete

command-failure-status:

terminate-command-on-failure-status

ll-and-ls-commands

Following are some alternatives to colorls

ogham/exa

Peltoche/lsd

powerlevel10k on top of powerlevel9k

This is optional setup and can be easy to change to and fro from powerlevel9k to powerlevel10k

Only change you need to do is

  1. Clone powerlevel10k sourcecode
    git clone https://github.com/romkatv/powerlevel10k.git ~/.oh-my-zsh/custom/themes/powerlevel10k
    
  2. Add powerlevel10k theme to .zshrc file and comment powerlevel9k
    #ZSH_THEME="powerlevel9k/powerlevel9k"
     ZSH_THEME="powerlevel10k/powerlevel10k"
    
  3. source the zsh config file
    source ~/.zshrc
    
  4. If you still need to configure powerlevel10k, you can execute following command and choose suitable options for you
p10k configure
  1. If you want to use older setup, just change the theme to powerlevel9k and
    mv ~/.p10k.zsh ~/.p10k.zsh.bak
    

    Minor difference compare to previous setup

  2. No longer print status bar on enter command
  3. git status difference, we get total number of unstaged, untracked files, here 5 unstaged files and 13 untracked files
  4. if previous command’s return status was success/error then subsequent enter will be in green/red respectively as shown below

Other customizations you can try:

  1. https://denysdovhan.com/spaceship-prompt/

:arrow_up:

iterm2 color theme

The color scheme I have used in above iterm2 snapshots is here

If you need different color schemes then you can ref


:arrow_up:

Terminal File Manager

Installation:

brew install nnn

OR
Refer installation instructions from here
OR
This will add icons to directories and files
Note: Nerd fonts should be installed and configured.

wget https://github.com/jarun/nnn/archive/refs/heads/master.zip
tar -zxvf master.zip
cd nnn-master/
# Not Zero, but Alphabet O, you will get binary nnn in same folder and you can move this bonary to the place you want and use it.
sudo make O_NERD=1

# Since I have install nnn with homebrew and it does not give any colors and icons, so  compiled it manually and replaced nnn binary file
sudo cp nnn /usr/local/Cellar/nnn/4.0/bin/
nnn -de

image

Plugins

curl -Ls https://raw.githubusercontent.com/jarun/nnn/master/plugins/getplugs | sh

Plugins are installed to ${XDG_CONFIG_HOME:-$HOME/.config}/nnn/plugins.

Add active plugin list to .zshrc/.bashrc file

export NNN_PLUG='f:finder;o:fzopen;p:mocplay;d:diffs;t:nmount;v:imgview'

Ref:

:arrow_up:

Python setup

brew install python@3

info:

Python has been installed as
  /usr/local/bin/python3

Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
`python3`, `python3-config`, `pip3` etc., respectively, have been installed into
  /usr/local/opt/python/libexec/bin

If you need Homebrew's Python 2.7 run
  brew install python@2

You can install Python packages with
  pip3 install <package>
They will install into the site-package directory
  /usr/local/lib/python3.7/site-packages

brew install python@2

Virtual Environment for python

It offers flexibility in isolating multiple python environment and does not interfer with other virtual environment
Package installed in one virtual environment will not be visible in other virtual environment
Package installed in virtual environment will not be installed system wide hence it will not be available to all programs which uses system python setup.

System python installation path
/System/Library/Frameworks/Python.framework/

Homebrew installed python path
/usr/local/Cellar/python/<version>/

Let us us python3 for virtual environment
pip3 install virtualenv

Setup virtual environment at any location, lets setup at home directory
virtualenv -p python3 ~/virtEnvPy3

Activate virtual environment

cd ~/virtEnvPy3
source bin/activate

Install any package for above virtual environment from terminal
pip install flask

Deactivate environment deactivate

on similar line we can create virtual environment for python2 as well

Now, if you want to extract which all packages you installed

pip2 freeze > requirements-2.txt
# OR
pip3 freeze > requirements-3.txt

If you want to install all packages from requirements.txt

pip2 install -r requirements.txt
#OR
pip3 install --user -r requirements.txt
# pip3 install help
# --user --> Install to the Python user install directory for your platform.  
# Typically ~/.local/, or %APPDATA%\Python on Windows.  
# (See the Python documentation for site.USER_BASE for full details.

:arrow_up:

GO setup

brew install golang or brew install go check version go version

Environment variables

Your Go working directory (GOPATH) is where you store your Go code/additional libraries. It is not mandatory to have your code at go-workspace. It can be any path you choose but must be separate from your Go installation directory (GOROOT).

mkdir ${HOME}/go-workspace
# GO projects/program will be stored
mkdir ${HOME}/go-workspace/src
# packaged object will be stored  
mkdir ${HOME}/go-workspace/pkg
# compiled binary files will be stored  
mkdir ${HOME}/go-workspace/bin

export GOPATH="${HOME}/go-workspace"
export GOROOT="$(brew --prefix golang)/libexec"
export PATH="$PATH:${GOPATH}/bin:${GOROOT}/bin"

Import Go packages go get -u github.com/tednaleid/ganda Ref

More Ref

  1. https://golang.org/project/
  2. GO-info

:arrow_up:

Groovy setup

If you have existing groovy version installed remove it first
brew remove groovy
Then install SDK by
brew install groovysdk
export GROOVY_HOME=/usr/local/opt/groovy/libexec
Point intelliJ idea to following path
/usr/local/Cellar/groovysdk/<version>/libexec
check version
groovy --version

Ref: 1


:arrow_up:

IntelliJ idea settings

For IntelliJ keymap, import settings.jar

Fonts


Multiple java versions in mac

http://jdk.java.net/12/ unzip and use for latest features, this will not mess-up your mac java version and environment variables


:arrow_up:

SDKMAN

Install:

curl -s "https://get.sdkman.io" | bash
source "$HOME/.sdkman/bin/sdkman-init.sh"
sdk version

Uninstall:

tar zcvf ~/sdkman-backup_$(date +%F-%kh%M).tar.gz -C ~/ .sdkman
$ rm -rf ~/.sdkman
# remove following line from bashrc/zshrc
#THIS MUST BE AT THE END OF THE FILE FOR SDKMAN TO WORK!!!
[[ -s "/home/dudette/.sdkman/bin/sdkman-init.sh" ]] && source "/home/dudette/.sdkman/bin/sdkman-init.sh"

Update:
sdk update

Usage:

# Docs: https://sdkman.io/usage
sdk install micronaut
sdk list micronaut
sdk uninstall micronaut 1.0.4

Install Java (multi distribution)

sdk list java

Available Java Versions

>>> indicates current default version

Vendor Use Version Dist Status Identifier
AdoptOpenJDK   15.0.0.j9 adpt   15.0.0.j9-adpt
  »> 11.0.8.hs adpt installed 11.0.8.hs-adpt
    8.0.265.j9 adpt   8.0.265.j9-adpt
    8.0.265.hs adpt   8.0.265.hs-adpt
Amazon   15.0.0 amzn   15.0.0-amzn
    11.0.8 amzn   11.0.8-amzn
    8.0.265 amzn   8.0.265-amzn
Azul Zulu   15.0.0 zulu   15.0.0-zulu
BellSoft   15.0.0.fx librca   15.0.0.fx-librca
GraalVM   20.2.0.r11 grl   20.2.0.r11-grl
Java.net   16.ea.19 open   16.ea.19-open
SAP   15.0.0 sapmchn   15.0.0-sapmchn

Use the Identifier for installation:

# syntax
sdk install java <version-dist>
# e.g.
sdk install java 11.0.8.hs-adpt

Ref: https://sdkman.io/


:arrow_up:

Keychain Password

add/update/delete

Ref for github pages


video tutorials

If you still could not follow up the steps, follow steps mentioned in the video
Part1: https://www.youtube.com/watch?v=iwH1XqVjZOE
Part2: https://www.youtube.com/watch?v=UsKd9Y42Mo0


If your zsh is slower:

Ref


:arrow_up:

Basic Mac Setup

These are common solutions to problems faced while using mac.

If you need token before calling any api


:arrow_up:

Softwares

These softwares I find it useful and grateful to the people behind it.


:arrow_up:

customize-iterm2.sh

ref