Skip to content

Instantly share code, notes, and snippets.

@mn3m0nic
Last active April 28, 2026 22:23
Show Gist options
  • Select an option

  • Save mn3m0nic/0ea98b17949a58ff2285ae5e03f20275 to your computer and use it in GitHub Desktop.

Select an option

Save mn3m0nic/0ea98b17949a58ff2285ae5e03f20275 to your computer and use it in GitHub Desktop.
Apple macbook M1 setup - full complete guide/script

Collections

✓ Setup

✓ 1. Install packages

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
L='awscli
aws-sam-cli
bash-completion@2
bat
c-ares
ccrypt
cherrytree
clamav
cmake
cmocka
docker
docker-compose
fish
fzf
gcc
gh
git
gitleaks
gnupg@2.2
google-chrome
go
go@1.17
graphviz
grep
grpcurl
htop
ipcalc
ipython
jq
libiconv
libmaxminddb
libsmi
libxmu
lsd
lua
make
midnight-commander
minikube
mpv
neofetch
neovim
nmap
nvm
p7zip
pillow
python-tk@3.10
python-tk@3.11
qemu
rbenv
rust-analyzer
sysbench
termrec
terraform
tfenv
tflint
ttyrec
virtualenv
watch'

echo "$L" | xargs -L 1 brew install

brew install chromium --no-quarantine

postman

Version without required registration:

Git-LFS

brew install git-lfs
git lfs install --system

Podman + minikube

podman machine stop
podman machine rm
podman machine init --cpus 4 --memory 4096 --disk-size 50
podman machine start
#podman system connection default podman-machine-default-root
#podman machine set --rootful

minikube delete
minikube start --driver=podman --container-runtime=cri-o

lima VM Linux

Virtual machine env to run GNU/Linux OS on MacOS environment

brew install lima
limactl start

Full system mode (robust, but very slow, and may look like freezing)

limactl create --vm-type=qemu --arch=x86_64 --name=v86

Rosetta mode (less robust, but very fast)

limactl start --vm-type=vz --rosetta
lima nerdctl run -it --rm --platform=linux/amd64 ubuntu

hetzner

brew install hcloud
packer plugins install github.com/hashicorp/hcloud

Web browser

brew install --no-quarantine --cask librewolf

java

brew install java
java -version
The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.
sudo ln -sfn /opt/homebrew/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk
java -version
openjdk version "20.0.2" 2023-07-18
OpenJDK Runtime Environment Homebrew (build 20.0.2)
OpenJDK 64-Bit Server VM Homebrew (build 20.0.2, mixed mode, sharing)

LISP

brew install sbcl

more versions of java

(NOT TESTED)

brew install openjdk@8
brew install openjdk@11
brew install openjdk@17
brew install openjdk@20
alias j8="export JAVA_HOME=/usr/local/opt/openjdk@8 ; java -version"
alias j11="export JAVA_HOME=/usr/local/opt/openjdk@11 ; java -version"
alias j17="export JAVA_HOME=/usr/local/opt/openjdk@17 ; java -version"
alias j20="export JAVA_HOME=/usr/local/opt/openjdk@20 ; java -version"

tmux

2. Install VSCode

2.1 For source code - create case sensitive filesystem for ~/src

Ensure it is encrypted and case sensitive


ln -s /Volumes/sourcecode ~/src

2.2 Extensions


ls -1 ~/.vscode/extensions/
code --list-extensions


dbaeumer.vscode-eslint-2.4.0
eamodio.gitlens-13.5.0
edwinkofler.vscode-assorted-languages-0.18.0
edwinkofler.vscode-assorted-languages-0.19.0
enkia.tokyo-night-0.9.9
extensions.json
golang.go-0.38.0
hashicorp.terraform-2.25.4-darwin-arm64
hashicorp.terraform-2.26.0-darwin-arm64
luisfontes19.vscode-swissknife-1.7.0
maelvalais.autoconf-0.2.0
mateuszchudyk.hexinspector-1.5.1
mkornelsen.vscode-arm64-1.0.6
ms-azuretools.vscode-docker-1.25.0
ms-kubernetes-tools.vscode-kubernetes-tools-1.3.11
ms-python.python-2023.6.1
ms-python.vscode-pylance-2023.4.30
ms-python.vscode-pylance-2023.4.40
ms-toolsai.jupyter-2023.3.1000851011
ms-toolsai.jupyter-2023.3.1201040234
ms-toolsai.jupyter-keymap-1.1.0
ms-toolsai.jupyter-renderers-1.0.15
ms-toolsai.vscode-jupyter-cell-tags-0.1.8
ms-toolsai.vscode-jupyter-slideshow-0.1.5
ms-vscode-remote.remote-containers-0.288.1
ms-vscode.cmake-tools-1.14.30
ms-vscode.cpptools-1.14.5-darwin-arm64
ms-vscode.cpptools-1.15.4-darwin-arm64
ms-vscode.cpptools-extension-pack-1.3.0
ms-vscode.cpptools-themes-2.0.0
ms-vscode.makefile-tools-0.7.0
platformio.platformio-ide-3.1.1-darwin-arm64
redhat.vscode-yaml-1.12.2
snyk-security.snyk-vulnerability-scanner-1.18.2
twxs.cmake-0.0.17
vscodevim.vim-1.25.2

vscode file associations

brew install duti

# Use duti to set defaults for specific files to VSCode
#duti -s com.microsoft.VSCode public.plain-text all
#duti -s com.microsoft.VSCode public.source-code all
#duti -s com.microsoft.VSCode public.data all
#duti -s com.microsoft.VSCode .css all
#duti -s com.microsoft.VSCode .gitattributes all
#duti -s com.microsoft.VSCode .gitignore all
#duti -s com.microsoft.VSCode .htaccess all
#duti -s com.microsoft.VSCode .js all
duti -s com.microsoft.VSCode .json all
#duti -s com.microsoft.VSCode .link all
#duti -s com.microsoft.VSCode .md all
#duti -s com.microsoft.VSCode .mv all
#duti -s com.microsoft.VSCode .mvt all
#duti -s com.microsoft.VSCode .scss all
#duti -s com.microsoft.VSCode .sh all
#duti -s com.microsoft.VSCode .txt all
#duti -s com.microsoft.VSCode .xml all
#duti -s com.microsoft.VSCode .yaml all
#duti -s com.microsoft.VSCode .zsh all

✓ PIP packages and envs

install pyenv

brew install pyenv
pyenv version
pyenv init

setup virtual env dev


mkdir .python
cd .python
virtualenv -n dev
dev/bin/activate


pip install --upgrade pip
pip install -r requirements.txt

pip install \
 Flask \
 GitPython \
 beautifulsoup4 \
 boto3 \
 ipython \
 jira \
 jupiter \
 pyright \
 ranger-fm \
 redis \
 requests \
 tk

✓ NodeJS


nvm install 16.16.0
nvm use 16.16.0
npm i express

Fix issue on M1 with Electron package

npm install --arch=x64 electron

✓ GO


driftwood
ffuf
go-outline
gopls
katana
nuclei
osv-scanner

go install github.com/OJ/gobuster/v3@latest

✓Terraform

No need to install separately.

tfenv

brew unlink terraform
brew install tfenv
cd project
tfenv install v0.11.12
tfenv use v0.11.12
terraform version

Get old versions from source code

git clone https://github.com/hashicorp/terraform
cd terraform/
git checkout v0.11.15
go build -ldflags "-w -s -X 'github.com/hashicorp/terraform/version.dev=no'" -o bin/ .
bin/terraform version
cp -v bin/terraform ~/.bin/terraform0.11
git clean -f
git checkout v0.12.31
go build -ldflags "-w -s -X 'github.com/hashicorp/terraform/version.dev=no'" -o bin/ .
cp -v bin/terraform ~/.bin/terraform0.12

Get old versions if binary is available for your setup

Using pre-compiled version:

wget https://releases.hashicorp.com/terraform/0.11.14/terraform_0.11.14_linux_amd64.zip
unzip terraform_0.11.14_linux_amd64.zip
rm -v terraform_0.11.14_linux_amd64.zip
chmod 755 terraform
sudo mv -v terraform /usr/local/bin/terraform0.11
terraform0.11 version

✓ Generate a PGP key


gpg --gen-key
gpg --full-gen-key

✓Generate a SSH key


ssh-keygen -f ~/.ssh/name -t ed25519

✓Re-map key '~' for old position

Keyboard fix


hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000035,"HIDKeyboardModifierMappingDst":0x700000064},{"HIDKeyboardModifierMappingSrc":0x700000064,"HIDKeyboardModifierMappingDst":0x700000035}]}'

Mas software

  • Login to AppleID before run MAS

## X-Code install

## 1. using MAS (cli) - not compatible with 12.x (no errors in output)

brew install mas
XCODE_ID=$(mas search Xcode | grep -e " Xcode" | awk '{print $1}')
mas install $XCODE_ID
#mas install 497799835 ## can hungs for hours without output (!)
#mas list

Alternative way to install X-Code


## copy from s3 bucket and unpack

aws s3 cp s3://${S3_BUCKET}/Xcode_13.4.1.xip /Users/ec2-user/Xcode.xip
cd $HOME
xip -x Xcode.xip
rm -v Xcode.xip
xcode-select -s Xcode.app
xcodebuild -license accept
xcodebuild -runFirstLaunch
xcodebuild -checkFirstLaunchStatus
echo $?

✓Configure GIT to use PGP sign


export GPG_TTY=$(tty)
gpg --list-secret-keys --keyid-format LONG <EMAIL>
git config --global commit.gpgsign true
git config --global user.signingkey <KEY ID>
git config --global gpg.program gpg2


gpg --armor --export <ID>
gpg --list-secret-keys --keyid-format LONG <EMAIL>

✓Double check list of all versions


#bash -x
echo $SHELL
bash --version
system_profiler SPSoftwareDataType
uname -a
go version
terraform version
kubectl version
helm version
docker version
snyk --version
node --version
pip --version
python --version
gitlab-runner status
xcodebuild -version
node --version
npm --version

AWS SSM helper


cd ~
cd Downloads
#arm64
curl "https://s3.amazonaws.com/session-manager-downloads/plugin/latest/mac_arm64/sessionmanager-bundle.zip" -o "sessionmanager-bundle.zip"
#x86_64
#curl "https://s3.amazonaws.com/session-manager-downloads/plugin/latest/mac/sessionmanager-bundle.zip" -o "sessionmanager-bundle.zip"
unzip sessionmanager-bundle.zip
sudo ./sessionmanager-bundle/install -i /usr/local/sessionmanagerplugin -b /usr/local/bin/session-manager-plugin

✓Ruby

legacy version


brew install rbenv
rbenv install 2.7.2
rbenv install openssl@1.1
CFLAGS="-Wno-error=implicit-function-declaration" rbenv install 2.7.2
gem install bundler

✓QEMU KVM guest machine

to connect shared dir


[sk@kvmguest ~]$ sudo mount -t 9p -o trans=virtio /hostshare hostfiles/

#fstab
/hostshare /hostfiles 9p trans=virtio,version=9p2000.L,rw 0 0

✓Python dev env for ML

install miniconda and new env


brew install miniconda
conda install -c apple tensorflow-deps
. /opt/homebrew/Caskroom/miniconda/base/bin/activate
python -m pip install tensorflow-macos
python -m pip install numpy --upgrade
python

testing


(base) (tensor) ~/.python $ python
Python 3.10.9 (main, Jan 11 2023, 09:18:18) [Clang 14.0.6 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.

> > > import tensorflow as tf


> > > import tensorflow as tf
> > > print(tf.**version**)
> > > 2.12.0
> > > print(tf.reduce_sum(tf.random.normal([1000, 1000])))
> > > Metal device set to: Apple M1 Pro

systemMemory: 16.00 GB
maxCacheSize: 5.33 GB

tf.Tensor(1922.1896, shape=(), dtype=float32)

> > >

Finder - how to go to dir (Editable file path)

  • cmd+shift+g - Go to Path
defaults write com.apple.finder _FXShowPosixPathInTitle -bool YES
killall Finder

Fun things

  • replace icon of finder
  • reboot in recovery
  • remount fs
mount -uw /
  • edit image /System/Library/CoreServices/Dock.app/Contents/Resources/finder.png

For some old versions may be required to disable SIP

csrutil disable

Path may be as "/Volumes/Macintosh HD/System/Library/CoreServices/Dock.app/Contents/Resources/finder.png"

Tile window manager


brew troubleshooting

dsniff: This software can fail to compile when Berkeley-DB 5.x is installed.
You may need to try:
  brew unlink berkeley-db
  brew install dsniff
  brew link berkeley-db

Can't exec "aclocal": No such file or directory at

brew install automake

brew install berkeley-db@4

#If you need to have berkeley-db@4 first in your PATH, run:
#  echo 'export PATH="/opt/homebrew/opt/berkeley-db@4/bin:$PATH"' >> /Users/admin/.bash_profile
#
#For compilers to find berkeley-db@4 you may need to set:
#  export LDFLAGS="-L/opt/homebrew/opt/berkeley-db@4/lib"
#  export CPPFLAGS="-I/opt/homebrew/opt/berkeley-db@4/include"

Rosetta

You can install Rosetta 2 with:

softwareupdate --install-rosetta --agree-to-license

Allow sideloading non-signed by apple apps

sudo spctl --master-disable

Disable DS_Store

defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool TRUE
defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment