Skip to content

Instantly share code, notes, and snippets.

@pichfl
Last active February 5, 2018 12:27
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 pichfl/5553594 to your computer and use it in GitHub Desktop.
Save pichfl/5553594 to your computer and use it in GitHub Desktop.
My zsh config
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
# Oh My ZSH Configuration
ZSH=$HOME/.oh-my-zsh
ZSH_THEME="pichfl"
# CASE_SENSITIVE="true"
# DISABLE_AUTO_UPDATE="true"
# export UPDATE_ZSH_DAYS=13
# DISABLE_LS_COLORS="true"
# DISABLE_AUTO_TITLE="true"
# DISABLE_CORRECTION="true"
COMPLETION_WAITING_DOTS="true"
# Uncomment following line if you want to disable marking untracked files under
# VCS as dirty. This makes repository status check for large repositories much,
# much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
plugins=(encode64 bower brew cp django encode64 extract gem git git-extras git-flow git-remote-branch history history-substring-search node npm osx pip python rsync screen sublime terminalapp urltools vagrant)
# Load Oh My ZSH
source $ZSH/oh-my-zsh.sh
# SSH Stuff (From Ian's config)
# =============================
# Create login shortcuts from SSH config file, which has 'Host' directives.
# (If you set up an ssh host in .ssh/config, it become an alias.)
if [ -e "$HOME/.ssh/config" ]; then
for host in $(grep -E '^Host +\w+$' $HOME/.ssh/config | awk '{print $2}'); do
alias $host="ssh $host"
done
fi
# See: http://www.zsh.org/mla/users/2003/msg00937.html
autoload _ssh ; _ssh
function _ssh_hosts () {
if [[ -r "$HOME/.ssh/config" ]]; then
local IFS=" " key host
while read key host; do
if [[ "$key" == (#i)host ]]; then
_wanted hosts expl host \
compadd -M 'm:{a-zA-Z}={A-Za-z} r:|.=* r:|=*' "$@" "$host"
fi
done < "$HOME/.ssh/config"
fi
}
# Set up ssh agent if I've been using `keychain`.
for cmd in ~/bin/keychain /usr/bin/keychain; do
if [ -x "$cmd" ]; then
keychainbin=$cmd
break
fi
done
if [ -n $keychainbin ]; then
if [ -e ~/.keychain/${HOSTNAME}-sh ]; then
source ~/.keychain/${HOSTNAME}-sh >/dev/null 2>&1
fi
alias agent="$keychainbin id_dsa && source ~/.keychain/$HOST-sh"
else
alias agent="echo command not found: keychain"
fi
# A problem with screen is that old sessions lose ssh-agent awareness. This
# little system fixes it.
function {
local agentdir=~/.latestssh
local agentfile=$agentdir/$HOST.sh
mkdir -p $agentdir
chmod 0700 $agentdir >/dev/null
if [ -n "$SSH_AUTH_SOCK" -a -z $STY ]; then
rm -f $agentfile >/dev/null
echo "export SSH_AUTH_SOCK=$SSH_AUTH_SOCK" >$agentfile
chmod 0600 $agentfile >/dev/null
fi
# ...existing windows can run this alias
alias latestssh="source $agentfile; ls \$SSH_AUTH_SOCK"
# ...new windows get it automatically
if [ -n "$STY" ]; then
source $agentfile
fi
}
# Path Stuff (From Ian's config)
# ==============================
# Functions which modify the path given a directory, but only if the directory
# exists and is not already in the path. (Super useful in ~/.zshlocal)
function _prepend_to_path() {
if [ -d $1 -a -z ${path[(r)$1]} ]; then
path=($1 $path);
fi
}
function _append_to_path() {
if [ -d $1 -a -z ${path[(r)$1]} ]; then
path=($path $1);
fi
}
_prepend_to_path ~/bin
_prepend_to_path /usr/local/bin
_prepend_to_path /usr/local/sbin
_prepend_to_path /usr/local/share/npm/bin
_prepend_to_path /opt/X11/bin
_prepend_to_path /usr/local/heroku/bin
_append_to_path /usr/sbin
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/opt/X11/lib/pkgconfig
# More or less useful aliases
# ===========================
alias zshconfig="subl ~/.zshrc"
alias ohmyzsh="subl ~/.oh-my-zsh"
alias sshconfig="subl ~/.ssh/config"
alias apache='sudo apachectl'
alias django="python manage.py"
alias npm-ug="npm update -g";
alias npm-u="npm update";
alias npm-i="npm install --save";
alias npm-d="npm install --save-dev";
alias npm-g="npm install -g";
alias emptytrash="sudo rm -rf ~/.Trash/*"
alias gitdamnit='git checkout --force HEAD; git pull --recurse-submodules;'
alias lscleanup='/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user && killall Finder'
alias nerdcrap='cat /dev/urandom | xxd | grep --color=never --line-buffered "be ef"'
alias ql="qlmanage -p"
alias wow="git status"
function pman() {
man -t $1 | open -f -a /Applications/Preview.app;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment