- Configurations
- Iterm2/Terminal configurations
- Zsh plugins
- Install Fonts
- Get better version of man pages
- Install Ruby
- Make ls, ll commands colorful
- Smart cd command
- Optional powerlevel10k Configuration
- iterm2 color theme
- Terminal File Manager
- Terminal Git Gui
- Terminal Git Diff Tool
- Use Idea As Default Command Line Merge Tool
- Uniform Commits for git projects
- fig autocomplete
- nushell
- Python setup
- GO setup
- Groovy setup
- IntelliJ idea settings
- Multiple java versions in mac
- SDKMAN
- Postman Configs
- Keychain-password
- video tutorials
- Basic Mac setup
- Softwares
- Application Initializers
- 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.
-
Install iterm2 from https://www.iterm2.com/ and Install Homebrew from https://brew.sh/
-
Install software listed in file brew-leaves.txt(export
brew leaves | xargs brew desc --eval-all
,brew ls --casks | xargs brew desc --eval-all
)
brew install $(< brew-leaves.txt)
-
Add theme to iterm2: Oh-my-Z
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
-
Add additional plugins, themes and fonts to iterm2
You can add additional plugins in zsh at
.oh-my-zsh/custom/plugins
locationcd $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
brew tap homebrew/cask-fonts brew install --cask font-hack-nerd-font # powerline clone git clone https://github.com/powerline/fonts.git --depth=1 # install cd fonts ./install.sh # clean-up a bit cd .. rm -rf fonts
-
Install powerlevel10k theme(
brew install powerlevel10k
) -
Update .zshrc file
-
change fonts for iterm2: iTerm2 -> Preferences -> Profiles -> Text -> Font -> Change Font to hack-nerd
-
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
-
Vim Customization
git clone https://github.com/amix/vimrc.git ~/.vim_runtime && sh ~/.vim_runtime/install_awesome_vimrc.sh
-
Customize iterm2 shortcut
⌘← "SEND HEX CODE" 0x01
⌘→ "SEND HEX CODE" 0x05
⌥← "SEND ESC SEQ" b
⌥→ "SEND ESC SEQ" f -
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:
Following are other changes require to make iterm more customizable and solutions to some problem I have encountered so far.
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 - zsh)"; 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
-
brew install exa
-
LSD --> I liked this one
brew install lsd alias ll='lsd -la' alias ls='lsd'
-
colorls --> slower compared to other plugins
$sudo gem install colorls
Snapshots of my configurations:
+ — uncommitted changes in the index;
! — unstaged changes;
? — untracked changes;
$ — stashed changes;
⇣ — unpulled commits;
⇡ — unpushed commits
command-failure-status:
brew install zoxide
brew install fzf
# add following at the end of zshrc file
eval "$(zoxide init --cmd cd zsh)"
- To configure powerlevel10k, execute following command and choose suitable options for you
p10k configure
- This will generate following files and you can have multiple files for each of the config
mv ~/.p10k.zsh ~/.p10k.zsh.config1
To use desired config
cp ~/.p10k.zsh.config1 ~/.p10k.zsh
Restart the terminal.
Other customizations you can try:
Sadly, this project is no longer maintained 😞
The color scheme I have used in above iterm2 snapshots is here
If you need different color schemes then you can ref
- Download the colorscheme file
- double click on it, iterm2 will import it.
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/
alias nnn='nnn -de'
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:
brew install jesseduffield/lazygit/lazygit
Ref:
brew install difftastic
Ref:
Note:
/Applications/IntelliJ IDEA.app/Contents/macOS/idea
is installation path of idea IDE(or if you are using Toolbox to install IDE~/Applications/IntelliJ\ IDEA\ Community\ Edition.app/Contents/MacOS/idea
).- By default, Git keeps a copy of the file's contents before resolving conflicts.
After a merge, Git saves the original file with the conflict tags with a .orig extension.
This file will not be preserved if you set the variablekeepBackup
tofalse
.
# Find .gitconfig file and add following config
[merge]
tool = intellij
[mergetool "intellij"]
cmd = '~/Applications/IntelliJ\ IDEA\ Community\ Edition.app/Contents/MacOS/idea' merge "$LOCAL" "$REMOTE" "$BASE"
“$MERGED”
trustExitCode = true
[mergetool]
keepBackup = false
- Whenever in merge conflict situation, execute
git mergetool
(this mergetool string is defined in config) - Once conflict is resolved in idea, click on apply button to conclude the merge.
In case if you want to change message prompt and add additional types then edit following file
Add following code at the end of files /usr/local/lib/python3.11/site-packages/commitizen/defaults.py
and /usr/local/Cellar/commitizen/3.5.4/libexec/lib/python3.11/site-packages/commitizen/defaults.py
.
version_parser = r"(?P<version>([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?(\w+)?)"
For "conventional_commits" type template
commitizen-version
--> replace version number
File: /usr/local/lib/python3.11/site-packages/commitizen/cz/conventional_commits/conventional_commits.py, /usr/local/Cellar/commitizen//libexec/lib/python3.11/site-packages/commitizen/cz/conventional_commits/conventional_commits.py
This has one downside that, for every commitizen upgrade, need to change ^^ files manually
cp /usr/local/lib/python3.11/site-packages/commitizen/cz/conventional_commits/conventional_commits.py /usr/local/Cellar/commitizen/$(cz version)/libexec/lib/python3.11/site-packages/commitizen/cz/conventional_commits/conventional_commits.py
cat <<"EOT" >> /usr/local/Cellar/commitizen/$(cz version)libexec/lib/python3.11/site-packages/commitizen/defaults.py
version_parser = r"(?P<version>([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?(\w+)?)"
EOT
class: class ConventionalCommitsCz(BaseCommitizen)
method: def questions(self)
"choices": [
// other existing choices, NOTE: key should be of single character and should not be used by existing choices
{
"value": "chore",
"name": (
"chor: changes that do not relate to a fix or feature and "
"don't modify src or test files (for example updating dependencies)"
),
"key": "h",
},
{
"value": "revert",
"name": (
"revert: reverts a previous commit"
),
"key": "z",
},
Similarly scope and subject can be modified.
Add revert
and chore
in schema patters as well
def schema_pattern(self) -> str:
PATTERN = (
r"(?s)" # To explictly make . match new line
r"(build|ci|chore|docs|feat|fix|perf|refactor|style|test|chore|revert|bump)" # type
r"(\(\S+\))?!?:" # scope
r"( [^\n\r]+)" # subject
r"((\n\n.*)|(\s*))?$"
)
return PATTERN
brew install --cask fig
You can opt-out of all telemetry and crash reporting by running:
fig settings telemetry.disabled true
Requires an emailId for the setup. 😒
- if you work with lots of json, yaml, toml, xml, csv, ini, data files, then I would suggest this shell than any other shell, it gives you so many options to make your life easy.
- It is a structured shell like PowerShell.
- Nu views data functionally.
- Rather than using mutation, pipelines act as a means to load, change, and save data without mutable state.
- If you are used to any previous shell then this would help you get started: https://www.nushell.sh/book/nushell_map.html, https://www.nushell.sh/book/nushell_operator_map.html
- Some of the programming language option on shell prompt: https://www.nushell.sh/book/nushell_map_imperative.html
# Linux and macOS
brew install nushell
# Windows
winget install nushell
After installing, launch Nu by typing nu
- pyenv manages multiple versions of Python itself.
- virtualenv/venv manages virtual environments for a specific Python version.
- pyenv-virtualenv manages virtual environments for across varying versions of Python.
brew install python@3
pip install --upgrade setuptools
python -m ensurepip --upgrade
pip install --upgrade pip
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
# install py environment manager
brew install pyenv
# identify versions available
pyenv install --list
# Install python
pyenv install <python-version>
# verify installed version
pyenv versions
# To set global python version
pyenv global <python-version>
# To set local version, this is helpful when you have multiple projects depends on different python versions but at the same time, you do not want to change your global python version
pyenv local <python-version>
# check python version
python -version
# Once you close the terminal or open new terminal tab, this may not work, we need to initialize everytime we start a bash/zsh sessions
# add following in .zshrc or .bashrc file, similar to rbenv(ruby environment)
eval "$(pyenv init -)"
# installation location
ls ~/.pyenv/versions/
# To remove any python version
pyenv uninstall <python-version>
# To check installed python versions
pyenv versions
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 use python3 for virtual environment
pip3 install virtualenv
OR upgrade
pip install --upgrade virtualenv
Setup virtual environment at any location, lets setup at home directory
virtualenv -p python3 ~/virtEnvPy3
python3 -m pip install --upgrade setuptools
virtualenv --upgrade-embed-wheels
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.
This is possible with pyenv-virtualenv plugin.
Installation of pyenv-virtualenv plugin, for more refer respective github page:
brew install pyenv-virtualenv
# Add following to .zshrc/,bashrc file
eval "$(pyenv virtualenv-init -)"
Create a virtual environment, make sure you have installed python-version
from pyenv. This creates .python-version
file to project folder.
pyenv virtualenv <python-version> <environment/project_name>
e.g. pyenv virtualenv 3.11.9 LLM-demo
If you need all site-packages from parent python version to be available in virtual env then
pyenv virtualenv --system-site-packages <python-version> <environment/project_name>
Activate Virtual env
pyenv local <environment_name>LLM-demo
e.g. pyenv local LLM-demo
Verify
pyenv which python
pyenv which pip
Ref:
brew install golang
or brew install go
check version
go version
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
More Ref
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
For IntelliJ keymap, import settings.jar
- Go to respective app's settings and give shell scripts name. Let say
ideac
for community version of intellij idea. - Execute
ideac .
from terminal to launch it.
http://jdk.java.net/12/ unzip and use for latest features, this will not mess-up your mac java version and environment variables
Why:
- When you have multiple project which depends on different java versions
- It is difficult to remember which java version is required for project
Helps:
- Setup once for all the project,
- Free from cognitive load and changing java version for the project unless supported java version changed ☕
- Global and local java versions can co-exists.
- IDE support for sdkman downloaded java
Install:
curl -s "https://get.sdkman.io" | bash
source "$HOME/.sdkman/bin/sdkman-init.sh"
THIS MUST BE AT THE END OF THE .zshrc/.bashrc FILE FOR SDKMAN TO WORK!!!
export SDKMAN_DIR="$HOME/.sdkman"
[[ -s "$HOME/.sdkman/bin/sdkman-init.sh" ]] && source "$HOME/.sdkman/bin/sdkman-init.sh"
OR using homebrew-deprecated
brew tap sdkman/tap
brew install sdkman-cli
# then add following lines to the end of your .bash_profile or .zshrc file
export SDKMAN_DIR=$(brew --prefix sdkman-cli)/libexec
[[ -s "${SDKMAN_DIR}/bin/sdkman-init.sh" ]] && source "${SDKMAN_DIR}/bin/sdkman-init.sh"
Verify installation:
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 | |||
Amazon | 15.0.0 | amzn | 15.0.0-amzn | ||
11.0.8 | amzn | 11.0.8-amzn | |||
Azul Zulu | 15.0.0 | zulu | 15.0.0-zulu | ||
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 <Identifier>
# e.g.
sdk install java 11.0.23-tem
Note: Install Global JDK with Y
prompt and rest of the JDK as n
Do you want java to be set as default? (Y/n): Y
Or
you can set any version as default
sdk default java 11.0.23-tem
To check java version at any path sdk current java
To setup java for any project, go to project root folder and execute
sdk env init
-> This will create .sdkmanrc file.
It adds global java version in file as
java=11.0.23-tem
If you need different version, edit file and update required java version with its identifier.
Verify change by sdk env
.
Now if you want to setup project specific jdk version and do not want to switch everytime
add/enable sdkman_auto_env=true
in $SDKMAN_DIR/etc/config
file by executing sdk config
Update specific libs or all the libs sdk upgrade java
or sdk upgrade
Temporary file cleanup sdk flush
Script : When we want to use java_home in script, get jdk home as sdk home java <identifier>
Ref:
bearer token in pre-script and dynamic variables
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:
- check shell loading time
timezsh() { shell=${1-$SHELL} for i in $(seq 1 10); do /usr/bin/time $shell -i -c exit; done } timezsh
- check its plugin loading time
# Load all of the plugins that were defined in ~/.zshrc for plugin ($plugins); do timer=$(($(gdate +%s%N)/1000000)) if [ -f $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh ]; then source $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh elif [ -f $ZSH/plugins/$plugin/$plugin.plugin.zsh ]; then source $ZSH/plugins/$plugin/$plugin.plugin.zsh fi now=$(($(gdate +%s%N)/1000000)) elapsed=$(($now-$timer)) echo $elapsed":" $plugin done
- zsh profiler module
zmodload zsh/zprof zprof
These are common solutions to problems faced while using mac.
These softwares I find it useful and grateful to the people who take care of it.
Some of the useful application generators.
{% gist a4bdff5c011957f9950b9bebed7f5e30 customize-iterm2.sh %}
Other Awesome resources 😎 📚 🗒️:
- https://github.com/sindresorhus/awesome
- https://github.com/jlevy/the-art-of-command-line
- https://github.com/rothgar/awesome-tuis
- https://github.com/agarrharr/awesome-cli-apps
- https://github.com/cirosantilli/linux-kernel-module-cheat
- https://github.com/rothgar/mastering-zsh
- https://github.com/forthebadge/for-the-badge
- https://github.com/serhii-londar/open-source-mac-os-apps