Commit 223fd60b authored by Bob Williams's avatar Bob Williams
Browse files

Merge remote-tracking branch 'upstream/master'

parents 185cb6e3 ee21fe94
The MIT License The MIT License
Copyright (c) 2009-2013 Robby Russell and contributors (see https://github.com/robbyrussell/oh-my-zsh/contributors) Copyright (c) 2009-2014 Robby Russell and contributors (see https://github.com/robbyrussell/oh-my-zsh/contributors)
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
......
...@@ -14,15 +14,25 @@ You can install this via the command line with either `curl` or `wget`. ...@@ -14,15 +14,25 @@ You can install this via the command line with either `curl` or `wget`.
h4. via `curl` h4. via `curl`
@curl -L https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | sh@ @curl -L http://install.ohmyz.sh | sh@
h4. via `wget` h4. via `wget`
@wget --no-check-certificate https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O - | sh@ @wget --no-check-certificate http://install.ohmyz.sh -O - | sh@
h3. The manual way h4. Optional: change the install directory
The default location is `~/.oh-my-zsh` (hidden in your home directory).
You can change the install directory with the ZSH environment variable, either
by running `export ZSH=/your/path` before installing, or setting it before the
end of the install pipeline like this:
@curl -L https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | ZSH=~/.dotfiles/zsh sh@
h3. The manual way
1. Clone the repository 1. Clone the repository
@git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh@ @git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh@
...@@ -35,7 +45,6 @@ h3. The manual way ...@@ -35,7 +45,6 @@ h3. The manual way
@cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc@ @cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc@
4. Set zsh as your default shell: 4. Set zsh as your default shell:
@chsh -s /bin/zsh@ @chsh -s /bin/zsh@
...@@ -46,6 +55,8 @@ h3. Problems? ...@@ -46,6 +55,8 @@ h3. Problems?
You _might_ need to modify your PATH in ~/.zshrc if you're not able to find some commands after switching to _Oh My Zsh_. You _might_ need to modify your PATH in ~/.zshrc if you're not able to find some commands after switching to _Oh My Zsh_.
If you installed manually or changed the install location, check ZSH in ~/.zshrc
h2. Usage h2. Usage
* enable the plugins you want in your @~/.zshrc@ (take a look at @plugins/@ to see what's possible) * enable the plugins you want in your @~/.zshrc@ (take a look at @plugins/@ to see what's possible)
......
...@@ -27,9 +27,9 @@ else ...@@ -27,9 +27,9 @@ else
fi fi
# List direcory contents # List direcory contents
alias lsa='ls -lah' alias lsa='ls -lah'
alias l='ls -la' alias l='ls -lah'
alias ll='ls -l' alias ll='ls -lh'
alias la='ls -lA' alias la='ls -lAh'
alias sl=ls # often screw this up alias sl=ls # often screw this up
alias afind='ack-grep -il' alias afind='ack-grep -il'
......
# TODO: Explain what some of this does.. # http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html
# http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Zle-Builtins
bindkey -e # http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Standard-Widgets
bindkey '\ew' kill-region
bindkey -s '\el' "ls\n" # Make sure that the terminal is in application mode when zle is active, since
bindkey '^r' history-incremental-search-backward # only then values from $terminfo are valid
bindkey "^[[5~" up-line-or-history if (( ${+terminfo[smkx]} )) && (( ${+terminfo[rmkx]} )); then
bindkey "^[[6~" down-line-or-history function zle-line-init() {
echoti smkx
# make search up and down work, so partially type and hit up/down to find relevant stuff }
bindkey '^[[A' up-line-or-search function zle-line-finish() {
bindkey '^[[B' down-line-or-search echoti rmkx
}
bindkey "^[[H" beginning-of-line zle -N zle-line-init
bindkey "^[[1~" beginning-of-line zle -N zle-line-finish
bindkey "^[OH" beginning-of-line fi
bindkey "^[[F" end-of-line
bindkey "^[[4~" end-of-line bindkey -e # Use emacs key bindings
bindkey "^[OF" end-of-line
bindkey ' ' magic-space # also do history expansion on space bindkey '\ew' kill-region # [Esc-w] - Kill from the cursor to the mark
bindkey -s '\el' 'ls\n' # [Esc-l] - run command: ls
bindkey "^[[1;5C" forward-word bindkey '^r' history-incremental-search-backward # [Ctrl-r] - Search backward incrementally for a specified string. The string may begin with ^ to anchor the search to the beginning of the line.
bindkey "^[[1;5D" backward-word bindkey "${terminfo[kpp]}" up-line-or-history # [PageUp] - Up a line of history
bindkey "${terminfo[knp]}" down-line-or-history # [PageDown] - Down a line of history
bindkey '^[[Z' reverse-menu-complete
bindkey "${terminfo[kcuu1]}" up-line-or-search # start typing + [Up-Arrow] - fuzzy find history forward
# Make the delete key (or Fn + Delete on the Mac) work instead of outputting a ~ bindkey "${terminfo[kcud1]}" down-line-or-search # start typing + [Down-Arrow] - fuzzy find history backward
bindkey '^?' backward-delete-char
bindkey "^[[3~" delete-char bindkey "${terminfo[khome]}" beginning-of-line # [Home] - Go to beginning of line
bindkey "^[3;5~" delete-char bindkey "${terminfo[kend]}" end-of-line # [End] - Go to end of line
bindkey "\e[3~" delete-char
bindkey ' ' magic-space # [Space] - do history expansion
bindkey '^[[1;5C' forward-word # [Ctrl-RightArrow] - move forward one word
bindkey '^[[1;5D' backward-word # [Ctrl-LeftArrow] - move backward one word
bindkey "${terminfo[kcbt]}" reverse-menu-complete # [Shift-Tab] - move through the completion menu backwards
bindkey '^?' backward-delete-char # [Backspace] - delete backward
bindkey "${terminfo[kdch1]}" delete-char # [Delete] - delete forward
# Edit the current command line in $EDITOR # Edit the current command line in $EDITOR
autoload -U edit-command-line autoload -U edit-command-line
......
# *_prompt_info functions for usage in your prompt
#
# Plugin creators, please add your *_prompt_info function to the list
# of dummy implementations to help theme creators not receiving errors
# without the need of implementing conditional clauses.
#
# See also lib/bzr.zsh, lib/git.zsh and lib/nvm.zsh for
# git_prompt_info, bzr_prompt_info and nvm_prompt_info
# Dummy implementations that return false to prevent command_not_found
# errors with themes, that implement these functions
# Real implementations will be used when the respective plugins are loaded
function chruby_prompt_info hg_prompt_info pyenv_prompt_info \
rbenv_prompt_info svn_prompt_info vi_mode_prompt_info \
virtualenv_prompt_info {
return 1
}
# oh-my-zsh supports an rvm prompt by default
# get the name of the rvm ruby version
function rvm_prompt_info() {
[ -f $HOME/.rvm/bin/rvm-prompt ] || return 1
local rvm_prompt
rvm_prompt=$($HOME/.rvm/bin/rvm-prompt ${=ZSH_THEME_RVM_PROMPT_OPTIONS} 2>/dev/null)
[[ "${rvm_prompt}x" == "x" ]] && return 1
echo "${ZSH_THEME_RVM_PROMPT_PREFIX:=(}${rvm_prompt}${ZSH_THEME_RVM_PROMPT_SUFFIX:=)}"
}
# use this to enable users to see their ruby version, no matter which
# version management system they use
function ruby_prompt_info() {
echo $(rvm_prompt_info || rbenv_prompt_info || chruby_prompt_info)
}
# using the rbenv plugin will override this with a real implementation
function rbenv_prompt_info() {}
# get the name of the ruby version
function rvm_prompt_info() {
[ -f $HOME/.rvm/bin/rvm-prompt ] || return
local rvm_prompt
rvm_prompt=$($HOME/.rvm/bin/rvm-prompt ${ZSH_THEME_RVM_PROMPT_OPTIONS} 2>/dev/null)
[[ "${rvm_prompt}x" == "x" ]] && return
echo "${ZSH_THEME_RVM_PROMPT_PREFIX:=(}${rvm_prompt}${ZSH_THEME_RVM_PROMPT_SUFFIX:=)}"
}
...@@ -27,9 +27,8 @@ function omz_termsupport_preexec { ...@@ -27,9 +27,8 @@ function omz_termsupport_preexec {
emulate -L zsh emulate -L zsh
setopt extended_glob setopt extended_glob
local CMD=${1[(wr)^(*=*|sudo|ssh|rake|-*)]} #cmd name only, or if this is sudo or ssh, the next cmd local CMD=${1[(wr)^(*=*|sudo|ssh|rake|-*)]} #cmd name only, or if this is sudo or ssh, the next cmd
local LINE="${2:gs/$/\\$}" local LINE="${2:gs/%/%%}"
LINE="${LINE:gs/%/%%}" title '$CMD' '%100>...>$LINE%<<'
title "$CMD" "%100>...>$LINE%<<"
} }
autoload -U add-zsh-hook autoload -U add-zsh-hook
......
export AWS_HOME=~/.aws
function agp {
echo $AWS_DEFAULT_PROFILE
}
function asp {
export AWS_DEFAULT_PROFILE=$1
export RPROMPT="<aws:$AWS_DEFAULT_PROFILE>"
}
function aws_profiles {
reply=($(grep profile $AWS_HOME/config|sed -e 's/.*profile \([a-zA-Z0-9_-]*\).*/\1/'))
}
compctl -K aws_profiles asp
source `which aws_zsh_completer.sh`
...@@ -18,11 +18,15 @@ if [[ $(uname) == "Darwin" ]] ; then ...@@ -18,11 +18,15 @@ if [[ $(uname) == "Darwin" ]] ; then
echo $i echo $i
} }
function plugged_in() {
[ $(ioreg -rc AppleSmartBattery | grep -c '^.*"ExternalConnected"\ =\ Yes') -eq 1 ]
}
function battery_pct_remaining() { function battery_pct_remaining() {
if [[ $(ioreg -rc AppleSmartBattery | grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]] ; then if plugged_in ; then
battery_pct
else
echo "External Power" echo "External Power"
else
battery_pct
fi fi
} }
......
...@@ -11,10 +11,25 @@ _brew_installed_formulae() { ...@@ -11,10 +11,25 @@ _brew_installed_formulae() {
installed_formulae=(`brew list`) installed_formulae=(`brew list`)
} }
_brew_installed_taps() {
installed_taps=(`brew tap`)
}
_brew_outdated_formulae() {
outdated_formulae=(`brew outdated`)
}
_brew_running_services() {
running_services=(`brew services list | awk '{print $1}'`)
}
local -a _1st_arguments local -a _1st_arguments
_1st_arguments=( _1st_arguments=(
'audit:check formulae for Homebrew coding style'
'bundle:look for a Brewfile and run each line as a brew command'
'cat:display formula file for a formula' 'cat:display formula file for a formula'
'cleanup:uninstall unused and old versions of packages' 'cleanup:uninstall unused and old versions of packages'
'commands:show a list of commands'
'create:create a new formula' 'create:create a new formula'
'deps:list dependencies and dependants of a formula' 'deps:list dependencies and dependants of a formula'
'doctor:audits your installation for common issues' 'doctor:audits your installation for common issues'
...@@ -22,27 +37,38 @@ _1st_arguments=( ...@@ -22,27 +37,38 @@ _1st_arguments=(
'home:visit the homepage of a formula or the brew project' 'home:visit the homepage of a formula or the brew project'
'info:information about a formula' 'info:information about a formula'
'install:install a formula' 'install:install a formula'
'reinstall:install a formula anew; re-using its current options'
'link:link a formula' 'link:link a formula'
'list:list files in a formula or not-installed formulae' 'list:list files in a formula or not-installed formulae'
'log:git commit log for a formula' 'log:git commit log for a formula'
'missing:check all installed formuale for missing dependencies.' 'missing:check all installed formuale for missing dependencies.'
'options:display install options specific to formula.' 'outdated:list formulae for which a newer version is available'
'outdated:list formulas for which a newer version is available' 'pin:pin specified formulae'
'prune:remove dead links' 'prune:remove dead links'
'reinstall:reinstall a formula'
'remove:remove a formula' 'remove:remove a formula'
'search:search for a formula (/regex/ or string)' 'search:search for a formula (/regex/ or string)'
'server:start a local web app that lets you browse formulae (requires Sinatra)' 'server:start a local web app that lets you browse formulae (requires Sinatra)'
'services:manage background services via launchctl' 'services:small wrapper around `launchctl` for supported formulae'
'tap:tap a new formula repository from GitHub, or list existing taps'
'unlink:unlink a formula' 'unlink:unlink a formula'
'unpin:unpin specified formulae'
'untap:remove a tapped repository'
'update:freshen up links' 'update:freshen up links'
'upgrade:upgrade outdated formulae' 'upgrade:upgrade outdated formulae'
'uses:show formulas which depend on a formula' 'uses:show formulae which depend on a formula'
'versions:show all available formula versions' )
local -a _service_arguments
_service_arguments=(
'cleanup:get rid of stale services and unused plists'
'list:list all services managed by `brew services`'
'restart:gracefully restart selected service'
'start:start selected service'
'stop:stop selected service'
) )
local expl local expl
local -a formulae installed_formulae local -a formulae installed_formulae installed_taps outdated_formulae running_services
_arguments \ _arguments \
'(-v)-v[verbose]' \ '(-v)-v[verbose]' \
...@@ -61,13 +87,13 @@ if (( CURRENT == 1 )); then ...@@ -61,13 +87,13 @@ if (( CURRENT == 1 )); then
fi fi
case "$words[1]" in case "$words[1]" in
search|-S) install|reinstall|audit|home|homepage|log|info|abv|uses|cat|deps|edit|options)
_arguments \ _brew_all_formulae
'(--macports)--macports[search the macports repository]' \ _wanted formulae expl 'all formulae' compadd -a formulae ;;
'(--fink)--fink[search the fink repository]' ;;
list|ls) list|ls)
_arguments \ _arguments \
'(--unbrewed)--unbrewed[files in brew --prefix not controlled by brew]' \ '(--unbrewed)--unbrewed[files in brew --prefix not controlled by brew]' \
'(--pinned)--pinned[list all versions of pinned formulae]' \
'(--versions)--versions[list all installed versions of a formula]' \ '(--versions)--versions[list all installed versions of a formula]' \
'1: :->forms' && return 0 '1: :->forms' && return 0
...@@ -75,10 +101,27 @@ case "$words[1]" in ...@@ -75,10 +101,27 @@ case "$words[1]" in
_brew_installed_formulae _brew_installed_formulae
_wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae _wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae
fi ;; fi ;;
install|home|homepage|log|info|abv|uses|cat|deps|edit|options|versions) remove|rm|uninstall|unlink|cleanup|link|ln|pin|unpin)
_brew_all_formulae
_wanted formulae expl 'all formulae' compadd -a formulae ;;
reinstall|remove|rm|uninstall|unlink|cleanup|link|ln)
_brew_installed_formulae _brew_installed_formulae
_wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae ;; _wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae ;;
search|-S)
_arguments \
'(--macports)--macports[search the macports repository]' \
'(--fink)--fink[search the fink repository]' ;;
services)
if [[ -n "$words[2]" ]]; then
case "$words[2]" in
restart|start|stop)
_brew_running_services
_wanted running_services expl 'running services' compadd -a running_services ;;
esac
else
_describe -t commands "brew services subcommand" _service_arguments
fi ;;
untap)
_brew_installed_taps
_wanted installed_taps expl 'installed taps' compadd -a installed_taps ;;
upgrade)
_brew_outdated_formulae
_wanted outdated_formulae expl 'outdated formulae' compadd -a outdated_formulae ;;
esac esac
################################################################################
# catimg script by Eduardo San Martin Morote aka Posva #
# http://posva.net #
# #
# Ouput the content of an image to the stdout using the 256 colors of the #
# terminal. #
# Github: https://github.com/posva/catimg #
################################################################################
function catimg() {
if [[ -x `which convert` ]]; then
zsh $ZSH/plugins/catimg/catimg.sh $@
else
echo "catimg need convert (ImageMagick) to work)"
fi
}
################################################################################
# catimg script by Eduardo San Martin Morote aka Posva #
# http://posva.net #
# #
# Ouput the content of an image to the stdout using the 256 colors of the #
# terminal. #
# Github: https://github.com/posva/catimg #
################################################################################
function help() {
echo "Usage catimg [-h] [-w width] [-c char] img"
echo "By default char is \" \" and w is the terminal width"
}
# VARIABLES
COLOR_FILE=$(dirname $0)/colors.png
CHAR=" "
WIDTH=""
IMG=""
while getopts qw:c:h opt; do
case "$opt" in
w) WIDTH="$OPTARG" ;;
c) CHAR="$OPTARG" ;;
h) help; exit ;;
*) help ; exit 1;;
esac
done
while [ "$1" ]; do
IMG="$1"
shift
done
if [ "$IMG" = "" -o ! -f "$IMG" ]; then
help
exit 1
fi
if [ ! "$WIDTH" ]; then
COLS=$(expr $(tput cols) "/" $(echo -n "$CHAR" | wc -c))
else
COLS=$(expr $WIDTH "/" $(echo -n "$CHAR" | wc -c))
fi
WIDTH=$(convert "$IMG" -print "%w\n" /dev/null)
if [ "$WIDTH" -gt "$COLS" ]; then
WIDTH=$COLS
fi
REMAP=""
if convert "$IMG" -resize $COLS\> +dither -remap $COLOR_FILE /dev/null ; then
REMAP="-remap $COLOR_FILE"
else
echo "The version of convert is too old, don't expect good results :(" >&2
#convert "$IMG" -colors 256 PNG8:tmp.png
#IMG="tmp.png"
fi
# Display the image
I=0
convert "$IMG" -resize $COLS\> +dither `echo $REMAP` txt:- 2>/dev/null |
sed -e 's/.*none.*/NO NO NO/g' -e '1d;s/^.*(\(.*\)[,)].*$/\1/g;y/,/ /' |
while read R G B f; do
if [ ! "$R" = "NO" ]; then
if [ "$R" -eq "$G" -a "$G" -eq "$B" ]; then
((
I++,
IDX = 232 + R * 23 / 255
))
else
((
I++,
IDX = 16
+ R * 5 / 255 * 36
+ G * 5 / 255 * 6
+ B * 5 / 255
))
fi
#echo "$R,$G,$B: $IDX"
echo -ne "\e[48;5;${IDX}m${CHAR}"
else
(( I++ ))
echo -ne "\e[0m${CHAR}"
fi
# New lines
(( $I % $WIDTH )) || echo -e "\e[0m"
done
...@@ -111,7 +111,7 @@ __ps() { ...@@ -111,7 +111,7 @@ __ps() {
'-beforeId="[Show only container created before Id, include non-running ones.]' \ '-beforeId="[Show only container created before Id, include non-running ones.]' \
'-l[Show only the latest created container, include non-running ones.]' \ '-l[Show only the latest created container, include non-running ones.]' \
'-n=[Show n last created containers, include non-running ones.]' \ '-n=[Show n last created containers, include non-running ones.]' \
'-notrurrrrnc[Dont truncate output]' \ '-notrunc[Dont truncate output]' \
'-q[Only display numeric IDs]' \ '-q[Only display numeric IDs]' \
'-s[Display sizes]' \ '-s[Display sizes]' \
'-sinceId="[Show only containers created since Id, include non-running ones.]' '-sinceId="[Show only containers created since Id, include non-running ones.]'
......
# Emacs 23 daemon capability is a killing feature.
# One emacs process handles all your frames whether
# you use a frame opened in a terminal via a ssh connection or X frames
# opened on the same host.
# Benefits are multiple
# - You don't have the cost of starting Emacs all the time anymore
# - Opening a file is as fast as Emacs does not have anything else to do.
# - You can share opened buffered across opened frames.
# - Configuration changes made at runtime are applied to all frames.
if "$ZSH/tools/require_tool.sh" emacs 23 2>/dev/null ; then
export EMACS_PLUGIN_LAUNCHER="$ZSH/plugins/emacs/emacsclient.sh"
# set EDITOR if not already defined.
export EDITOR="${EDITOR:-${EMACS_PLUGIN_LAUNCHER}}"
alias emacs="$EMACS_PLUGIN_LAUNCHER --no-wait"
alias e=emacs
# same than M-x eval but from outside Emacs.
alias eeval="$EMACS_PLUGIN_LAUNCHER --eval"
# create a new X frame
alias eframe='emacsclient --alternate-editor "" --create-frame'
# to code all night long
alias emasc=emacs
alias emcas=emacs
# Write to standard output the path to the file
# opened in the current buffer.
function efile {
local cmd="(buffer-file-name (window-buffer))"
"$EMACS_PLUGIN_LAUNCHER" --eval "$cmd" | tr -d \"
}
# Write to standard output the directory of the file
# opened in the the current buffer
function ecd {
local cmd="(let ((buf-name (buffer-file-name (window-buffer))))
(if buf-name (file-name-directory buf-name)))"
local dir="$($EMACS_PLUGIN_LAUNCHER --eval $cmd | tr -d \")"
if [ -n "$dir" ] ;then
echo "$dir"
else
echo "can not deduce current buffer filename." >/dev/stderr
return 1
fi
}
fi
## Local Variables:
## mode: sh
## End:
#!/bin/sh
# get list of available X windows.
x=`emacsclient --alternate-editor '' --eval '(x-display-list)' 2>/dev/null`
if [ -z "$x" ] ;then
# Create one if there is no X window yet.
emacsclient --alternate-editor "" --create-frame "$@"
else
# prevent creating another X frame if there is at least one present.
emacsclient --alternate-editor "" "$@"
fi
alias gemb="gem build *.gemspec"
alias gemp="gem push *.gem"
# gemy GEM 0.0.0 = gem yank GEM -v 0.0.0
function gemy {
gem yank $1 -v $2
}
\ No newline at end of file
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: UTF-8 -*- # -*- coding: UTF-8 -*-
from subprocess import Popen, PIPE
import re
# change those symbols to whatever you prefer # change those symbols to whatever you prefer
symbols = {'ahead of': '↑', 'behind': '↓', 'staged':'♦', 'changed':'‣', 'untracked':'…', 'clean':'⚡', 'unmerged':'≠', 'sha1':':'} symbols = {
'ahead of': '↑',
from subprocess import Popen, PIPE 'behind': '↓',
'staged': '♦',
'changed': '‣',
'untracked': '…',
'clean': '⚡',
'unmerged': '≠',
'sha1': ':'
}
output,error = Popen(['git','status'], stdout=PIPE, stderr=PIPE).communicate() output, error = Popen(
['git', 'status'], stdout=PIPE, stderr=PIPE).communicate()
if error: if error:
import sys import sys
sys.exit(0) sys.exit(0)
lines = output.splitlines() lines = output.splitlines()
import re behead_re = re.compile(
behead_re = re.compile(r"^# Your branch is (ahead of|behind) '(.*)' by (\d+) commit") r"^# Your branch is (ahead of|behind) '(.*)' by (\d+) commit")
diverge_re = re.compile(r"^# and have (\d+) and (\d+) different") diverge_re = re.compile(r"^# and have (\d+) and (\d+) different")
status = '' status = ''
...@@ -23,6 +33,7 @@ changed = re.compile(r'^# Changed but not updated:$', re.MULTILINE) ...@@ -23,6 +33,7 @@ changed = re.compile(r'^# Changed but not updated:$', re.MULTILINE)
untracked = re.compile(r'^# Untracked files:$', re.MULTILINE) untracked = re.compile(r'^# Untracked files:$', re.MULTILINE)
unmerged = re.compile(r'^# Unmerged paths:$', re.MULTILINE) unmerged = re.compile(r'^# Unmerged paths:$', re.MULTILINE)
def execute(*command): def execute(*command):
out, err = Popen(stdout=PIPE, stderr=PIPE, *command).communicate() out, err = Popen(stdout=PIPE, stderr=PIPE, *command).communicate()
if not err: if not err:
...@@ -32,17 +43,16 @@ def execute(*command): ...@@ -32,17 +43,16 @@ def execute(*command):
return nb return nb
if staged.search(output): if staged.search(output):
nb = execute(['git','diff','--staged','--name-only','--diff-filter=ACDMRT']) nb = execute(
['git', 'diff', '--staged', '--name-only', '--diff-filter=ACDMRT'])
status += '%s%s' % (symbols['staged'], nb) status += '%s%s' % (symbols['staged'], nb)
if unmerged.search(output): if unmerged.search(output):
nb = execute(['git','diff', '--staged','--name-only', '--diff-filter=U']) nb = execute(['git', 'diff', '--staged', '--name-only', '--diff-filter=U'])
status += '%s%s' % (symbols['unmerged'], nb) status += '%s%s' % (symbols['unmerged'], nb)
if changed.search(output): if changed.search(output):
nb = execute(['git','diff','--name-only', '--diff-filter=ACDMRT']) nb = execute(['git', 'diff', '--name-only', '--diff-filter=ACDMRT'])
status += '%s%s' % (symbols['changed'], nb) status += '%s%s' % (symbols['changed'], nb)
if untracked.search(output): if untracked.search(output):
## nb = len(Popen(['git','ls-files','--others','--exclude-standard'],stdout=PIPE).communicate()[0].splitlines())
## status += "%s" % (symbols['untracked']*(nb//3 + 1), )
status += symbols['untracked'] status += symbols['untracked']
if status == '': if status == '':
status = symbols['clean'] status = symbols['clean']
...@@ -51,9 +61,13 @@ remote = '' ...@@ -51,9 +61,13 @@ remote = ''
bline = lines[0] bline = lines[0]
if bline.find('Not currently on any branch') != -1: if bline.find('Not currently on any branch') != -1:
branch = symbols['sha1']+ Popen(['git','rev-parse','--short','HEAD'], stdout=PIPE).communicate()[0][:-1] branch = symbols['sha1'] + Popen([
'git',
'rev-parse',
'--short',
'HEAD'], stdout=PIPE).communicate()[0][:-1]
else: else:
branch = bline.split(' ')[3] branch = bline.split(' ')[-1]
bstatusline = lines[1] bstatusline = lines[1]
match = behead_re.match(bstatusline) match = behead_re.match(bstatusline)
if match: if match:
...@@ -62,7 +76,7 @@ else: ...@@ -62,7 +76,7 @@ else:
elif lines[2:]: elif lines[2:]:
div_match = diverge_re.match(lines[2]) div_match = diverge_re.match(lines[2])
if div_match: if div_match:
remote = "{behind}{1}{ahead of}{0}".format(*div_match.groups(), **symbols) remote = "{behind}{1}{ahead of}{0}".format(
*div_match.groups(), **symbols)
print '\n'.join([branch,remote,status])
print('\n'.join([branch, remote, status]))
...@@ -62,8 +62,10 @@ alias glgg='git log --graph --max-count=10' ...@@ -62,8 +62,10 @@ alias glgg='git log --graph --max-count=10'
compdef _git glgg=git-log compdef _git glgg=git-log
alias glgga='git log --graph --decorate --all' alias glgga='git log --graph --decorate --all'
compdef _git glgga=git-log compdef _git glgga=git-log
alias glo='git log --oneline' alias glo='git log --oneline --decorate --color'
compdef _git glo=git-log compdef _git glo=git-log
alias glog='git log --oneline --decorate --color --graph'
compdef _git glog=git-log
alias gss='git status -s' alias gss='git status -s'
compdef _git gss=git-status compdef _git gss=git-status
alias ga='git add' alias ga='git add'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment