Update tmux and zsh for git

This commit is contained in:
Hunter Haugen 2014-03-11 14:10:51 -07:00
parent 98ede8b9f7
commit 1d74e0cf43
3 changed files with 42 additions and 269 deletions

View file

@ -40,11 +40,12 @@ bind Down swap-pane -D
bind C-r source-file ~/.tmux.conf
# Set default path
bind R set-option default-path "$PWD"
bind C set-option default-path ""
#bind R set-option default-path "$PWD" #removed in 1.9a
#bind C set-option default-path "" #removed in 1.9a
# Start window in the session root
bind r new-window -c -
bind r new-window
bind c new-window -c "#{pane_current_path}"
# Moving between windows
#bind " " next-window
@ -55,6 +56,8 @@ bind r new-window -c -
# splits
#unbind %
#unbind '"'
bind % split-window -h -c "#{pane_current_path}"
bind '"' split-window -v -c "#{pane_current_path}"
#bind | split-window -h
#bind - split-window -v
#bind = next-layout

View file

@ -1,246 +0,0 @@
##
## Load with `autoload -U zgitinit; zgitinit'
##
typeset -gA zgit_info
zgit_info=()
zgit_chpwd_hook() {
zgit_info_update
}
zgit_preexec_hook() {
if [[ $2 == git\ * ]] || [[ $2 == *\ git\ * ]]; then
zgit_precmd_do_update=1
fi
}
zgit_precmd_hook() {
if [ $zgit_precmd_do_update ]; then
unset zgit_precmd_do_update
zgit_info_update
fi
}
zgit_info_update() {
zgit_info=()
local gitdir="$(git rev-parse --git-dir 2>/dev/null)"
if [ $? -ne 0 ] || [ -z "$gitdir" ]; then
return
fi
zgit_info[dir]=$gitdir
zgit_info[bare]=$(git rev-parse --is-bare-repository)
zgit_info[inwork]=$(git rev-parse --is-inside-work-tree)
}
zgit_isgit() {
if [ -z "$zgit_info[dir]" ]; then
return 1
else
return 0
fi
}
zgit_inworktree() {
zgit_isgit || return
if [ "$zgit_info[inwork]" = "true" ]; then
return 0
else
return 1
fi
}
zgit_isbare() {
zgit_isgit || return
if [ "$zgit_info[bare]" = "true" ]; then
return 0
else
return 1
fi
}
zgit_head() {
zgit_isgit || return 1
if [ -z "$zgit_info[head]" ]; then
local name=''
name=$(git symbolic-ref -q HEAD)
if [ $? -eq 0 ]; then
if [[ $name == refs/(heads|tags)/* ]]; then
name=${name#refs/(heads|tags)/}
fi
else
name=$(git name-rev --name-only --no-undefined --always HEAD)
if [ $? -ne 0 ]; then
return 1
elif [[ $name == remotes/* ]]; then
name=${name#remotes/}
fi
fi
zgit_info[head]=$name
fi
echo $zgit_info[head]
}
zgit_branch() {
zgit_isgit || return 1
zgit_isbare && return 1
if [ -z "$zgit_info[branch]" ]; then
local branch=$(git symbolic-ref HEAD 2>/dev/null)
if [ $? -eq 0 ]; then
branch=${branch##*/}
else
branch=$(git name-rev --name-only --always HEAD)
fi
zgit_info[branch]=$branch
fi
echo $zgit_info[branch]
return 0
}
zgit_tracking_remote() {
zgit_isgit || return 1
zgit_isbare && return 1
local branch
if [ -n "$1" ]; then
branch=$1
elif [ -z "$zgit_info[branch]" ]; then
branch=$(zgit_branch)
[ $? -ne 0 ] && return 1
else
branch=$zgit_info[branch]
fi
local k="tracking_$branch"
local remote
if [ -z "$zgit_info[$k]" ]; then
remote=$(git config branch.$branch.remote)
zgit_info[$k]=$remote
fi
echo $zgit_info[$k]
return 0
}
zgit_tracking_merge() {
zgit_isgit || return 1
zgit_isbare && return 1
local branch
if [ -z "$zgit_info[branch]" ]; then
branch=$(zgit_branch)
[ $? -ne 0 ] && return 1
else
branch=$zgit_info[branch]
fi
local remote=$(zgit_tracking_remote $branch)
[ $? -ne 0 ] && return 1
if [ -n "$remote" ]; then # tracking branch
local merge=$(git config branch.$branch.merge)
if [ $remote != "." ]; then
merge=$remote/$(basename $merge)
fi
echo $merge
return 0
else
return 1
fi
}
zgit_isindexclean() {
zgit_isgit || return 1
if git diff --quiet --cached 2>/dev/null; then
return 0
else
return 1
fi
}
zgit_isworktreeclean() {
zgit_isgit || return 1
if git diff --quiet 2>/dev/null; then
return 0
else
return 1
fi
}
zgit_hasuntracked() {
zgit_isgit || return 1
local -a flist
flist=($(git ls-files --others --exclude-standard))
if [ $#flist -gt 0 ]; then
return 0
else
return 1
fi
}
zgit_hasunmerged() {
zgit_isgit || return 1
local -a flist
flist=($(git ls-files -u))
if [ $#flist -gt 0 ]; then
return 0
else
return 1
fi
}
zgit_svnhead() {
zgit_isgit || return 1
local commit=$1
if [ -z "$commit" ]; then
commit='HEAD'
fi
git show --raw $commit | \
grep git-svn-id | \
sed -re 's/^\s*git-svn-id: .*@([0-9]+).*$/\1/'
}
zgit_rebaseinfo() {
zgit_isgit || return 1
if [ -d $zgit_info[dir]/rebase-merge ]; then
dotest=$zgit_info[dir]/rebase-merge
elif [ -d $zgit_info[dir]/.dotest-merge ]; then
dotest=$zgit_info[dir]/.dotest-merge
elif [ -d .dotest ]; then
dotest=.dotest
else
return 1
fi
zgit_info[dotest]=$dotest
zgit_info[rb_onto]=$(cat "$dotest/onto")
if [ -f "$dotest/upstream" ]; then
zgit_info[rb_upstream]=$(cat "$dotest/upstream")
else
zgit_info[rb_upstream]=
fi
if [ -f "$dotest/orig-head" ]; then
zgit_info[rb_head]=$(cat "$dotest/orig-head")
elif [ -f "$dotest/head" ]; then
zgit_info[rb_head]=$(cat "$dotest/head")
fi
zgit_info[rb_head_name]=$(cat "$dotest/head-name")
return 0
}
chpwd_functions+=zgit_chpwd_hook
preexec_functions+=zgit_preexec_hook
precmd_functions+=zgit_precmd_hook
zgit_info_update
# vim:set ft=zsh:

56
.zshenv
View file

@ -11,15 +11,21 @@ fpath=($fpath $HOME/.zsh/func)
#typeset -u fpath
# Options
setopt appendhistory hist_ignore_space hist_ignore_all_dups extendedglob nomatch notify dvorak # correct
setopt prompt_subst appendhistory hist_ignore_space hist_ignore_all_dups extendedglob nomatch notify dvorak # correct
unsetopt beep
bindkey -e
zstyle :compinstall filename '~/.zshrc'
autoload -Uz compinit colors zgitinit && colors && zgitinit
autoload -Uz compinit colors vcs_info select-word-style && colors
compinit -u
zstyle :compinstall filename '~/.zshenv'
zstyle ':vcs_info:*' actionformats '%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%F{3}|%F{1}%a%F{5}]%f '
zstyle ':vcs_info:*' formats '%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%F{5}]%f '
zstyle ':vcs_info:*' enable git
#bindkey '^L' push-line
bindkey "^I" expand-or-complete-prefix
#select-word-style bash
umask 022
# Fix $TERM
@ -97,23 +103,29 @@ export ENVPUPPET_BASEDIR="$HOME/Documents/work/git"
export OVFTOOL='/Applications/VMware OVF Tool/ovftool'
# Prompt
#PS1="%m%# "
prompt_precmd() {
gitcolor=""
if zgit_isgit ; then
if ! zgit_isindexclean ; then
#PROMPT="[%F{$usercolor}%n%F{white}@%F{$hostcolor}%m%F{white}:%F{blue}%~%f](%F{cyan}$(zgit_branch)%f)>"
gitcolor=$fg[blue]
elif ! zgit_isworktreeclean ; then
#PROMPT="[%F{$usercolor}%n%F{white}@%F{$hostcolor}%m%F{white}:%F{blue}%~%f]>"
gitcolor=$fg[green]
fi
fi
color="%(?.$gitcolor.$fg[red])"
PROMPT="%m$color%#%{$reset_color%} "
}
#prompt_precmd() {
# gitcolor=""
# if zgit_isgit ; then
# if ! zgit_isindexclean ; then
# #PROMPT="[%F{$usercolor}%n%F{white}@%F{$hostcolor}%m%F{white}:%F{blue}%~%f](%F{cyan}$(zgit_branch)%f)>"
# gitcolor=$fg[blue]
# elif ! zgit_isworktreeclean ; then
# #PROMPT="[%F{$usercolor}%n%F{white}@%F{$hostcolor}%m%F{white}:%F{blue}%~%f]>"
# gitcolor=$fg[green]
# fi
# fi
# color="%(?.$gitcolor.$fg[red])"
# PROMPT="%m$color%#%{$reset_color%} "
#}
#precmd_functions+=prompt_precmd
PROMPT="%m%# "
vcs_info_wrapper() {
vcs_info
if [ -n "$vcs_info_msg_0_" ]; then
echo "%{$fg[grey]%}${vcs_info_msg_0_}%{$reset_color%}$del"
fi
}
RPROMPT=$'$(vcs_info_wrapper)'
if [ `uname -s` = "SunOS" ] ; then
export LANG="C"
@ -244,14 +256,14 @@ alias gd="git diff"
alias gdc="git diff --cached"
alias gc="git commit"
alias gca="git commit --amend"
alias gfa="git fetch --all"
alias gfap="git fetch --all --prune"
alias gfa="git fetch --all --prune"
alias gr="git remote -v show"
alias gp="git push"
alias gu="git pull"
alias gdw="git diff --color-words"
alias gk="gitk --all&"
alias gx="gitx --all"
alias be="bundle exec"
alias uzbl="uzbl-browser"
alias hide="SetFile -a V"
alias show="SetFile -a v"
@ -264,6 +276,10 @@ alias -s mkv="mplayer"
alias -s mpg="mplayer"
# Functions
function listvm() { curl -s --url http://vcloud.delivery.puppetlabs.net/vm/ ; }
function getvm() { curl -d --url http://vcloud.delivery.puppetlabs.net/vm/$1 ; }
function sshvm() { ssh -i ~/.ssh/id_rsa-acceptance root@$1 ; }
function rmvm() { curl -X DELETE --url http://vcloud.delivery.puppetlabs.net/vm/$1 ; }
args() { echo $#; }
title() { WINTITLE="$*"; print -Pn "\e]0;$WINTITLE\a" }
hl() { pbpaste | highlight --syntax=$1 -O rtf | pbcopy }