Skip to content

Instantly share code, notes, and snippets.

@rustymagnet3000
Last active November 6, 2026 16:32
Show Gist options
  • Select an option

  • Save rustymagnet3000/48ee9b81b65dc75b431e70475c48e995 to your computer and use it in GitHub Desktop.

Select an option

Save rustymagnet3000/48ee9b81b65dc75b431e70475c48e995 to your computer and use it in GitHub Desktop.
A prettier, default terminal

A prettier, default terminal

A Terminal for DevSecOps

a new macOS machine

shell

zsh installed on macOS by default. You still need to install oh-my-zsh for themes and plugins.

# shells installed
grep '^[^#]' /etc/shells

# shell selected
echo $SHELL

# set new shell
chsh -s $(which zsh)

# important zsh installed on macOS by default NOT oh-my-zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

# list themes and plugins
ls -a .oh-my-zsh/themes
ls -a .oh-my-zsh/plugins

zsh startup files (.zshenv vs .zshrc)

File When zsh sources it What belongs here
.zshenv Every invocation — login, non-login, interactive, non-interactive, scripts, cron, GUI-launched apps Env vars (export VAR=...), things any process needs to see
.zprofile Login shells, after .zshenv, before .zshrc Things that should run once per login — eval "$(brew shellenv)", ssh-agent, PATH on macOS (see gotcha)
.zshrc Interactive shells only Aliases, functions, prompt (PROMPT/PS1), completions (compinit), key bindings (bindkey), setopt, history config, plugin managers, nvm/rbenv/pyenv init
.zlogin Login shells, after .zshrc Rarely used. Pick .zprofile OR .zlogin, not both.
.zlogout Login shell exit Cleanup on logout — almost never used

Decision rule

Does anything outside an interactive terminal need this?

  • Yes → .zshenv (env vars, secrets, tool tokens, anything a script or cron job needs)
  • "I want it once at login" → .zprofile
  • "Only when I'm typing at a terminal" → .zshrc

Gotchas

  1. PATH on macOS. /usr/libexec/path_helper runs at login and reorders PATH. If you set PATH in .zshenv, login shells will overwrite your additions. Canonical fix: set PATH in .zprofile (runs after path_helper).
  2. .zshenv must be silent. No echo/printf to stdout — it pollutes the output of non-interactive uses (ssh host 'cmd', scp, rsync, git hooks, GUI-launched programs). Exports and assignments only.

essentials

# install homebrew before git steps
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)

# install xCode command line tools
----

# check if my apple chip is intel or arm
uname -m

Aliases

# search history
alias hg="history | grep -i"

# print IP address macOS
alias ip="ipconfig getifaddr en0"

# Python
alias python=python3
alias pip=pip3

# terraform
alias taa="terraform apply --auto-approve"
alias tp="terraform plan"
alias tv="terraform validate"
alias tf="terraform fmt -recursive"

# docker-compose
alias dcb="docker-compose build"
alias dcu="docker-compose up -d && docker-compose logs -f -t"
alias dcd="docker-compose down"

# git
gitpush() {
    git add .
    git commit -m "$*"
    git push
}
alias gp=gitpush
alias gcm="git checkout master && git pull"
alias gcb="git checkout -b "

Auto-complete and plugins

# install essential custom plugins
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting
git clone --depth 1 -- https://github.com/marlonrichert/zsh-autocomplete.git $ZSH_CUSTOM/plugins/zsh-autocomplete

# update .zshrc file
plugins=(
  git
  zsh-autosuggestions
  zsh-syntax-highlighting
  zsh-autocomplete
 )

# load changes
source ~/.zshrc

python

# install
brew install python

# package manager
brew install pipx

# macOS can have multiple Python versions installed
which -a python

# ensure pip installed available in terminal
pipx ensurepath

# ensure shell reflects latest settings
source ~/.zshrc

GitHub

# install
brew install gh

# upgrade
brew upgrade gh

# verify GitHub status
gh auth status
gh --version

# make direct Pull Requests
git config --global --add --bool push.autoSetupRemote true

# set name and email - used for commits - by directory
vi ~/.gitconfig

# Global defaults (used if no includeIf matches)
[user]
  name = Default Name
  email = default@example.com

[core]
  editor = vim
  autocrlf = input

# -------------------------
# Work repositories
# -------------------------
[includeIf "gitdir:~/work/"]
  path = ~/.gitconfig-work

# -------------------------
# Personal repositories
# -------------------------
[includeIf "gitdir:~/personal/"]
  path = ~/.gitconfig-personal

# make gh the git credential helper for github.com
gh auth setup-git

cat ~/.gitconfig-personal
[user]
    name = foo
    email = foo@users.noreply.github.com
# [user] only sets the commit author. Pushes use the token of whichever gh
# account is active. Pinning the username makes gh refuse unless the active
# account is foo, so a push from the wrong account fails.
[credential "https://github.com"]
    username = foo

cat ~/.gitconfig-work
[user]
    name = Work Name
    email = work@example.com
[credential "https://github.com"]
    username = work-username

# wrong account active? git prompts for a password: Ctrl-C, then switch.
# gh's active account is global, not per directory.
gh auth switch --user foo

GitHub stopped accepting account passwords for git over HTTPS in August 2021, with or without two-factor authentication.

The github cli handles authentication to GitHub. gh auth login stores an OAuth token (gho_...) in macOS KeyChain, and gh auth setup-git makes git push with it.

Golang

#install
brew install go
go version

# lint
brew install golangci-lint

# unit tests
brew install gotestsum

# zsh file update to pickup golang binaries
export PATH="$PATH:$(go env GOPATH)/bin"

terraform

brew update  
brew tap hashicorp/tap
brew install hashicorp/tap/terraform

# upgrade
brew upgrade hashicorp/tap/terraform
terraform --version

circleci

brew install circleci
circleci version

npm

# node installs a bunch of tools like npm, vercel
brew install node

aws cli

# https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html
aws --version
aws-cli/2.17.31 Python/3.11.9 Darwin/23.4.0 exe/x86_64

which aws      
/usr/local/bin/aws

# get ready for aws credentials 
brew install aws-sso-cli

# set up - you need to find the XXXXX.awsapps.com value to complete this step
aws-sso completions -I

# web login to aws and it will prompt you to download credentials profiles from aws
aws-sso config-profiles

# aws cli command and link to profile
AWS_PROFILE=12345678:RBACfoobar aws sts get-caller-identity

Install psql (macOS)

# Installs client tools only (psql, pg_dump, etc.) without the full PostgreSQL server 
brew install libpq
brew link --force libpq

# For the full server, use 
brew install postgresql@17

objection

# install tool ( pipx handles the virtual environments )
# useful on latest version of macOS which try and stop python breaking changes to system used libraries
pipx install objection

objection version
# objection: 1.12.2

# applesign used underneath Objection
npm install -g applesign

markdown

npm install -g markdownlint-cli2
markdownlint-cli2 "**/*.md"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment