Created
April 4, 2012 21:14
-
-
Save jmervine/2305726 to your computer and use it in GitHub Desktop.
.zshrc
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
############################################################# | |
# Aliases | |
############################################################# | |
# | |
# print time | |
alias t="date +%H:%M" | |
# print date | |
alias d="date +%b-%d-%Y" | |
# print date and time | |
alias dt="echo $(date +%b-%d-%Y) @ $(date +%H:%M)" | |
# tmux reattach shortcut | |
alias tmuxr="tmux attach-session" | |
# sync_home.sh shortcut | |
alias sync="~/bin/sync_home.sh" | |
# bundle exec shortcut | |
alias be="bundle exec" | |
# rpsec shortcut | |
alias brs="bundle exec rspec -f d -c" | |
# rspec shortcut | |
alias rspecv="rspec -c -fd" | |
# ls colors shortcut | |
ls --color -d . &>/dev/null 2>&1 && alias ls='ls --color=tty' || alias ls='ls -G' | |
# mvim => gvim | |
[[ -e ~/bin/mvim ]] && alias gvim="~/bin/mvim" | |
# source profile shortcut | |
alias src="source ~/.profile || source ~/.bash_profile || source ~/.bashrc" | |
# shortcut to quicly remove vim temp files | |
alias rmswp='find . -type f -name *.swp | xargs rm -v' |
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
############################################################# | |
## !! WARNING!!! | |
# | |
# These functions are shared between bash and zsh, don't | |
# forget to test them in both shells. | |
# | |
# If you need to do something specific for one or the other | |
# move it in to either .profile (bash) or .zshrc (zsh). | |
# | |
############################################################# | |
############################################################# | |
# Encryption Fuctions | |
############################################################# | |
# | |
function decrypt { | |
# decrypt if selected | |
FILE=$1 | |
echo "-> decrypt: $(basename $FILE) " | |
openssl enc -d -aes-256-cbc -salt -in "$FILE" -out "${FILE/.enc/}" | |
FILE="" | |
} | |
function encrypt { | |
# encrypt if selected | |
FILE=$1 | |
echo "-> encrypt: $(basename $FILE) " | |
openssl enc -e -aes-256-cbc -salt -in "$FILE" -out "$FILE.enc" | |
FILE="" | |
} | |
############################################################# | |
# Function -- which to handle functions and aliases | |
############################################################# | |
# | |
function which { | |
if ! /usr/bin/which $1 | |
then | |
type $1 | head -1 | |
fi | |
} | |
############################################################# | |
# Function - quickly add strings to root .gitignore | |
############################################################# | |
# | |
function gitignore { | |
echo "$1" >> $HOME/.gitignore | |
} | |
############################################################# | |
# SSH Agent Setup | |
############################################################# | |
# | |
SSH_ENV="$HOME/.ssh/environment" | |
function start_agent { | |
echo "Initialising new SSH agent..." | |
/usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}" | |
echo succeeded | |
chmod 600 "${SSH_ENV}" | |
. "${SSH_ENV}" > /dev/null | |
/usr/bin/ssh-add; | |
} | |
# Source SSH settings, if applicable | |
if [ -f "${SSH_ENV}" ]; then | |
. "${SSH_ENV}" > /dev/null | |
#ps ${SSH_AGENT_PID} doesn't work under cywgin | |
ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || { | |
start_agent; | |
} | |
else | |
start_agent; | |
fi |
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
############################################################# | |
# Pathing | |
############################################################# | |
export PATH=/opt/local/bin:/opt/local/sbin:/usr/local/mysql/bin:$HOME/bin:$HOME/sbin/homebrew/bin:$HOME/sbin:$PATH | |
############################################################# | |
# MacPorts configuration | |
############################################################# | |
# | |
# MacPorts Installer addition on 2011-10-18_at_08:41:30: adding an appropriate PATH variable for use with MacPorts. | |
export PATH=/opt/local/bin:/opt/local/sbin:$PATH | |
############################################################# | |
# RVM Environment | |
############################################################# | |
# | |
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function |
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
export EDITOR=vi | |
############################################################### | |
# Completion | |
############################################################### | |
CASE_SENSITIVE="true" | |
COMPLETION_WAITING_DOTS="true" | |
setopt bash_autolist | |
autoload -U compinit && compinit | |
zstyle ':completion:*:*:kill:*:processes' command 'ps --forest -e -o pid,user,tty,cmd' | |
autoload -U zmv | |
############################################################### | |
# Externals | |
############################################################### | |
# | |
. ~/.pathrc # paths | |
. ~/.aliasrc # aliases | |
. ~/.functionrc # functions | |
############################################################### | |
# History | |
############################################################### | |
setopt inc_append_history | |
setopt share_history | |
HISTSIZE=10000 | |
SAVEHIST=10000 | |
HISTFILE=~/.zsh_history | |
unsetopt correct_all | |
############################################################### | |
# Directory Navigation | |
############################################################### | |
# remember directories you've navigated through | |
# dirs -v to list | |
# cd +1 to jump to dir 1 from top | |
# cd -3 to jump to dir 3 from bottom | |
setopt AUTO_PUSHD | |
############################################################### | |
# Prompt | |
############################################################### | |
function git_branch_string { | |
echo "`git status | grep "^# On branch .*$" | cut -d " " -f 4`" | |
} | |
function git_branch { | |
RED="%{$fg[red]%}" | |
GREEN="%{$fg[green]%}" | |
YELLOW="%{$fg[yellow]%}" | |
git rev-parse --git-dir &> /dev/null | |
git_status="$(git status 2> /dev/null)" | |
branch_pattern="^# On branch (.*)$" | |
remote_pattern="# Your branch is (.*) of" | |
diverge_pattern="# Your branch and (.*) have diverged" | |
ahead_pattern="^# Your branch is ahead of" | |
if [[ ! ${git_status} =~ "working directory clean" ]]; then | |
state=" ${RED}⚡" | |
fi | |
if [[ ${git_status} =~ ${remote_pattern} ]]; then | |
if [[ ${git_status} =~ ${ahead_pattern} ]]; then | |
remote=" ${YELLOW}↑" | |
else | |
remote=" ${YELLOW}↓" | |
fi | |
fi | |
if [[ ${git_status} =~ ${diverge_pattern} ]]; then | |
remote=" ${YELLOW}↕" | |
fi | |
if [[ ${git_status} =~ ${branch_pattern} ]]; then | |
branch="`git_branch_string`" | |
echo " ${branch}${remote}${state}" | |
fi | |
} | |
function ruby_version { | |
echo `ruby -v | cut -d " " -f 2` 2>/dev/null | |
} | |
function precmd() { | |
local p_git_branch="`git_branch`" | |
local p_ruby_version="ruby-`ruby_version`%{$reset_color%}" | |
local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})" | |
PS1="%{$fg[yellow]%}[%n@%m] %{$fg[blue]%}%~ %{$reset_color%}$ " | |
RPROMPT="%{$fg[red]%}${return_code} %{$reset_color%} [ ${p_git_branch}%{$reset_color%} | ${p_ruby_version} |%t ]" | |
} | |
autoload -U colors && colors |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment