diff --git a/dotty-symlinks.yml b/dotty-symlinks.yml new file mode 100644 index 000000000..07a80a51e --- /dev/null +++ b/dotty-symlinks.yml @@ -0,0 +1,2 @@ +rc: .zshrc +.: .oh-my-zsh diff --git a/lib/git.zsh b/lib/git.zsh index defa062c6..49d1018e5 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -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" } -# Checks if working tree is dirty -parse_git_dirty() { - if [[ -n $(git status -s --ignore-submodules=dirty 2> /dev/null) ]]; then - echo "$ZSH_THEME_GIT_PROMPT_DIRTY" - else - echo "$ZSH_THEME_GIT_PROMPT_CLEAN" +parse_git_dirty () { + gitstat=$(git status 2>/dev/null | grep '\(# Untracked\|# Changes\|# Changed but not updated:\)') + + if [[ $(echo ${gitstat} | grep -c "^\(# Untracked files:\|# Changed but not updated:\|# Changes not staged for commit:\)$") > 0 ]]; then + echo -n "$ZSH_THEME_GIT_PROMPT_UNTRACKED" + 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 } @@ -20,6 +27,15 @@ function git_prompt_ahead() { 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 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" diff --git a/rc b/rc new file mode 100644 index 000000000..d97aa33b8 --- /dev/null +++ b/rc @@ -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 diff --git a/refcard.pdf b/refcard.pdf new file mode 100644 index 000000000..5e4e5f090 Binary files /dev/null and b/refcard.pdf differ diff --git a/themes/so8res.zsh-theme b/themes/so8res.zsh-theme new file mode 100644 index 000000000..b8da08fb8 --- /dev/null +++ b/themes/so8res.zsh-theme @@ -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