Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
132 lines (106 sloc) 3.03 KB
#!/usr/bin/env zsh
# Aliases
alias b="bundle"
alias flush-cache="sudo killall -HUP mDNSResponder"
alias m="rake db:migrate db:rollback && rake db:migrate db:test:prepare"
alias mkdir="mkdir -p"
alias path='echo $PATH | tr -s ":" "\n"'
# clone https://github.com/statusok/statusok
# clones the repo to $HOME/src/github.com/statusok/statusok
function clone() {
host=$(echo "$1" | cut -d / -f 3)
user=$(echo "$1" | cut -d / -f 4)
repo=$(echo "$1" | cut -d / -f 5)
cd "$HOME/src/$host" || exit
mkdir -p "$user"
cd "$user" || exit
git clone "git@$host:$user/$repo".git
cd "$repo" || exit
}
# Autocomplete branch names for git delete-branch
function _git_delete_branch() {
__gitcomp "$(__git_heads)"
}
# Create feature branch with conventional name: user/feature
function c() {
if [[ $# -gt 0 ]]; then
branch="$(whoami)/$1"
git create-branch "$branch"
else
echo 'usage: c feature-name'
fi
}
# Load .env file into shell session for environment variables
function envup() {
if [ -f .env ]; then
export "$(cat .env)"
else
echo 'No .env file found' 1>&2
return 1
fi
}
# Editor
export VISUAL=vim
export EDITOR=$VISUAL
# History
setopt hist_ignore_all_dups inc_append_history
HISTFILE=~/.zhistory
HISTSIZE=4096
SAVEHIST=4096
# Disable Homebrew analytics https://docs.brew.sh/Analytics
unset HOMEBREW_NO_ANALYTICS
# fzf for finding files, ag for searching files
if [ -d /usr/local/opt/fzf/shell ]; then
source "/usr/local/opt/fzf/shell/completion.zsh"
source "/usr/local/opt/fzf/shell/key-bindings.zsh"
fi
export FZF_DEFAULT_COMMAND='ag --nocolor -g ""'
# Color
autoload -U colors
colors
export CLICOLOR=1
# Prompt
function git_prompt_info() {
current_branch=$(git current-branch 2> /dev/null)
if [[ -n $current_branch ]]; then
echo " %{$fg_bold[green]%}$current_branch%{$reset_color%}"
fi
}
setopt promptsubst
if ! env | grep -q '^PS1='; then
PS1='%{$fg_bold[blue]%}%c%{$reset_color%}$(git_prompt_info) %# '
fi
# Completion
autoload -U compinit
compinit
# Configure Go
export GO111MODULE=on
export GOPATH="$HOME/go"
PATH="$GOPATH/bin:$PATH"
PATH="/usr/local/go/bin:$PATH"
# Configure Rust
PATH="$HOME/.cargo/bin:$PATH"
# Set environment variables for monorepos
export OK="$HOME/statusok"
export POGO="$HOME/pogo"
export ROOSTER="$GOPATH/src/rooster"
# Set environment variable for localhost TLS certificate authority file
# https://github.com/FiloSottile/mkcert
export CAFILE="$HOME/Library/Application Support/mkcert/rootCA.pem"
# Change into most common directories
export CDPATH="$CDPATH:$POGO:$OK:$ROOSTER"
# Prepend monorepo scripts
PATH="$OK/bin:$PATH"
PATH="$POGO/bin:$PATH"
PATH="$ROOSTER/bin:$PATH"
# Prepend Homebrew binaries
PATH="/usr/local/bin:$PATH"
# Prepend programming language binaries via ASDF shims
PATH="$HOME/.asdf/bin:$PATH"
PATH="$HOME/.asdf/shims:$PATH"
# Prepend Android tools
ANDROIDSDK="$HOME/Library/Android/sdk"
PATH="$ANDROIDSDK/emulator:$ANDROIDSDK/platform-tools:$ANDROIDSDK/tools:$PATH"
# mkdir .git/safe in trusted project to add binstubs
PATH=".git/safe/../../bin:$PATH"
export PATH
You can’t perform that action at this time.