This commit is contained in:
GitHub Merge Button 2012-01-24 18:45:44 -08:00
commit ecb8975c1e
5 changed files with 222 additions and 6 deletions

2
dotty-symlinks.yml Normal file
View file

@ -0,0 +1,2 @@
rc: .zshrc
.: .oh-my-zsh

View file

@ -4,12 +4,19 @@ function git_prompt_info() {
echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX" echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX"
} }
# Checks if working tree is dirty parse_git_dirty () {
parse_git_dirty() { gitstat=$(git status 2>/dev/null | grep '\(# Untracked\|# Changes\|# Changed but not updated:\)')
if [[ -n $(git status -s --ignore-submodules=dirty 2> /dev/null) ]]; then
echo "$ZSH_THEME_GIT_PROMPT_DIRTY" if [[ $(echo ${gitstat} | grep -c "^\(# Untracked files:\|# Changed but not updated:\|# Changes not staged for commit:\)$") > 0 ]]; then
else echo -n "$ZSH_THEME_GIT_PROMPT_UNTRACKED"
echo "$ZSH_THEME_GIT_PROMPT_CLEAN" fi
if [[ $(echo ${gitstat} | grep -c "^# Changes to be committed:$") > 0 ]]; then
echo -n "$ZSH_THEME_GIT_PROMPT_DIRTY"
fi
if [[ $(echo ${gitstat} | grep -v '^$' | wc -l | tr -d ' ') == 0 ]]; then
echo -n "$ZSH_THEME_GIT_PROMPT_CLEAN"
fi fi
} }
@ -20,6 +27,15 @@ function git_prompt_ahead() {
fi fi
} }
#
# Will return the current branch name
# Usage example: git pull origin $(current_branch)
#
function current_branch() {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo ${ref#refs/heads/}
}
# Formats prompt string for current git commit short SHA # Formats prompt string for current git commit short SHA
function git_prompt_short_sha() { function git_prompt_short_sha() {
SHA=$(git rev-parse --short HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER" SHA=$(git rev-parse --short HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER"

138
rc Normal file
View file

@ -0,0 +1,138 @@
# The following lines were added by compinstall
# zstyle ':completion:*' completer _expand _complete _ignored _correct _approximate
zstyle ':completion:*' completer _expand _complete _ignored _correct _approximate
zstyle ':completion:*' matcher-list '' 'r:|[._-]=** r:|=**' 'l:|=* r:|=*'
zstyle :compinstall filename '/home/nate/.zshrc'
autoload -Uz compinit
compinit
# End of lines added by compinstall
# Lines configured by zsh-newuser-install
HISTFILE=~/.histfile
HISTSIZE=1000
SAVEHIST=1000
setopt autocd beep extendedglob nomatch
bindkey -v
# End of lines configured by zsh-newuser-install
# These guys know what they are doing.
export ZSH=$HOME/.oh-my-zsh
export ZSH_THEME="light"
source $ZSH/oh-my-zsh.sh
# Fuck flow control. Right off the bat.
stty -ixon
# LOL HAI
setopt DVORAK
setopt interactivecomments
unsetopt correct_all
# Important variables.
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/nate/.exe:/home/nate/.cabal/bin:/home/nate/.node_modules/.bin
# Plugins time! TODO: add more plugins
# TODO: make sure git autocomplete is happy times
plugins=(git)
# My aliases.
alias ls="ls --color=auto --hide='*.pyc'"
alias tmux "TERM=xterm-256color tmux"
alias mkdir='mkdir -p'
alias bbuild="bookbuilder -a \"Nate Soares\""
alias pacman="pacman-color"
alias aurify="makepkg -s && sudo pacman -U *.pkg.*"
alias pirate="aria2c"
alias view="feh -F"
alias pdf="apvlv"
alias pdf2="evince"
alias ebook="calibre"
alias get="sudo pacman-color -S"
alias unget="sudo pacman-color -R"
alias canget="pacman-color -Ss"
alias music="ncmpc"
alias song="cvlc"
alias dvi="evince"
alias so="source"
# This is sort of like an alias.
qfind() { find . -iname "*$1*" }
# Ls on printing
preexec() { ODIR="$(pwd)" }
precmd() { [[ "$(pwd)" != $ODIR ]] && ls --color=auto --hide='*.pyc' }
# Extract all the archives!
extract() {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xvjf $1 ;;
*.tar.gz) tar xvzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xvf $1 ;;
*.tbz2) tar xvjf $1 ;;
*.tgz) tar xvzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo "'$1' cannot be extracted via >extract<" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
# TODO: Remove when you are sure you like the new way better.
# No correcting
# unsetopt correct_all
# Complete from both ends
# setopt completeinword
# Insensitive complete
# zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}'
# Better killall
# zstyle ':completion:*:killall:*' command 'ps -u $USER -o cmd'
# Better 'word' usage (^W)
# autoload select-word-style
# select-word-style shell
# Superior globbing
# setopt extendedglob
# unsetopt caseglob
# TODO: Get some more virtualenvs back
# export WORKON_HOME=$HOME/.virtualenvs
# export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python
# source /usr/local/bin/virtualenvwrapper.sh
# Git
export GIT_EDITOR=vim
# TODO: Make the transition between term and X nicer
if [ $TERM = "screen-256color" ]; then
PS1="%{$fg[green]%}"'$(tmux display-message -p "#W")'"%{$fg[white]%}:"$PS1
PS1="%{$fg[blue]%}"'$(tmux display-message -p "#I")'"%{$fg[white]%}."$PS1
elif [ $TERM = "xterm" ]; then
if [ !`tmux attach` ]; then
TERM=xterm-256color tmux
fi
fi
# Muzak
if [ ! "`pgrep mpd`" ]; then
echo "Starting music player daemon..."
mpd
fi

BIN
refcard.pdf Normal file

Binary file not shown.

60
themes/so8res.zsh-theme Normal file
View file

@ -0,0 +1,60 @@
function collapse_pwd {
echo $(pwd | sed -e "s,^$HOME,~,")
}
function prompt_char {
git branch >/dev/null 2>/dev/null && echo '»' && return
hg root >/dev/null 2>/dev/null && echo '⇒' && return
echo '→'
}
function battery_charging {
if [[ $(acpi -b) == *Discharging* ]] ; then echo 0; else echo 1; fi
}
function battery_charge {
echo $(acpi -b | sed 's/.*, \([0-9]\+\).*/\1/')
}
function battery_mode {
if [[ $(battery_charging) -eq 1 ]] ; then
echo "%{$fg[blue]%}"
elif [[ $(battery_charge) -ge 70 ]] ; then
echo "%{$fg[green]%}"
elif [[ $(battery_charge) -ge 30 ]] ; then
echo "%{$fg[yellow]%}"
elif [[ $(battery_charge) -ge 12 ]] ; then
echo "%{$fg[red]%}%B"
else
echo "%{$fg[red]%}%S%B"
fi
}
function battery_info {
if [[ $(battery_charging) -eq 1 ]] ; then
if [[ $(battery_charge) -lt 98 ]] ; then
echo "["$(battery_charge)"%%]"
fi
else
echo "["$(battery_charge)"%%]"
fi
}
COLOR_NAME='%{$fg[magenta]%}'
COLOR_HOST='%{$fg[yellow]%}'
COLOR_DIR='%{$fg[green]%}'
COLOR_ARROW='%{$fg[cyan]%}'
COLOR_DAYNAME='%{$fg[magenta]%}'
COLOR_DAYNUM='%{$fg[magenta]%}%B'
COLOR_MONTH='%{$fg[yellow]%}%b'
COLOR_TIME='%{$fg[green]%}'
COLOR_RESET='%{$reset_color%}%s%u%b'
COLOR_SPACE='%{$fg[white]%}'
ZSH_THEME_GIT_PROMPT_PREFIX=" on %{$fg[magenta]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}"'!'
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[magenta]%}"'*'
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[green]%}"' ✔'
RPROMPT=$COLOR_DAYNAME\$(date +"%a")' '$COLOR_DAYNUM\$(date +"%d")' '$COLOR_MONTH\$(date +"%b")' '$COLOR_TIME\$(date +"%H:%M")' '\$(battery_mode)\$(battery_info)$COLOR_RESET
PROMPT=$COLOR_NAME'%n'$COLOR_SPACE'@'$COLOR_HOST'%m'$COLOR_SPACE':'$COLOR_DIR\$(collapse_pwd)\$(git_prompt_info)$COLOR_ARROW'
'\$(prompt_char)' '$COLOR_RESET