Skip to content

Instantly share code, notes, and snippets.

@starenka
Created March 12, 2012 13:55
Show Gist options
  • Save starenka/2022088 to your computer and use it in GitHub Desktop.
Save starenka/2022088 to your computer and use it in GitHub Desktop.
function hg_prompt_info {
hg prompt --angle-brackets "\
< %{$fg[green]%}<branch>%{$reset_color%}>\
< at %{$fg[yellow]%}<tags|%{$reset_color%}, %{$fg[yellow]%}>%{$reset_color%}>\
%{$fg[green]%}<status|modified|unknown><update>%{$reset_color%}<
patches: <patches|join( → )|pre_applied(%{$fg[yellow]%})|post_applied(%{$reset_color%})|pre_unapplied(%{$fg_bold[black]%})|post_unapplied(%{$reset_color%})>>" 2>/dev/null
}
function battery_pct_remaining() { echo "$(acpi | cut -f2 -d',' | tr -cd '[:digit:]')" }
function battery_time_remaining() { echo $(acpi | cut -f3 -d',') }
function battery_time_remaining_sh() {
out=$(acpi | cut -f3 -d',' | cut -f2 -d' ')
if [ $out ]; then echo $out
else; echo 'AC'
fi
}
function battery_pct_prompt() {
b=$(battery_pct_remaining)
if [ $b -gt 50 ] ; then
color='green'
elif [ $b -gt 25 ] ; then
color='yellow'
else
color='red'
fi
echo "%{$fg[$color]%}[$(battery_pct_remaining)%% $(battery_time_remaining_sh)]%{$reset_color%}"
}
#stderr red
#exec 2>>(while read line; do
# print '\e[91m'${(q)line}'\e[0m' > /dev/tty; print -n $'\0'; done &)
HISTFILE=~/.histfile
HISTSIZE=1000
SAVEHIST=2000
unsetopt autocd
setopt prompt_subst
autoload -U colors && colors
autoload -Uz compinit
bindkey -e
zstyle :compinstall filename '/home/starenka/.zshrc'
compinit
# prompt: machine (if running screen, show window #) path
if [ x$WINDOW != x ]; then
export PS1="%{%F{yellow}%}%n%{%f%}@%m[$WINDOW] %~%# "
else
export PS1='%{%F{blue}%}%n%{%f%} %~$(hg_prompt_info) %# '
fi
RPROMPT="\$(battery_pct_prompt)"
zstyle ':completion:*' completer _expand _complete _correct _approximate
zstyle ':completion:*' expand prefix suffix
zstyle ':completion:*' file-sort name
zstyle ':completion:*' group-name ''
zstyle ':completion:*' ignore-parents parent pwd
zstyle ':completion:*' list-colors ''
zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s
zstyle ':completion:*' list-suffixes true
zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}' 'r:|[._-]=** r:|=**'
zstyle ':completion:*' max-errors 1
zstyle ':completion:*' menu select=0
zstyle ':completion:*' original true
zstyle ':completion:*' prompt 'correct %e errors'
zstyle ':completion:*' squeeze-slashes true
##aliases + exports##
source ~/.bash_aliases
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
#PATH="/opt:$PATH"
fi
export PYTHONPATH=$PYTHONPATH:~/bin
export WORKON_HOME=/data/.envs
source /usr/local/bin/virtualenvwrapper.sh
#nosetests don't eat prints
export NOSE_NOCAPTURE=1
#export HTTP_PROXY=10.10.1.10:3128
#export HTTPS_PROXY=10.10.1.11:1080
#export FTP_PROXY=10.10.1.10:3128
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment