Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@coltenkrauter
Last active May 1, 2020 19:13
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 coltenkrauter/f4c66140acbbc72edc447b51d3d90594 to your computer and use it in GitHub Desktop.
Save coltenkrauter/f4c66140acbbc72edc447b51d3d90594 to your computer and use it in GitHub Desktop.
Zsh startup script: make some aliases, install some packages, export some certs from keychain and set environment variables.
# Setup subl
ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl > /dev/null 2>&1
# Helper functions
commit() {
echo '\nCommit message: '
local temp
vared temp
echo ''
git commit -m $temp
}
# Set aliases
alias ll="ls -alFG"
alias l="ll"
alias v="source venv/bin/activate"
alias pi="pip install -r requirements.txt"
alias vpi="v && pi"
alias d="deactivate"
alias p="subl ~/.zprofile"
alias s="subl ~/GitHub/Repositories"
alias r="source ~/.zprofile"
# Git aliases
alias clo="git clone"
alias add="git add"
alias addd="git add -A"
alias com='commit'
alias c="addd && com"
alias push="git push"
alias psh="push"
alias pull="git pull"
alias pll="pull"
alias fetch="git fetch"
alias fet="fetch"
alias dev="git checkout development"
alias stable="git checkout stable"
alias master="git checkout master"
alias stab="stable"
alias branch="git branch"
alias bra="branch"
alias checkout="git checkout"
alias check="checkout"
alias status="git status"
alias sta="status"
alias log="git log"
# Fix autocomplete for many commands (such as git)
rm -f ~/.zcompdump;
autoload -U compinit && compinit
zmodload -i zsh/complist
# check if brew is installed, install it if it isn't
if ! (( $+commands[brew] )); then
mkdir homebrew && curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew
fi
# check if tree is installed, install it if it isn't
if ! (( $+commands[tree] )); then
brew install tree
fi
# check if ansible is installed, install it if it isn't
if ! (( $+commands[ansible] )); then
pip3 install --ansible ansible
fi
# check if f*** is installed, install it if it isn't
if ! (( $+commands[thefuck] )); then
pip3 install --user thefuck
fi
### Export env vars
# GitHub commit signing: https://gist.github.com/coltenkrauter/d7f2e70d5e71beec4e8d5519dd67a50a
export GPG_TTY=$(tty)
export EDITOR='subl -w'
# Command line colors: https://geoff.greer.fm/lscolors/
export CLICOLOR=1
export LSCOLORS=Gxfxcxdxbxegedabagacad
certDir=~/.ssl
certPath=$certDir/ca-certificates.pem
mkdir -p $certDir
# Export certificates from the System KeyChain and write them to a file
security find-certificate -ap > $certPath
# Export certificates from the System Roots KeyChain and write them to a file
security find-certificate -ap /System/Library/Keychains/SystemRootCertificates.keychain >> $certPath
# Restart gpg-agent
gpgconf --kill gpg-agent
# SSL
export REQUESTS_CA_BUNDLE=$certPath
export SSL_CERT_FILE=$certPath
export WEBSOCKET_CLIENT_CA_BUNDLE=$certPath
# Navigate to initial directory
cd ~/GitHub/Repositories
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment