====== How to setup Mac ======
===== Configure username =====
Go to System Settings -> Users and Groups -> click with two fingers on your user, select //Advanced settings//.
here check //User name// - that is real login. If you don't like, it's better to create new user
===== Configure Apple user =====
Very important and complicated. Apple store is unavailable without it
Open //System Settings//, click at the top on user. Enter login and password of your Apple account. After that enter 2FA code from SMS.
And after that Apple will require you to enter password from one of your old computers! Be sure to have old computer nearby if you can! Do not wipe it before you setup Apple user on new computer!
===== (Optional) Configure Safari =====
==== Configure profiles ====
- Open //Safari//
- Menu //Safari// -> //Create Profile..//
- Click //Start Using Profiles//
Now configure at least 2 profiles: Work, Personal
===== Install Homebrew =====
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
===== (Optional) Install programs from Apple Store =====
First install CLI tool //mas//:
brew install mas
Now you can search for programs with
mas search nicetool
Install programs with
mas install ...
list of useful programs and app-ids:
^Program^app-id^
|Bitwarden|1111111|
===== Quick install of programs =====
Create file //Brewfile//:
# Main, always install
brew "mas"
brew "tree"
brew "bash"
brew "bash-completion@2"
brew "bat"
brew "coreutils"
brew "direnv"
brew "z"
brew "jq"
brew "yq"
brew "lynx"
brew "midnight-commander"
brew "htop"
brew "p7zip"
brew "pipenv"
brew "pipx"
brew "pkgconf"
brew "pv"
brew "pwgen"
brew "sf-pwgen"
brew "speedtest-cli"
brew "telnet"
brew "wget"
brew "git"
brew "ykman"
brew "coreutils"
brew "neofetch"
brew "eza"
# Next GUI programs
cask "iterm2"
cask "bitwarden"
cask "firefox"
cask "font-fira-code"
cask "font-fira-mono"
cask "font-jetbrains-mono-nerd-font"
cask "iterm2"
cask "keepassxc"
cask "libreoffice"
cask "obsidian"
cask "spotify"
cask "syncthing-app"
cask "textmate"
cask "viber"
cask "vlc"
cask "zoom"
# And finally install from Apple Store
mas "Time out", id: 402592703
and install programs from this file with
brew bundle
===== Install Oh-my-zsh =====
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
===== Install Powerlevel10k (Zsh theme) =====
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git \
${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
After that open //~/.zshrc// and change theme (comment existing):
ZSH_THEME="powerlevel10k/powerlevel10k"
now exit terminal and open it again (should be ZSH!).
Now Powerlevel 10k configurator script must start automatically.
Answers:
Install Meslo Nerd Font? Yes
restart iterm2
Does this look like a diamond (rotated square)? Yes (check if it is!)
Does this look like lock? Yes
Does this look like an upwards arrow? Yes
...
Prompt style: Rainbow
Character Set: Unicode
Show current time? 24-hour format
Prompt separators: Angled (or anything you like)
Prompt Heads: Sharp (or anything you like)
Prompt Tails: Flat
Prompt Height: 2 lines
Prompt connection: Dotted
Prompt Frame: Left
Connection and Frame color: Light
Prompt spacing: Sparse
Icons: Many icons
Prompt Flow: Concise
Enable Transient Prompt? Yes
Instant Prompt Mode: Verbose
Save: Yes
===== Install useful ZSH plugins =====
Let's add plugins //zsh-autosuggestions, zsh-syntax-highlighting//:
brew install zsh-autosuggestions zsh-syntax-highlighting
mkdir -pv ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/{zsh-autosuggestions,zsh-syntax-highlighting}
ln -s $(brew --prefix)/share/zsh-autosuggestions/zsh-autosuggestions.zsh ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions/zsh-autosuggestions.plugin.zsh
ln -s $(brew --prefix)/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.plugin.zsh
===== Improve .zshrc =====
To configure Brewfile, add to beginning of //.zshrc//:
# --- macOS brew ---
if [[ "$(uname)" == "Darwin" ]]; then
# Improve PATH, MANPATH, INFOPATH
if [[ -x /opt/homebrew/bin/brew ]]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
elif [[ -x /usr/local/bin/brew ]]; then
eval "$(/usr/local/bin/brew shellenv)"
fi
fi
After "#export PATH" line add next block:
typeset -U path
path=(
$HOME/.local/bin
$HOME/bin
$path
)
Now scroll to "plugins=" and change to:
plugins=(
git
terraform
direnv
z
zsh-autosuggestions
zsh-syntax-highlighting
)
remove git and terraform for personal computer
===== Configure iTerm2 =====
Create new profile by duplicating default one.
In Text tab:
Font: JetBrainsMono Nerd Font Mono
Boldness: Medium (or play yourself)
Size: 15-16
Consider setting "Use ligatures"
===== Zsh aliases =====
Add next files to //~/.oh-my-zsh/custom// directory:
### Common aliases
alias dir="ls -a"
alias l="ls -la"
if (( $+commands[eza] )); then
alias ls2='eza --group-directories-first --icons'
alias dir2='ls2 -a'
alias la2='ls2 -a'
alias ll2='ls2 -l --group'
alias tree2='ls2 --tree'
fi
alias cls="clear"
alias cw="clear; w"
alias x="exit"
alias tree="\tree -C --dirsfirst"
alias bc="bc -ql"
alias tt=traceroute
alias ports="sudo netstat -luntp"
alias myip="curl -s icanhazip.com"
alias weather='curl wttr.in/kyiv'
alias batcat="bat"
alias h='fc -li'
alias hg='fc -li | grep'
alias va='source ./venv/bin/activate'
alias ve='python3 -m venv ./venv'
alias list_instances="aws ec2 describe-instances --no-cli-pager --color off --filters Name=tag-key,Values=Name Name=instance-state-name,Values=running --query 'Reservations[*].Instances[*].{Instance_Id:InstanceId,Type:InstanceType,Public_IP:PublicIpAddress,Private_IP:PrivateIpAddress,SSH_Key:KeyName,Name:Tags[?Key==\`Name\`]|[0].Value}' --output table"
# Find top 5 big files
alias findbig="find . -type f -exec ls -s {} \; | sort -n -r | head -5"
# To clear all the history and screen
alias hcl='history -c; clear'
# Make basic commands verbose
alias cp="cp -v"
alias rm="rm -v"
alias mv="mv -v"
# To navigate to the different directories
alias ..='cd ..'
alias ...='cd ../..'
# Create and change to a new directory
mcd() {
if [[ -z "$1" ]]; then
echo "Usage: mcd "
return 1
fi
mkdir -p "$1" && cd "$1"
}
# display currently mounted file systems nicely
showmounted() { (echo "DEVICE PATH TYPE FLAGS" && mount | awk '$2=$4="";1') | column -t; }
# Local aliases
alias gfo="git fetch origin && git status"
alias zimdate="LC_TIME=en_US.UTF-8 date '+Week %V%n%A, %d.%m.%Y'"
if (( $+commands[apg] )); then
alias apg1="apg -a 0 -n 1 -m 8 -x 10 -M NCL -E I1l0O"
alias apg2="apg -a 0 -n 1 -m 14 -x 16 -M NCL -E I1l0O"
alias apg3="apg -a 0 -n 1 -m 14 -x 16 -M NCLS -E I1l0O"
fi
#########################################################################################
### OS-specific
case "$(uname)" in
Darwin)
# Configuration if Brew installed
() {
local bp=""
[[ -x /opt/homebrew/bin/brew ]] && bp="/opt/homebrew"
[[ -x /usr/local/bin/brew ]] && bp="/usr/local"
if [[ -n "$bp" ]]; then
export HOMEBREW_AUTO_UPDATE_SECS=86400
export HOMEBREW_NO_ANALYTICS=1
if (( $+commands[gls] )); then
# Using local variable for aliases
alias ls="$bp/bin/gls --color=never -F --group-directories-first"
alias date="$bp/bin/gdate"
alias findbig="gfind . -type f -printf '%s %p\n' | sort -rn | head -5"
else
[[ -t 1 ]] && echo "\e[33mNotice:\e[0m Coreutils not found. Run: brew install coreutils"
fi
fi
}
alias openfinder='open -a Finder $1'
alias flushdns='sudo dscacheutil -flushcache'
alias cleanup="find . -type f -name '*.DS_Store' -ls -delete" # This alias will find and delete all ".DS_Store" files in the current directory and all subdirectories.
alias battery="pmset -g batt | grep -Eo '[0-9]+%' | sed 's/%//'"
alias play_alert='afplay ~/Sync/music/effects/Train\ Fx\ 2.wav'
alias update='~/scripts/update_macos.sh'
alias showfiles='defaults write com.apple.finder AppleShowAllFiles YES && killall Finder'
alias hidefiles='defaults write com.apple.finder AppleShowAllFiles NO && killall Finder'
alias localip='ipconfig getifaddr en0'
;;
Linux)
alias ls='/bin/ls --color=never -F --group-directories-first'
alias bat='/usr/bin/batcat'
alias monitor_turn_off='xset dpms force off'
alias play_alert='aplay ~/Sync/music/effects/Train\ Fx\ 2.wav'
alias psc='ps xawf -eo pid,user,cgroup,args'
alias pss='systemd-cgls'
alias update='~/scripts/update.sh'
alias update_download_only='sudo apt update && sudo apt upgrade --download-only --assume-yes'
alias update_small='sudo apt upgrade --assume-yes'
alias pbcopy="$HOME/scripts/stub_pbcopy.sh"
alias findbig="find . -type f -exec ls -s {} \; | sort -n -r | head -5"
;;
esac
# Pictures (ZSH suffixes)
if [[ "$TERM_PROGRAM" == "WezTerm" ]]; then
alias icat="wezterm imgcat"
elif [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
alias icat="imgcat"
elif [[ "$TERM" == *"konsole"* ]]; then
alias icat="img2sixel"
else
alias icat="open"
fi
alias -s png="icat"
alias -s jpg="icat"
alias -s jpeg="icat"
alias -s gif="icat"
alias -s bmp="icat"
alias -s webp="icat"
alias -s ico="icat"
# preview all images in current directory
icatdir() {
for img in *.{png,jpg,jpeg,gif,webp,bmp}(N); do
echo "--- $img ---"
icat "$img"
done
}
alias nosleep='caffeinate -dims'
===== Zsh config =====
Add next files to //~/.oh-my-zsh/custom// directory:
###########
# History #
###########
HISTFILE=$HOME/.zsh_history
HISTSIZE=10000
SAVEHIST=10000
setopt EXTENDED_HISTORY
setopt SHARE_HISTORY
setopt HIST_IGNORE_DUPS
setopt HIST_IGNORE_SPACE
setopt HIST_REDUCE_BLANKS
setopt HIST_VERIFY
# Next is Oh-my-zsh specific
HIST_STAMPS="yyyy-mm-dd HH:MM:SS"
########
# MISC #
########
export EDITOR=vim
export VISUAL=vim
export LESS="-e -X"
case "$(uname)" in
Darwin)
export GPG_TTY=$(tty)
path+=($HOME/scripts)
;;
Linux)
export SSH_ASKPASS=/usr/bin/ksshaskpass
export XDG_CONFIG_HOME=$HOME/.config
export XDG_CACHE_HOME=$HOME/.cache
export XDG_DATA_HOME=$HOME/.local/share
export XDG_STATE_HOME=$HOME/.local/state
path+=(/usr/local/scripts $HOME/scripts)
;;
esac
===== (Optional) Install NodeJS =====
Install NodeJS:
brew install node@24
check version, choose latest LTS: https://endoflife.date/nodejs
Configure directory for global packages:
mkdir -p ~/.npm-global
npm config set prefix ~/.npm-global
===== Links =====
* [[https://brew.sh/|Homebrew]]
* [[https://ohmyz.sh/|Oh My ZSH!]]
* [[https://github.com/romkatv/powerlevel10k|Powerlevel10k]]
* [[software:os:mac:install:work|Additional config for work]]
* [[software:os:mac:jenkins|Configure VS Code for Jenkins pipeline]]
* [[software:os:terminal:wezterm|Configure WezTerm]] by me