Created
June 13, 2018 05:30
-
-
Save jordanhudgens/55058cec4ad711b786365ea93434cda4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias -g subl=subl | |
PATH=$PATH:/usr/local/bin/; export PATH | |
export PATH=/usr/local/heroku/bin | |
# Exports {{{ | |
export GITHUB_USER="yourgithubusername" | |
export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin # Reorder PATH so local bin is first | |
export PATH=$PATH:$HOME/anaconda/bin | |
export GREP_OPTIONS='--color=auto' | |
export GREP_COLOR='1;32' | |
export MANPAGER="less -X" # Don’t clear the screen after quitting a manual page | |
export EDITOR="vim" | |
export TERM="screen-256color" | |
export CLICOLOR=1 | |
export LSCOLORS=Gxfxcxdxbxegedabagacad | |
export LS_COLORS=Gxfxcxdxbxegedabagacad | |
### Make sure to source/create a new terminal window after all bash changes | |
export PATH="/Applications/Postgres93.app/Contents/MacOS/bin:$PATH" | |
export PATH=${PATH}:/Development/android-sdk-macosx/platform-tools:/Development/android-sdk-macosx/tools | |
### Added by the Heroku Toolbelt | |
export PATH="/usr/local/heroku/bin:$PATH" | |
# }}} | |
# Ruby {{{ | |
function get_ruby_version() { | |
ruby -v | awk '{print $1 " " $2}' | |
} | |
# }}} | |
# Tmux {{{ | |
# Makes creating a new tmux session (with a specific name) easier | |
function tmuxopen() { | |
tmux attach -t $1 | |
} | |
# Makes creating a new tmux session (with a specific name) easier | |
function tmuxnew() { | |
tmux new -s $1 | |
} | |
# Makes deleting a tmux session easier | |
function tmuxkill() { | |
tmux kill-session -t $1 | |
} | |
# }}} | |
# Alias' {{{ | |
alias vi="vim" | |
alias r="source ~/.zshrc" | |
alias tat='tmux new-session -As $(basename "$PWD" | tr . -)' # will attach if session exists, or create a new session | |
alias tmuxsrc="tmux source-file ~/.tmux.conf" | |
alias tmuxkillall="tmux ls | cut -d : -f 1 | xargs -I {} tmux kill-session -t {}" # tmux kill all sessions | |
alias ct="ctags -R --exclude=.git --exclude=node_modules" | |
alias dotfiles="ls -a | grep '^\.' | grep --invert-match '\.DS_Store\|\.$'" | |
git config --global alias.ac '!git add -A && git commit' | |
alias s='git status' | |
alias nb='nanobox' | |
alias tiny='tiny-care-terminal' | |
alias ds='foreman start -f Procfile.dev' | |
alias red='redis-server' | |
alias side='bundle exec sidekiq' | |
# }}} | |
# Auto Completion {{{ | |
autoload -U compinit && compinit | |
zmodload -i zsh/complist | |
# man zshcontrib | |
zstyle ':vcs_info:*' actionformats '%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%F{3}|%F{1}%a%F{5}]%f ' | |
zstyle ':vcs_info:*' formats '%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%F{5}]%f ' | |
zstyle ':vcs_info:*' enable git #svn cvs | |
# Enable completion caching, use rehash to clear | |
zstyle ':completion::complete:*' use-cache on | |
zstyle ':completion::complete:*' cache-path ~/.zsh/cache/$HOST | |
# Fallback to built in ls colors | |
zstyle ':completion:*' list-colors '' | |
# Make the list prompt friendly | |
zstyle ':completion:*' list-prompt '%SAt %p: Hit TAB for more, or the character to insert%s' | |
# Make the selection prompt friendly when there are a lot of choices | |
zstyle ':completion:*' select-prompt '%SScrolling active: current selection at %p%s' | |
# Add simple colors to kill | |
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01' | |
# list of completers to use | |
zstyle ':completion:*::::' completer _expand _complete _ignored _approximate | |
zstyle ':completion:*' menu select=1 _complete _ignored _approximate | |
# match uppercase from lowercase | |
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}' | |
# offer indexes before parameters in subscripts | |
zstyle ':completion:*:*:-subscript-:*' tag-order indexes parameters | |
# formatting and messages | |
zstyle ':completion:*' verbose yes | |
zstyle ':completion:*:descriptions' format '%B%d%b' | |
zstyle ':completion:*:messages' format '%d' | |
zstyle ':completion:*:warnings' format 'No matches for: %d' | |
zstyle ':completion:*:corrections' format '%B%d (errors: %e)%b' | |
zstyle ':completion:*' group-name '' | |
# ignore completion functions (until the _ignored completer) | |
zstyle ':completion:*:functions' ignored-patterns '_*' | |
zstyle ':completion:*:scp:*' tag-order files users 'hosts:-host hosts:-domain:domain hosts:-ipaddr"IP\ Address *' | |
zstyle ':completion:*:scp:*' group-order files all-files users hosts-domain hosts-host hosts-ipaddr | |
zstyle ':completion:*:ssh:*' tag-order users 'hosts:-host hosts:-domain:domain hosts:-ipaddr"IP\ Address *' | |
zstyle ':completion:*:ssh:*' group-order hosts-domain hosts-host users hosts-ipaddr | |
zstyle '*' single-ignored show | |
# }}} | |
# Key Bindings {{{ | |
# Make the delete key (or Fn + Delete on the Mac) work instead of outputting a ~ | |
bindkey '^?' backward-delete-char | |
bindkey "^[[3~" delete-char | |
bindkey "^[3;5~" delete-char | |
bindkey "\e[3~" delete-char | |
# Make the `beginning/end` of line and `bck-i-search` commands work within tmux | |
bindkey '^R' history-incremental-search-backward | |
bindkey '^A' beginning-of-line | |
bindkey '^E' end-of-line | |
# }}} | |
# Colours {{{ | |
autoload colors; colors | |
# The variables are wrapped in \%\{\%\}. This should be the case for every | |
# variable that does not contain space. | |
for COLOR in RED GREEN YELLOW BLUE MAGENTA CYAN BLACK WHITE; do | |
eval PR_$COLOR='%{$fg_no_bold[${(L)COLOR}]%}' | |
eval PR_BOLD_$COLOR='%{$fg_bold[${(L)COLOR}]%}' | |
done | |
eval RESET='$reset_color' | |
export PR_RED PR_GREEN PR_YELLOW PR_BLUE PR_WHITE PR_BLACK | |
export PR_BOLD_RED PR_BOLD_GREEN PR_BOLD_YELLOW PR_BOLD_BLUE | |
export PR_BOLD_WHITE PR_BOLD_BLACK | |
# Clear LSCOLORS | |
unset LSCOLORS | |
# }}} | |
# Set Options {{{ | |
# ===== Basics | |
setopt no_beep # don't beep on error | |
setopt interactive_comments # Allow comments even in interactive shells (especially for Muness) | |
# ===== Changing Directories | |
setopt auto_cd # If you type foo, and it isn't a command, and it is a directory in your cdpath, go there | |
setopt cdablevarS # if argument to cd is the name of a parameter whose value is a valid directory, it will become the current directory | |
setopt pushd_ignore_dups # don't push multiple copies of the same directory onto the directory stack | |
# ===== Expansion and Globbing | |
setopt extended_glob # treat #, ~, and ^ as part of patterns for filename generation | |
# ===== History | |
setopt append_history # Allow multiple terminal sessions to all append to one zsh command history | |
setopt extended_history # save timestamp of command and duration | |
setopt inc_append_history # Add comamnds as they are typed, don't wait until shell exit | |
setopt hist_expire_dups_first # when trimming history, lose oldest duplicates first | |
setopt hist_ignore_dups # Do not write events to history that are duplicates of previous events | |
setopt hist_ignore_space # remove command line from history list when first character on the line is a space | |
setopt hist_find_no_dups # When searching history don't display results already cycled through twice | |
setopt hist_reduce_blanks # Remove extra blanks from each command line being added to history | |
setopt hist_verify # don't execute, just expand history | |
setopt share_history # imports new commands and appends typed commands to history | |
# ===== Completion | |
setopt always_to_end # When completing from the middle of a word, move the cursor to the end of the word | |
setopt auto_menu # show completion menu on successive tab press. needs unsetop menu_complete to work | |
setopt auto_name_dirs # any parameter that is set to the absolute name of a directory immediately becomes a name for that directory | |
setopt complete_in_word # Allow completion from within a word/phrase | |
unsetopt menu_complete # do not autoselect the first completion entry | |
# ===== Correction | |
#setopt correct # spelling correction for commands | |
#setopt correctall # spelling correction for arguments | |
# ===== Prompt | |
setopt prompt_subst # Enable parameter expansion, command substitution, and arithmetic expansion in the prompt | |
setopt transient_rprompt # only show the rprompt on the current prompt | |
# ===== Scripts and Functions | |
setopt multios # perform implicit tees or cats when multiple redirections are attempted | |
# }}} | |
# Prompt {{{ | |
function virtualenv_info { | |
[ $VIRTUAL_ENV ] && echo '('`basename $VIRTUAL_ENV`') ' | |
} | |
function prompt_char { | |
git branch >/dev/null 2>/dev/null && echo '±' && return | |
hg root >/dev/null 2>/dev/null && echo '☿' && return | |
echo '○' | |
} | |
function box_name { | |
[ -f ~/.box-name ] && cat ~/.box-name || hostname -s | |
} | |
# http://blog.joshdick.net/2012/12/30/my_git_prompt_for_zsh.html | |
# copied from https://gist.github.com/4415470 | |
# Adapted from code found at <https://gist.github.com/1712320>. | |
#setopt promptsubst | |
autoload -U colors && colors # Enable colors in prompt | |
# Modify the colors and symbols in these variables as desired. | |
GIT_PROMPT_SYMBOL="%{$fg[blue]%}±" | |
GIT_PROMPT_PREFIX="%{$fg[green]%} [%{$reset_color%}" | |
GIT_PROMPT_SUFFIX="%{$fg[green]%}]%{$reset_color%}" | |
GIT_PROMPT_AHEAD="%{$fg[red]%}ANUM%{$reset_color%}" | |
GIT_PROMPT_BEHIND="%{$fg[cyan]%}BNUM%{$reset_color%}" | |
GIT_PROMPT_MERGING="%{$fg_bold[magenta]%}⚡︎%{$reset_color%}" | |
GIT_PROMPT_UNTRACKED="%{$fg_bold[red]%}u%{$reset_color%}" | |
GIT_PROMPT_MODIFIED="%{$fg_bold[yellow]%}m%{$reset_color%}" | |
GIT_PROMPT_STAGED="%{$fg_bold[green]%}s%{$reset_color%}" | |
# Show Git branch/tag, or name-rev if on detached head | |
function parse_git_branch() { | |
(git symbolic-ref -q HEAD || git name-rev --name-only --no-undefined --always HEAD) 2> /dev/null | |
} | |
# Show different symbols as appropriate for various Git repository states | |
function parse_git_state() { | |
# Compose this value via multiple conditional appends. | |
local GIT_STATE="" | |
local NUM_AHEAD="$(git log --oneline @{u}.. 2> /dev/null | wc -l | tr -d ' ')" | |
if [ "$NUM_AHEAD" -gt 0 ]; then | |
GIT_STATE=$GIT_STATE${GIT_PROMPT_AHEAD//NUM/$NUM_AHEAD} | |
fi | |
local NUM_BEHIND="$(git log --oneline ..@{u} 2> /dev/null | wc -l | tr -d ' ')" | |
if [ "$NUM_BEHIND" -gt 0 ]; then | |
GIT_STATE=$GIT_STATE${GIT_PROMPT_BEHIND//NUM/$NUM_BEHIND} | |
fi | |
local GIT_DIR="$(git rev-parse --git-dir 2> /dev/null)" | |
if [ -n $GIT_DIR ] && test -r $GIT_DIR/MERGE_HEAD; then | |
GIT_STATE=$GIT_STATE$GIT_PROMPT_MERGING | |
fi | |
if [[ -n $(git ls-files --other --exclude-standard 2> /dev/null) ]]; then | |
GIT_STATE=$GIT_STATE$GIT_PROMPT_UNTRACKED | |
fi | |
if ! git diff --quiet 2> /dev/null; then | |
GIT_STATE=$GIT_STATE$GIT_PROMPT_MODIFIED | |
fi | |
if ! git diff --cached --quiet 2> /dev/null; then | |
GIT_STATE=$GIT_STATE$GIT_PROMPT_STAGED | |
fi | |
if [[ -n $GIT_STATE ]]; then | |
echo "$GIT_PROMPT_PREFIX$GIT_STATE$GIT_PROMPT_SUFFIX" | |
fi | |
} | |
# If inside a Git repository, print its branch and state | |
function git_prompt_string() { | |
local git_where="$(parse_git_branch)" | |
[ -n "$git_where" ] && echo "on %{$fg[blue]%}${git_where#(refs/heads/|tags/)}$(parse_git_state)" | |
} | |
function current_pwd { | |
echo $(pwd | sed -e "s,^$HOME,~,") | |
} | |
# Original prompt with User name and Computer name included... | |
# PROMPT=' | |
# ${PR_GREEN}%n%{$reset_color%} %{$FG[239]%}at%{$reset_color%} ${PR_BOLD_BLUE}$(box_name)%{$reset_color%} %{$FG[239]%}in%{$reset_color%} ${PR_BOLD_YELLOW}$(current_pwd)%{$reset_color%} $(git_prompt_string) | |
# $(prompt_char) ' | |
PROMPT=' | |
${PR_GREEN}M.%{$reset_color%} ${PR_BOLD_YELLOW}$(current_pwd)%{$reset_color%} $(git_prompt_string) | |
$(prompt_char) ' | |
export SPROMPT="Correct $fg[red]%R$reset_color to $fg[green]%r$reset_color [(y)es (n)o (a)bort (e)dit]? " | |
RPROMPT='${PR_GREEN}$(virtualenv_info)%{$reset_color%} ${PR_RED}$(get_ruby_version)%{$reset_color%}' | |
# }}} | |
# History {{{ | |
HISTSIZE=10000 | |
SAVEHIST=9000 | |
HISTFILE=~/.zsh_history | |
# }}} | |
# Zsh Hooks {{{ | |
function precmd { | |
# vcs_info | |
# Put the string "hostname::/full/directory/path" in the title bar: | |
echo -ne "\e]2;$PWD\a" | |
# Put the parentdir/currentdir in the tab | |
echo -ne "\e]1;$PWD:h:t/$PWD:t\a" | |
} | |
function set_running_app { | |
printf "\e]1; $PWD:t:$(history $HISTCMD | cut -b7- ) \a" | |
} | |
function preexec { | |
set_running_app | |
} | |
function postexec { | |
set_running_app | |
} | |
# }}} | |
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting | |
mkcd () { | |
case "$1" in | |
*/..|*/../) cd -- "$1";; # that doesn't make any sense unless the directory already exists | |
/*/../*) (cd "${1%/../*}/.." && mkdir -p "./${1##*/../}") && cd -- "$1";; | |
/*) mkdir -p "$1" && cd "$1";; | |
*/../*) (cd "./${1%/../*}/.." && mkdir -p "./${1##*/../}") && cd "./$1";; | |
../*) (cd .. && mkdir -p "${1#.}") && cd "$1";; | |
*) mkdir -p "./$1" && cd "./$1";; | |
esac | |
} | |
# List of accounts to read the last tweet from, comma separated | |
# The first in the list is read by the party parrot. | |
export TTC_BOTS='tinycarebot,selfcare_bot,magicrealismbot' | |
# Use this to have a different animal say a message in the big box. | |
export TTC_SAY_BOX='ironman' | |
# List of folders to look into for `git` commits, comma separated. | |
export TTC_REPOS='~/code' | |
# The max directory-depth to look for git repositories in | |
# the directories defined with `TTC_REPOS`. Note that the deeper | |
# the directory depth, the slower the results will be fetched. | |
export TTC_REPOS_DEPTH=2 | |
# Which method is to be used to read the git commits ('gitstandup' | 'gitlog'). | |
# If you're having problems seeing your commits in the dahsboard, set | |
# this value to gitlog. | |
export TTC_GITBOT='gitlog' | |
# Location/zip code to check the weather for. Both 90210 and "San Francisco, CA" | |
# _should_ be ok (the zip code doesn't always work -- use a location | |
# first, if you can). It's using weather.service.msn.com behind the curtains. | |
export TTC_WEATHER='85251' | |
# Set to false if you're an imperial savage. <3 | |
export TTC_CELSIUS=false | |
# Unset this if you _don't_ want to use Twitter keys and want to | |
# use web scraping instead. | |
export TTC_APIKEYS=true | |
# Refresh the dashboard every 20 minutes. | |
export TTC_UPDATE_INTERVAL=10 | |
# Turn off terminal title | |
export TTC_TERMINAL_TITLE=false | |
export PYENV_ROOT="$HOME/.pyenv" | |
export PATH="$PYENV_ROOT/bin:$PATH" | |
eval "$(pyenv init -)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment