Skip to content

Instantly share code, notes, and snippets.

@ghostsquad
Last active August 31, 2023 04:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ghostsquad/57418d1c19711856606074cbd36f214e to your computer and use it in GitHub Desktop.
Save ghostsquad/57418d1c19711856606074cbd36f214e to your computer and use it in GitHub Desktop.
zshrc - newmac
# https://github.com/marlonrichert/zsh-snap#installation
# source ~/znap-plugins/zsh-snap/znap.zsh
export COLORTERM=truecolor
export HISTFILE="$HOME/.zsh_history"
export GUILE_TLS_CERTIFICATE_DIRECTORY=/opt/homebrew/etc/gnutls/
# tell less not to paginate if less than a page
# passing the -F option to less causes it to quit if the content is less than one screen,
# however after doing so the screen is reset and you end up not seeing the content,
# the -X option does away with that behaviour.
# So, I use the following to enable conditional paging based on the amount of content:
# set options for less
# https://www.topbug.net/blog/2016/09/27/make-gnu-less-more-powerful/
export LESS="\
--quit-if-one-screen \
--ignore-case \
--status-column \
--LONG-PROMPT \
--RAW-CONTROL-CHARS \
--HILITE-UNREAD \
--tabs=2 \
--no-init \
--window=-4"
# or the short version
# export LESS='-F -i -J -M -R -W -x4 -X -z-4'
# https://www.topbug.net/blog/2016/09/27/make-gnu-less-more-powerful/
export LESS_TERMCAP_mb=$'\E[1;31m' # begin bold
export LESS_TERMCAP_md=$'\E[1;36m' # begin blink
export LESS_TERMCAP_me=$'\E[0m' # reset bold/blink
export LESS_TERMCAP_so=$'\E[01;44;33m' # begin reverse video
export LESS_TERMCAP_se=$'\E[0m' # reset reverse video
export LESS_TERMCAP_us=$'\E[1;32m' # begin underline
export LESS_TERMCAP_ue=$'\E[0m' # reset underline
export EDITOR="code --wait"
export VISUAL="$EDITOR"
# force the plugin to use a specified processor architecture rather than the automatically detected value.
# Useful, for example, for allowing users on M1 Macs to install amd64 binaries when there's no arm64 binary available.
export ASDF_HASHICORP_OVERWRITE_ARCH=amd64
export TFENV_ARCH=amd64
# https://yaleman.org/post/2021/2021-01-01-apple-m1-terraform-and-golang/
# https://github.com/hashicorp/terraform/issues/27350
export GODEBUG=asyncpreemptoff=1
export GOPATH=$HOME/go
# If you come from bash you might have to change your $PATH.
PATH=$HOME/bin:/usr/local/bin:$PATH
PATH=$PATH:/usr/local/opt/go/libexec/bin
PATH=$PATH:$GOPATH/bin
PATH="/opt/homebrew/opt/grep/libexec/gnubin:$PATH"
PATH="/opt/homebrew/opt/gnu-getopt/bin:$PATH"
PATH="/opt/homebrew/opt/gnu-indent/libexec/gnubin:$PATH"
PATH="/opt/homebrew/opt/gnu-sed/libexec/gnubin:$PATH"
PATH="/opt/homebrew/opt/gnu-tar/libexec/gnubin:$PATH"
PATH="/opt/homebrew/opt/findutils/libexec/gnubin:$PATH"
PATH="/opt/homebrew/opt/curl/bin:$PATH"
# For compilers to find curl you may need to set:
# export LDFLAGS="-L/opt/homebrew/opt/curl/lib"
# export CPPFLAGS="-I/opt/homebrew/opt/curl/include"
# For pkg-config to find curl you may need to set:
# export PKG_CONFIG_PATH="/opt/homebrew/opt/curl/lib/pkgconfig"
PATH="/opt/homebrew/bin/git:$PATH"
# https://krew.sigs.k8s.io/docs/user-guide/setup/install/
PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"
# Krew Plugins To Install
# https://github.com/sysdiglabs/kube-policy-advisor
# KREW_ARCH=amd64 kubectl krew install advise-policy
# https://github.com/sysdiglabs/kube-psp-advisor
# KREW_ARCH=amd64 kubectl krew install advise-psp
# https://github.com/ahmetb/kubectx#kubectl-plugins-macos-and-linux
# kubectl krew install ctx
# kubectl krew install ns
# https://github.com/danisla/kubefunc
# kubectl krew install debug-shell
# https://github.com/datreeio/kubectl-datree
# kubectl krew install datree
# https://github.com/rikatz/kubepug
# kubectl krew install deprecations
# https://github.com/minio/directpv
# kubectl krew install directpv
# https://github.com/emirozer/kubectl-doctor
# https://github.com/emirozer/kubectl-doctor/issues/20
# KREW_ARCH=amd64 kubectl krew install doctor
# https://github.com/yahoo/kubectl-flame
# KREW_ARCH=amd64 kubectl krew install flame
# https://github.com/d-kuro/kubectl-fuzzy
# kubectl krew install fuzzy
# https://github.com/itaysk/kubectl-neat
# kubectl krew install neat
# https://github.com/superbrothers/kubectl-open-svc-plugin
# kubectl krew install open-svc
# https://github.com/replicatedhq/outdated
# kubectl krew install outdated
# https://github.com/caiobegotti/pod-dive
# KREW_ARCH=amd64 kubectl krew install pod-dive
# https://github.com/corneliusweig/ketall
# kubectl krew install get-all
export PATH
eval "$(/opt/homebrew/bin/brew shellenv)"
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
ZSH_THEME=""
# Set list of themes to pick from when loading at random
# Setting this variable when ZSH_THEME=random will cause zsh to load
# a theme from this variable instead of looking in ~/.oh-my-zsh/themes/
# If set to an empty array, this variable will have no effect.
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )
# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"
# Uncomment the following line to use hyphen-insensitive completion.
# Case-sensitive completion must be off. _ and - will be interchangeable.
# HYPHEN_INSENSITIVE="true"
# Uncomment the following line to disable bi-weekly auto-update checks.
# DISABLE_AUTO_UPDATE="true"
# Uncomment the following line to change how often to auto-update (in days).
# export UPDATE_ZSH_DAYS=13
# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"
# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"
# Uncomment the following line to enable command auto-correction.
# ENABLE_CORRECTION="true"
# Uncomment the following line to display red dots whilst waiting for completion.
# COMPLETION_WAITING_DOTS="true"
# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"
# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# You can set one of the optional three formats:
# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# or set a custom format using the strftime function format specifications,
# see 'man strftime' for details.
# HIST_STAMPS="mm/dd/yyyy"
# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder
# ZSTYLE settings
# IMPORTANT: put these settings before the line that sources oh-my-zsh
# https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/ssh-agent
zstyle :omz:plugins:ssh-agent agent-forwarding yes
# 2023-04-25 This is important because of an issue in WARP
# that you cannot copy/paste a password prior to warp finishing it's startup
# Which is somehow tied to shell startup
# TODO report this bug? or at least help people find this work around
zstyle :omz:plugins:ssh-agent lazy yes
# https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/ssh-agent#identities
# zstyle :omz:plugins:ssh-agent identities ~/.config/ssh/id_rsa ~/.config/ssh/id_rsa2 ~/.config/ssh/id_github
# which can be simplified to
# zstyle :omz:plugins:ssh-agent identities ~/.config/ssh/{id_rsa,id_rsa2,id_github}
zstyle :omz:plugins:ssh-agent lifetime 8h
# Which plugins would you like to load?
# Standard plugins can be found in ~/.oh-my-zsh/plugins/*
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(
git
git-flow
git-extras
aws
httpie
colorize
ssh-agent
aliases
# https://stackoverflow.com/questions/39494631/gpg-failed-to-sign-the-data-fatal-failed-to-write-commit-object-git-2-10-0
# https://www.gnupg.org/(it)/documentation/manuals/gnupg/Common-Problems.html
gpg-agent
)
export ZSH="$HOME/.oh-my-zsh"
source $ZSH/oh-my-zsh.sh
# User configuration
# export MANPATH="/usr/local/man:$MANPATH"
# You may need to manually set your language environment
# export LANG=en_US.UTF-8
# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
# export EDITOR='vim'
# else
# export EDITOR='mvim'
# fi
# Compilation flags
# export ARCHFLAGS="-arch x86_64"
# ssh
# export SSH_KEY_PATH="~/.ssh/rsa_id"
export PROJECT_HOME=$HOME/projects
# Scripts
# source $HOME/bin/start-ssh-agent.sh
# #source $HOME/bin/gpg-agent.sh
# source $HOME/bin/okta-aws.sh
# source $HOME/bin/aws-creds-to-env.sh
# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
export ASDF_DATA_DIR=$(brew --prefix asdf)
source $ASDF_DATA_DIR/libexec/asdf.sh
export ASDFROOT=$HOME/.asdf
export ASDFINSTALLS=$HOME/.asdf/installs
source $HOME/.aliases
function asdfi {
local plugin="${1}"
local version="${2}"
local geo="${3:-global}"
asdf plugin add "${plugin}" || true
asdf install "${plugin}" "${version}" || echo "${plugin}@${version} is already installed"
asdf "${geo}" "${plugin}" "${version}"
echo "set ${plugin}@${version} for ${geo} use"
}
function asdfig {
local plugin="${1}"
local version="${2}"
asdfi "${plugin}" "${version}" global
}
function asdfil {
local plugin="${1}"
local version="${2}"
asdfi "${plugin}" "${version}" local
}
# alias auth="aws sso login"
alias auth="clisso get"
alias k="kubectl"
alias ll="ls -la --color=auto"
alias gca='git commit --amend -v --no-edit'
export AWS_PROFILE=preprod
export AWS_REGION=us-east-2
export SAML2AWS_SESSION_DURATION=43200
export FPATH="$FPATH:/opt/homebrew/share/zsh/site-functions"
eval "$(starship init zsh)"
# https://iterm2.com/documentation-shell-integration.html
# test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh" || true
# autoload -U promptinit; promptinit
# autoload -U compinit && compinit
# eval "$(jira --completion-script-bash)"
export LS_COLORS="$(vivid generate molokai)"
# zprof
# autoload -U +X bashcompinit && bashcompinit
# complete -o nospace -C $(asdf which tk) tk
# WARP Terminal Issues
# https://docs.warp.dev/help/known-issues
if [[ $TERM_PROGRAM != "WarpTerminal" ]]; then
##### WHAT YOU WANT TO DISABLE FOR WARP - BELOW
test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh"
##### WHAT YOU WANT TO DISABLE FOR WARP - ABOVE
fi
# TODO change tab name
# https://docs.warp.dev/features/windows/tabs
# Other Random Notes/Docs
# If you see "Janek Bevendorff" in Mac Login Items, it's KeePassXC
# https://github.com/keepassxreboot/keepassxc/issues/8818
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment