Created
October 2, 2012 04:59
-
-
Save dnmiller/3816248 to your computer and use it in GitHub Desktop.
zshrc
This file contains hidden or 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
# Path to your oh-my-zsh configuration. | |
ZSH=$HOME/.oh-my-zsh | |
# Pre-loaded theme | |
ZSH_THEME="agnoster" | |
# (Will change per machine) | |
DEFAULT_USER="danmiller" | |
# Dots are pretty. | |
COMPLETION_WAITING_DOTS="true" | |
# Use virtualenvwrapper if we have it. This should come before the plugins. | |
[[ -a /Library/Frameworks/Python.framework/Versions/2.7/bin/virtualenvwrapper.sh ]] \ | |
&& source /Library/Frameworks/Python.framework/Versions/2.7/bin/virtualenvwrapper.sh | |
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/ | |
plugins=(git ruby history-substring-search rbenv python pip osx brew) | |
# Load the good stuff. | |
source $ZSH/oh-my-zsh.sh | |
# Make sure we know which python is first. | |
export PATH=/Library/Frameworks/Python.framework/Versions/2.7/bin:$PATH | |
# Yes. | |
export EDITOR="vi" | |
# Aliases | |
alias del='echo Moving to ~/.Trash/ ...; mv -i $* ~/.Trash/' | |
alias cdf='eval `osascript /Applications/Utilities/OpenTerminal.app/Contents/Resources/Scripts/OpenTerminal.scpt`' | |
alias ls='ls -FG' | |
alias dir='ls -FGl' | |
alias ll="ls -l" | |
# Safe options | |
alias rm='rm -i' | |
alias mv='mv -i' | |
alias cp='cp -i' | |
# cd, because typing the backslash sucks | |
alias .='cd ../' | |
alias ..='cd ../../' | |
alias ...='cd ../../../' | |
alias ....='cd ../../../../' | |
# Function to update dotfiles. Note that the dotfiles themselves use spf-13 | |
# for vim and oh-my-zsh for zsh | |
update_dotfiles() { | |
update_zshrc() { | |
if [[ -d ~/.dotfiles/zshrc ]]; then | |
print "Pulling .zshrc from github." | |
cd .dotfiles/zshrc | |
git pull | |
cd - | |
else | |
print "No zshrc found. Cloning new from gist." | |
git clone git://gist.github.com/3816248.git ~/.dotfiles/zshrc | |
if [[ ! -L ~/.zshrc ]]; then | |
if [[ -a ~/.zshrc ]]; then | |
print "Existing .zshrc detected. Copying up to .zshrc.bak" | |
mv ~/.zshrc ~/.zshrc.bak | |
fi | |
print "Creating sym link from ~/.zshrc to ~/.dotfiles/zshrc/.zshrc" | |
ln -s ~/.dotfiles/zshrc/.zshrc ~/.zshrc | |
fi | |
usrname= | |
vared -p 'Enter user name for DEFAULT_USER: ' usrname | |
echo '\n\n# Username for which the [user]@[machine] prompt is hidden: ' >> ~/.zshrc.username | |
echo 'export DEFAULT_USER="'$usrname'"' >> ~/.zshrc.username | |
fi | |
} | |
update_vimrc() { | |
if [[ -d ~/.dotfiles/vimrc ]]; then | |
print "Pulling .vimrc from github." | |
cd .dotfiles/vimrc | |
git pull | |
cd - | |
else | |
print "No vimrc found. Cloning new from gist." | |
git clone git://gist.github.com/3877159.git ~/.dotfiles/vimrc | |
if [[ ! -L ~/.vimrc.local ]]; then | |
if [[ -a ~/.vimrc.local ]]; then | |
print "Existing .vimrc.local detected. Copying up to .vimrc.local.bak" | |
mv ~/.vimrc.local ~/.vimrc.local.bak | |
fi | |
print "Creating sym link from ~/.vimrc.local to ~/.dotfiles/vimrc/.vimrc.local" | |
ln -s ~/.dotfiles/vimrc/.vimrc.local ~/.vimrc.local | |
fi | |
fi | |
} | |
if [[ -d ~/.dotfiles ]]; then | |
print "Dotfiles found. Updating..." | |
else | |
print "No dotfiles found. Creating new dotfiles at ~/.dotfiles" | |
mkdir ~/.dotfiles | |
fi | |
update_zshrc | |
update_vimrc | |
# Don't clutter up the command-line namespace. | |
unset -f update_vimrc | |
unset -f update_zshrc | |
source ~/.zshrc | |
} | |
# Source the username if available. | |
[[ -a .zshrc.username ]] && source ~/.zshrc.username |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment