Reworked zsh

This commit is contained in:
hellerve
2015-04-05 13:40:23 +02:00
parent f6cde060af
commit 9e6f10e473

54
zshrc
View File

@@ -4,8 +4,11 @@ zstyle ':completion:*' completer _expand _complete _ignored _approximate
zstyle ':completion:*' matcher-list 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}' 'm:{[:lower:]}={[:upper:]}' 'r:|[._-_]=** r:|=**' '' zstyle ':completion:*' matcher-list 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}' 'm:{[:lower:]}={[:upper:]}' 'r:|[._-_]=** r:|=**' ''
zstyle :compinstall filename '/Users/sidharta/.zshrc' zstyle :compinstall filename '/Users/sidharta/.zshrc'
autoload -Uz compinit -D autoload -Uz compinit -D && compinit
compinit autoload -U promptinit && promptinit
autoload -U colors && colors
autoload -Uz VCS_INFO_get_data_git && VCS_INFO_get_data_git 2> /dev/null
setopt prompt_subst
# End of lines added by compinstall # End of lines added by compinstall
# Lines configured by zsh-newuser-install # Lines configured by zsh-newuser-install
HISTFILE=~/.zsh_history HISTFILE=~/.zsh_history
@@ -30,6 +33,9 @@ alias pupgrade3="python3.4 ~/.pip-upgrade 3"
alias pupgrade="pupgrade2 && pupgrade3" alias pupgrade="pupgrade2 && pupgrade3"
alias cupgrade="cabal update; cabal list --simple-output --installed | awk '{print $1}' | uniq | xargs -I {} cabal install {} --reinstall" alias cupgrade="cabal update; cabal list --simple-output --installed | awk '{print $1}' | uniq | xargs -I {} cabal install {} --reinstall"
alias ghci="ghci -v0" alias ghci="ghci -v0"
alias ghc-sandbox="ghc -no-user-package-db -package-db .cabal-sandbox/*-packages.conf.d"
alias ghci-sandbox="ghci -no-user-package-db -package-db .cabal-sandbox/*-packages.conf.d"
alias runhaskell-sandbox="runhaskell -no-user-package-db -package-db .cabal-sandbox/*-packages.conf.d"
alias psg="ps aux | grep -v grep | grep -i -e VSZ -e" alias psg="ps aux | grep -v grep | grep -i -e VSZ -e"
alias qmake="/usr/local/Cellar/qt5/5.3.2/bin/qmake" alias qmake="/usr/local/Cellar/qt5/5.3.2/bin/qmake"
alias lupdate="/usr/local/Cellar/qt5/5.3.2/bin/lupdate" alias lupdate="/usr/local/Cellar/qt5/5.3.2/bin/lupdate"
@@ -61,7 +67,7 @@ alias tmv="tmux split-window"
alias tmh="tmux split-window -h" alias tmh="tmux split-window -h"
alias tms="tmux select-pane -t" alias tms="tmux select-pane -t"
alias tmk="killall tmux; tmux" alias tmk="killall tmux; tmux"
PROMPT="[%{$fg[red]%}%n%{$reset_color%}@%{$fg[blue]%}%m %{$fg_no_bold[yellow]%}%1~%{$reset_color%}]\$" PROMPT="%{$fg[green]%}<%{$fg[red]%}%n%{$reset_color%}@%{$fg[green]%}%m%{$fg[green]%}>%{$reset_color%} "
expand-or-complete-with-dots(){ expand-or-complete-with-dots(){
echo -n "e[31m.....\e[0m" echo -n "e[31m.....\e[0m"
@@ -91,6 +97,48 @@ case $TERM in
} ;; } ;;
esac esac
function rprompt-git-current-branch {
local name st color gitdir action
if [[ "$PWD" =~ '/\.git(/.*)?$' ]]; then
return
fi
name=`git rev-parse --abbrev-ref=loose HEAD 2> /dev/null`
if [[ -z $name ]]; then
return
fi
gitdir=`git rev-parse --git-dir 2> /dev/null`
action=`VCS_INFO_git_getaction "$gitdir"` && action="($action)"
st=`git status 2> /dev/null`
if [[ -n `echo "$st" | grep "^nothing to"` ]]; then
color=%F{green}
elif [[ -n `echo "$st" | grep "^no changes added"` ]]; then
color=%F{yellow}
elif [[ -n `echo "$st" | grep "^# Changes to be committed"` ]]; then
color=%B%F{red}
else
color=%F{red}
fi
echo "$color$name$action%f%b "
}
function cabal_sandbox_info() {
cabal_files=(*.cabal(N))
if [ $#cabal_files -gt 0 ]; then
if [ -f cabal.sandbox.config ]; then
echo "%{$fg[green]%}sandboxed%{$reset_color%}"
else
echo "%{$fg[red]%}not sandboxed%{$reset_color%}"
fi
fi
}
RPROMPT='`rprompt-git-current-branch`'
RPROMPT+="%{$fg[yellow]%}%~%{$reset_color%}"
RPROMPT+=' `cabal_sandbox_info`'
extract(){ extract(){
if [ -f $1 ] ; then if [ -f $1 ] ; then
case $1 in case $1 in