mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-01-30 02:44:42 +01:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
9cdd70dc9d
58 changed files with 1744 additions and 230 deletions
|
|
@ -1,5 +1,4 @@
|
|||
A handful of functions, auto-complete helpers, and stuff that makes you shout...
|
||||
|
||||
oh-my-zsh is an open source, community-driven framework for managing your ZSH configuration. It comes bundled with a ton of helpful functions, helpers, plugins, themes, and few things that make you shout...
|
||||
|
||||
bq. "OH MY ZSHELL!"
|
||||
|
||||
|
|
@ -63,6 +62,15 @@ If you want to override any of the default behavior, just add a new file (ending
|
|||
If you have many functions which go well together you can put them as a *.plugin.zsh file in the @custom/plugins/@ directory and then enable this plugin.
|
||||
If you would like to override the functionality of a plugin distributed with oh-my-zsh, create a plugin of the same name in the @custom/plugins/@ directory and it will be loaded instead of the one in @plugins/@.
|
||||
|
||||
h3. Updates
|
||||
|
||||
By default you will be prompted to check for updates. If you would like oh-my-zsh to automatically update itself without prompting you, set the following in your ~/.zshrc
|
||||
|
||||
@DISABLE_UPDATE_PROMPT=true@
|
||||
|
||||
To disable updates entirely, put this in your ~/.zshrc
|
||||
|
||||
@DISABLE_AUTO_UPDATE=true@
|
||||
|
||||
h3. Uninstalling
|
||||
|
||||
|
|
@ -76,9 +84,7 @@ h3. (Don't) Send us your theme! (for now)
|
|||
|
||||
-I'm hoping to collect a bunch of themes for our command prompts. You can see existing ones in the @themes/@ directory.-
|
||||
|
||||
We have enough themes for the time being. Please fork the project and add on in there, you can let people know how to grab it from there.
|
||||
|
||||
|
||||
We have enough themes for the time being. Please fork the project and add on in there, you can let people know how to grab it from there.
|
||||
|
||||
h2. Contributors
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ alias history='fc -l 1'
|
|||
|
||||
# List direcory contents
|
||||
alias lsa='ls -lah'
|
||||
alias l='ls -lA1'
|
||||
#alias l='ls -la'
|
||||
alias ll='ls -l'
|
||||
alias la='ls -lA'
|
||||
alias sl=ls # often screw this up
|
||||
|
|
|
|||
|
|
@ -34,8 +34,10 @@ cdpath=(.)
|
|||
# use /etc/hosts and known_hosts for hostname completion
|
||||
[ -r /etc/ssh/ssh_known_hosts ] && _global_ssh_hosts=(${${${${(f)"$(</etc/ssh/ssh_known_hosts)"}:#[\|]*}%%\ *}%%,*}) || _global_ssh_hosts=()
|
||||
[ -r ~/.ssh/known_hosts ] && _ssh_hosts=(${${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[\|]*}%%\ *}%%,*}) || _ssh_hosts=()
|
||||
[ -r ~/.ssh/config ] && _ssh_config=($(cat ~/.ssh/config | sed -ne 's/Host[=\t ]//p')) || _ssh_config=()
|
||||
[ -r /etc/hosts ] && : ${(A)_etc_hosts:=${(s: :)${(ps:\t:)${${(f)~~"$(</etc/hosts)"}%%\#*}##[:blank:]#[^[:blank:]]#}}} || _etc_hosts=()
|
||||
hosts=(
|
||||
"$_ssh_config[@]"
|
||||
"$_global_ssh_hosts[@]"
|
||||
"$_ssh_hosts[@]"
|
||||
"$_etc_hosts[@]"
|
||||
|
|
@ -43,6 +45,7 @@ hosts=(
|
|||
localhost
|
||||
)
|
||||
zstyle ':completion:*:hosts' hosts $hosts
|
||||
zstyle ':completion:*' users off
|
||||
|
||||
# Use caching so that commands like apt and dpkg complete are useable
|
||||
zstyle ':completion::complete:*' use-cache 1
|
||||
|
|
|
|||
|
|
@ -1,2 +1,14 @@
|
|||
# correct commands, but not any arguments (correct_all would do that)
|
||||
setopt correct
|
||||
if [[ "$DISABLE_CORRECTION" == "true" ]]; then
|
||||
return
|
||||
else
|
||||
setopt correct_all
|
||||
alias man='nocorrect man'
|
||||
alias mv='nocorrect mv'
|
||||
alias mysql='nocorrect mysql'
|
||||
alias mkdir='nocorrect mkdir'
|
||||
alias gist='nocorrect gist'
|
||||
alias heroku='nocorrect heroku'
|
||||
alias ebuild='nocorrect ebuild'
|
||||
alias hpodder='nocorrect hpodder'
|
||||
alias sudo='nocorrect sudo'
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
setopt auto_name_dirs
|
||||
setopt auto_pushd
|
||||
setopt pushd_ignore_dups
|
||||
setopt pushdminus
|
||||
|
||||
alias ..='cd ..'
|
||||
alias cd..='cd ..'
|
||||
|
|
@ -11,14 +12,14 @@ alias cd.....='cd ../../../..'
|
|||
alias cd/='cd /'
|
||||
|
||||
alias 1='cd -'
|
||||
alias 2='cd +2'
|
||||
alias 3='cd +3'
|
||||
alias 4='cd +4'
|
||||
alias 5='cd +5'
|
||||
alias 6='cd +6'
|
||||
alias 7='cd +7'
|
||||
alias 8='cd +8'
|
||||
alias 9='cd +9'
|
||||
alias 2='cd -2'
|
||||
alias 3='cd -3'
|
||||
alias 4='cd -4'
|
||||
alias 5='cd -5'
|
||||
alias 6='cd -6'
|
||||
alias 7='cd -7'
|
||||
alias 8='cd -8'
|
||||
alias 9='cd -9'
|
||||
|
||||
cd () {
|
||||
if [[ "x$*" == "x..." ]]; then
|
||||
|
|
@ -29,6 +30,9 @@ cd () {
|
|||
cd ../../../..
|
||||
elif [[ "x$*" == "x......" ]]; then
|
||||
cd ../../../../..
|
||||
elif [ -d ~/.autoenv ]; then
|
||||
source ~/.autoenv/activate.sh
|
||||
autoenv_cd "$@"
|
||||
else
|
||||
builtin cd "$@"
|
||||
fi
|
||||
|
|
|
|||
16
lib/git.zsh
16
lib/git.zsh
|
|
@ -14,14 +14,20 @@ parse_git_dirty() {
|
|||
if [[ "$(git config --get oh-my-zsh.hide-status)" != "1" ]]; then
|
||||
if [[ $POST_1_7_2_GIT -gt 0 ]]; then
|
||||
SUBMODULE_SYNTAX="--ignore-submodules=dirty"
|
||||
fi
|
||||
GIT_STATUS=$(git status -s ${SUBMODULE_SYNTAX} 2> /dev/null | tail -n1)
|
||||
if [[ -n $GIT_STATUS && "$GIT_STATUS" != "$CLEAN_MESSAGE" ]]; then
|
||||
fi
|
||||
if [[ "$DISABLE_UNTRACKED_FILES_DIRTY" != "true" ]]; then
|
||||
GIT_STATUS=$(git status -s ${SUBMODULE_SYNTAX} 2> /dev/null | tail -n1)
|
||||
else
|
||||
GIT_STATUS=$(git status -s ${SUBMODULE_SYNTAX} -uno 2> /dev/null | tail -n1)
|
||||
fi
|
||||
if [[ -n $(git status -s ${SUBMODULE_SYNTAX} -uno 2> /dev/null) ]]; then
|
||||
echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
|
||||
else
|
||||
echo "$ZSH_THEME_GIT_PROMPT_CLEAN"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "$ZSH_THEME_GIT_PROMPT_CLEAN"
|
||||
fi
|
||||
}
|
||||
|
||||
# get the difference between the local and remote branches
|
||||
|
|
|
|||
2
lib/rbenv.zsh
Normal file
2
lib/rbenv.zsh
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
# using the rbenv plugin will override this with a real implementation
|
||||
function rbenv_prompt_info() {}
|
||||
|
|
@ -8,7 +8,7 @@ function title {
|
|||
fi
|
||||
if [[ "$TERM" == screen* ]]; then
|
||||
print -Pn "\ek$1:q\e\\" #set screen hardstatus, usually truncated at 20 chars
|
||||
elif [[ "$TERM" == xterm* ]] || [[ $TERM == rxvt* ]] || [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
|
||||
elif [[ "$TERM" == xterm* ]] || [[ $TERM == rxvt* ]] || [[ $TERM == ansi ]] || [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
|
||||
print -Pn "\e]2;$2:q\a" #set window name
|
||||
print -Pn "\e]1;$1:q\a" #set icon (=tab) name (will override window name on broken terminal)
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -73,6 +73,9 @@ else
|
|||
if [ -f "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme" ]
|
||||
then
|
||||
source "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme"
|
||||
elif [ -f "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme" ]
|
||||
then
|
||||
source "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme"
|
||||
else
|
||||
source "$ZSH/themes/$ZSH_THEME.zsh-theme"
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ if [[ -x `which yaourt` ]]; then
|
|||
}
|
||||
alias yaconf='yaourt -C' # Fix all configuration files with vimdiff
|
||||
# Pacman - https://wiki.archlinux.org/index.php/Pacman_Tips
|
||||
alias yaupg='yaourt -Syu' # Synchronize with repositories before upgrading packages that are out of date on the local system.
|
||||
alias yaupg='yaourt -Syua' # Synchronize with repositories before upgrading packages (AUR packages too) that are out of date on the local system.
|
||||
alias yasu='yaourt --sucre' # Same as yaupg, but without confirmation
|
||||
alias yain='yaourt -S' # Install specific package(s) from the repositories
|
||||
alias yains='yaourt -U' # Install specific package not from the repositories but from a file
|
||||
|
|
@ -18,6 +18,8 @@ if [[ -x `which yaourt` ]]; then
|
|||
alias yareps='yaourt -Ss' # Search for package(s) in the repositories
|
||||
alias yaloc='yaourt -Qi' # Display information about a given package in the local database
|
||||
alias yalocs='yaourt -Qs' # Search for package(s) in the local database
|
||||
alias yalst='yaourt -Qe' # List installed packages, even those installed from AUR (they're tagged as "local")
|
||||
alias yaorph='yaourt -Qtd' # Remove orphans using yaourt
|
||||
# Additional yaourt alias examples
|
||||
if [[ -x `which abs` ]]; then
|
||||
alias yaupd='yaourt -Sy && sudo abs' # Update and refresh the local package and ABS databases against repositories
|
||||
|
|
|
|||
18
plugins/autoenv/autoenv.plugin.zsh
Normal file
18
plugins/autoenv/autoenv.plugin.zsh
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
# The use_env call below is a reusable command to activate/create a new Python
|
||||
# virtualenv, requiring only a single declarative line of code in your .env files.
|
||||
# It only performs an action if the requested virtualenv is not the current one.
|
||||
use_env() {
|
||||
typeset venv
|
||||
venv="$1"
|
||||
if [[ "${VIRTUAL_ENV:t}" != "$venv" ]]; then
|
||||
if workon | grep -q "$venv"; then
|
||||
workon "$venv"
|
||||
else
|
||||
echo -n "Create virtualenv $venv now? (Yn) "
|
||||
read answer
|
||||
if [[ "$answer" == "Y" ]]; then
|
||||
mkvirtualenv "$venv"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
|
@ -10,12 +10,16 @@
|
|||
|
||||
if [[ $(uname) == "Darwin" ]] ; then
|
||||
|
||||
function battery_pct() {
|
||||
typeset -F maxcapacity=$(ioreg -rc "AppleSmartBattery"| grep '^.*"MaxCapacity"\ =\ ' | sed -e 's/^.*"MaxCapacity"\ =\ //')
|
||||
typeset -F currentcapacity=$(ioreg -rc "AppleSmartBattery"| grep '^.*"CurrentCapacity"\ =\ ' | sed -e 's/^.*CurrentCapacity"\ =\ //')
|
||||
integer i=$(((currentcapacity/maxcapacity) * 100))
|
||||
echo $i
|
||||
}
|
||||
|
||||
function battery_pct_remaining() {
|
||||
if [[ $(ioreg -rc AppleSmartBattery | grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]] ; then
|
||||
typeset -F maxcapacity=$(ioreg -rc "AppleSmartBattery"| grep '^.*"MaxCapacity"\ =\ ' | sed -e 's/^.*"MaxCapacity"\ =\ //')
|
||||
typeset -F currentcapacity=$(ioreg -rc "AppleSmartBattery"| grep '^.*"CurrentCapacity"\ =\ ' | sed -e 's/^.*CurrentCapacity"\ =\ //')
|
||||
integer i=$(((currentcapacity/maxcapacity) * 100))
|
||||
echo $i
|
||||
battery_pct
|
||||
else
|
||||
echo "External Power"
|
||||
fi
|
||||
|
|
@ -42,17 +46,27 @@ if [[ $(uname) == "Darwin" ]] ; then
|
|||
fi
|
||||
echo "%{$fg[$color]%}[$(battery_pct_remaining)%%]%{$reset_color%}"
|
||||
else
|
||||
echo ""
|
||||
echo "∞"
|
||||
fi
|
||||
}
|
||||
|
||||
elif [[ $(uname) == "Linux" ]] ; then
|
||||
|
||||
if [[ $(acpi 2&>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] ; then
|
||||
function battery_pct_remaining() { echo "$(acpi | cut -f2 -d ',' | tr -cd '[:digit:]')" }
|
||||
function battery_time_remaining() { echo $(acpi | cut -f3 -d ',') }
|
||||
function battery_pct_prompt() {
|
||||
b=$(battery_pct_remaining)
|
||||
function battery_pct_remaining() {
|
||||
if [[ $(acpi 2&>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] ; then
|
||||
echo "$(acpi | cut -f2 -d ',' | tr -cd '[:digit:]')"
|
||||
fi
|
||||
}
|
||||
|
||||
function battery_time_remaining() {
|
||||
if [[ $(acpi 2&>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] ; then
|
||||
echo $(acpi | cut -f3 -d ',')
|
||||
fi
|
||||
}
|
||||
|
||||
function battery_pct_prompt() {
|
||||
b=$(battery_pct_remaining)
|
||||
if [[ $(acpi 2&>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] ; then
|
||||
if [ $b -gt 50 ] ; then
|
||||
color='green'
|
||||
elif [ $b -gt 20 ] ; then
|
||||
|
|
@ -61,11 +75,8 @@ elif [[ $(uname) == "Linux" ]] ; then
|
|||
color='red'
|
||||
fi
|
||||
echo "%{$fg[$color]%}[$(battery_pct_remaining)%%]%{$reset_color%}"
|
||||
}
|
||||
else
|
||||
error_msg='no battery'
|
||||
function battery_pct_remaining() { echo $error_msg }
|
||||
function battery_time_remaining() { echo $error_msg }
|
||||
function battery_pct_prompt() { echo '' }
|
||||
fi
|
||||
else
|
||||
echo "∞"
|
||||
fi
|
||||
}
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ _1st_arguments=(
|
|||
'update:freshen up links'
|
||||
'upgrade:upgrade outdated formulae'
|
||||
'uses:show formulas which depend on a formula'
|
||||
'versions:show all available formula versions'
|
||||
)
|
||||
|
||||
local expl
|
||||
|
|
@ -71,7 +72,7 @@ case "$words[1]" in
|
|||
_brew_installed_formulae
|
||||
_wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae
|
||||
fi ;;
|
||||
install|home|homepage|log|info|abv|uses|cat|deps|edit|options)
|
||||
install|home|homepage|log|info|abv|uses|cat|deps|edit|options|versions)
|
||||
_brew_all_formulae
|
||||
_wanted formulae expl 'all formulae' compadd -a formulae ;;
|
||||
remove|rm|uninstall|unlink|cleanup|link|ln)
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ case $state in
|
|||
"viz[Generate a visual representation of your dependencies]" \
|
||||
"init[Generate a simple Gemfile, placed in the current directory]" \
|
||||
"gem[Create a simple gem, suitable for development with bundler]" \
|
||||
"clean[Cleans up unused gems in your bundler directory]" \
|
||||
"help[Describe available tasks or one specific task]"
|
||||
ret=0
|
||||
;;
|
||||
|
|
@ -62,6 +63,14 @@ case $state in
|
|||
exec)
|
||||
_normal && ret=0
|
||||
;;
|
||||
clean)
|
||||
_arguments \
|
||||
'(--force)--force[forces clean even if --path is not set]' \
|
||||
'(--dry-run)--dry-run[only print out changes, do not actually clean gems]' \
|
||||
'(--no-color)--no-color[Disable colorization in output]' \
|
||||
'(--verbose)--verbose[Enable verbose output mode]'
|
||||
ret=0
|
||||
;;
|
||||
(open|show)
|
||||
_gems=( $(bundle show 2> /dev/null | sed -e '/^ \*/!d; s/^ \* \([^ ]*\) .*/\1/') )
|
||||
if [[ $_gems != "" ]]; then
|
||||
|
|
|
|||
|
|
@ -2,11 +2,12 @@ alias be="bundle exec"
|
|||
alias bi="bundle install"
|
||||
alias bl="bundle list"
|
||||
alias bp="bundle package"
|
||||
alias bo="bundle open"
|
||||
alias bu="bundle update"
|
||||
|
||||
# The following is based on https://github.com/gma/bundler-exec
|
||||
|
||||
bundled_commands=(annotate cap capify cucumber foreman guard middleman nanoc rackup rainbows rake rspec ruby shotgun spec spork thin thor unicorn unicorn_rails puma)
|
||||
bundled_commands=(annotate cap capify cucumber foreman guard jekyll middleman nanoc rackup rainbows rake rspec ruby shotgun spec spin spork thin thor unicorn unicorn_rails puma)
|
||||
|
||||
## Functions
|
||||
|
||||
|
|
|
|||
28
plugins/colorize/colorize.plugin.zsh
Normal file
28
plugins/colorize/colorize.plugin.zsh
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
# Plugin for highligthing file content
|
||||
# Plugin highlights file content based on the filename extension.
|
||||
# If no highlighting method supported for given extension then it tries
|
||||
# guess it by looking for file content.
|
||||
|
||||
alias colorize='colorize_via_pygmentize'
|
||||
|
||||
colorize_via_pygmentize() {
|
||||
if [ ! -x $(which pygmentize) ]; then
|
||||
echo package \'pygmentize\' is not installed!
|
||||
exit -1
|
||||
fi
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
pygmentize -g $@
|
||||
fi
|
||||
|
||||
for FNAME in $@
|
||||
do
|
||||
filename=$(basename "$FNAME")
|
||||
lexer=`pygmentize -N \"$filename\"`
|
||||
if [ "Z$lexer" != "Ztext" ]; then
|
||||
pygmentize -l $lexer "$FNAME"
|
||||
else
|
||||
pygmentize -g "$FNAME"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
|
@ -3,3 +3,7 @@
|
|||
# this is installed in Ubuntu
|
||||
|
||||
[[ -e /etc/zsh_command_not_found ]] && source /etc/zsh_command_not_found
|
||||
|
||||
# Arch Linux command-not-found support, you must have package pkgfile installed
|
||||
# https://wiki.archlinux.org/index.php/Pkgfile#.22Command_not_found.22_hook
|
||||
[[ -e /usr/share/doc/pkgfile/command-not-found.zsh ]] && source /usr/share/doc/pkgfile/command-not-found.zsh
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ alias csu='composer self-update'
|
|||
alias cu='composer update'
|
||||
alias ci='composer install'
|
||||
alias ccp='composer create-project'
|
||||
alias cdu='composer dump-autoload'
|
||||
|
||||
# install composer in the current directory
|
||||
alias cget='curl -s https://getcomposer.org/installer | php'
|
||||
|
|
|
|||
5
plugins/copyfile/copyfile.plugin.zsh
Normal file
5
plugins/copyfile/copyfile.plugin.zsh
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
function copyfile {
|
||||
[[ "$#" != 1 ]] && return 1
|
||||
local file_to_copy=$1
|
||||
cat $file_to_copy | pbcopy
|
||||
}
|
||||
|
|
@ -20,6 +20,19 @@ _managepy-createcachetable(){
|
|||
$nul_args && ret=0
|
||||
}
|
||||
|
||||
_managepy-collectstatic(){
|
||||
_arguments -s : \
|
||||
'--link=-[Create a symbolic link to each file instead of copying.]:' \
|
||||
'--noinput=-[Do NOT prompt the user for input of any kind.]:' \
|
||||
'--no-post-process=-[Do NOT post process collected files.]:' \
|
||||
'--ignore=-[Ignore files or directories matching this glob-style pattern. Use multiple times to ignore more.]:' \
|
||||
'--dry-run=-[Do everything except modify the filesystem.]:' \
|
||||
'--clear=-[Clear the existing files using the storage before trying to copy or link the original file.]:' \
|
||||
'--link=-[Create a symbolic link to each file instead of copying.]:' \
|
||||
'--no-default-ignore=-[Do not ignore the common private glob-style patterns "CVS", ".*" and "*~".]:' \
|
||||
$nul_args && ret=0
|
||||
}
|
||||
|
||||
_managepy-dbshell(){
|
||||
_arguments -s : \
|
||||
$nul_args && ret=0
|
||||
|
|
@ -163,6 +176,7 @@ _managepy-commands() {
|
|||
commands=(
|
||||
'adminindex:prints the admin-index template snippet for the given app name(s).'
|
||||
'createcachetable:creates the table needed to use the SQL cache backend.'
|
||||
'collectstatic:Collect static files in a single location.'
|
||||
'dbshell:runs the command-line client for the current DATABASE_ENGINE.'
|
||||
"diffsettings:displays differences between the current settings.py and Django's default settings."
|
||||
'dumpdata:Output the contents of the database as a fixture of the given format.'
|
||||
|
|
@ -220,4 +234,5 @@ _managepy() {
|
|||
|
||||
compdef _managepy manage.py
|
||||
compdef _managepy django
|
||||
compdef _managepy django-admin.py
|
||||
compdef _managepy django-manage
|
||||
|
|
|
|||
416
plugins/git-flow-avh/git-flow-avh.plugin.zsh
Normal file
416
plugins/git-flow-avh/git-flow-avh.plugin.zsh
Normal file
|
|
@ -0,0 +1,416 @@
|
|||
#!zsh
|
||||
#
|
||||
# Installation
|
||||
# ------------
|
||||
#
|
||||
# To achieve git-flow completion nirvana:
|
||||
#
|
||||
# 0. Update your zsh's git-completion module to the newest verion.
|
||||
# From here. http://zsh.git.sourceforge.net/git/gitweb.cgi?p=zsh/zsh;a=blob_plain;f=Completion/Unix/Command/_git;hb=HEAD
|
||||
#
|
||||
# 1. Install this file. Either:
|
||||
#
|
||||
# a. Place it in your .zshrc:
|
||||
#
|
||||
# b. Or, copy it somewhere (e.g. ~/.git-flow-completion.zsh) and put the following line in
|
||||
# your .zshrc:
|
||||
#
|
||||
# source ~/.git-flow-completion.zsh
|
||||
#
|
||||
# c. Or, use this file as a oh-my-zsh plugin.
|
||||
#
|
||||
|
||||
_git-flow ()
|
||||
{
|
||||
local curcontext="$curcontext" state line
|
||||
typeset -A opt_args
|
||||
|
||||
_arguments -C \
|
||||
':command:->command' \
|
||||
'*::options:->options'
|
||||
|
||||
case $state in
|
||||
(command)
|
||||
|
||||
local -a subcommands
|
||||
subcommands=(
|
||||
'init:Initialize a new git repo with support for the branching model.'
|
||||
'feature:Manage your feature branches.'
|
||||
'config:Manage your configuration.'
|
||||
'release:Manage your release branches.'
|
||||
'hotfix:Manage your hotfix branches.'
|
||||
'support:Manage your support branches.'
|
||||
'version:Shows version information.'
|
||||
)
|
||||
_describe -t commands 'git flow' subcommands
|
||||
;;
|
||||
|
||||
(options)
|
||||
case $line[1] in
|
||||
|
||||
(init)
|
||||
_arguments \
|
||||
-f'[Force setting of gitflow branches, even if already configured]'
|
||||
;;
|
||||
|
||||
(version)
|
||||
;;
|
||||
|
||||
(hotfix)
|
||||
__git-flow-hotfix
|
||||
;;
|
||||
|
||||
(release)
|
||||
__git-flow-release
|
||||
;;
|
||||
|
||||
(feature)
|
||||
__git-flow-feature
|
||||
;;
|
||||
(config)
|
||||
__git-flow-config
|
||||
;;
|
||||
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
__git-flow-release ()
|
||||
{
|
||||
local curcontext="$curcontext" state line
|
||||
typeset -A opt_args
|
||||
|
||||
_arguments -C \
|
||||
':command:->command' \
|
||||
'*::options:->options'
|
||||
|
||||
case $state in
|
||||
(command)
|
||||
|
||||
local -a subcommands
|
||||
subcommands=(
|
||||
'start:Start a new release branch.'
|
||||
'finish:Finish a release branch.'
|
||||
'list:List all your release branches. (Alias to `git flow release`)'
|
||||
'publish:Publish release branch to remote.'
|
||||
'track:Checkout remote release branch.'
|
||||
'delet:Delete a release branch.'
|
||||
)
|
||||
_describe -t commands 'git flow release' subcommands
|
||||
_arguments \
|
||||
-v'[Verbose (more) output]'
|
||||
;;
|
||||
|
||||
(options)
|
||||
case $line[1] in
|
||||
|
||||
(start)
|
||||
_arguments \
|
||||
-F'[Fetch from origin before performing finish]'\
|
||||
':version:__git_flow_version_list'
|
||||
;;
|
||||
|
||||
(finish)
|
||||
_arguments \
|
||||
-F'[Fetch from origin before performing finish]' \
|
||||
-s'[Sign the release tag cryptographically]'\
|
||||
-u'[Use the given GPG-key for the digital signature (implies -s)]'\
|
||||
-m'[Use the given tag message]'\
|
||||
-p'[Push to $ORIGIN after performing finish]'\
|
||||
':version:__git_flow_version_list'
|
||||
;;
|
||||
|
||||
(delete)
|
||||
_arguments \
|
||||
-f'[Force deletion]' \
|
||||
-r'[Delete remote branch]' \
|
||||
':version:__git_flow_version_list'
|
||||
;;
|
||||
|
||||
(publish)
|
||||
_arguments \
|
||||
':version:__git_flow_version_list'
|
||||
;;
|
||||
|
||||
(track)
|
||||
_arguments \
|
||||
':version:__git_flow_version_list'
|
||||
;;
|
||||
|
||||
*)
|
||||
_arguments \
|
||||
-v'[Verbose (more) output]'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
__git-flow-hotfix ()
|
||||
{
|
||||
local curcontext="$curcontext" state line
|
||||
typeset -A opt_args
|
||||
|
||||
_arguments -C \
|
||||
':command:->command' \
|
||||
'*::options:->options'
|
||||
|
||||
case $state in
|
||||
(command)
|
||||
|
||||
local -a subcommands
|
||||
subcommands=(
|
||||
'start:Start a new hotfix branch.'
|
||||
'finish:Finish a hotfix branch.'
|
||||
'delete:Delete a hotfix branch.'
|
||||
'list:List all your hotfix branches. (Alias to `git flow hotfix`)'
|
||||
)
|
||||
_describe -t commands 'git flow hotfix' subcommands
|
||||
_arguments \
|
||||
-v'[Verbose (more) output]'
|
||||
;;
|
||||
|
||||
(options)
|
||||
case $line[1] in
|
||||
|
||||
(start)
|
||||
_arguments \
|
||||
-F'[Fetch from origin before performing finish]'\
|
||||
':hotfix:__git_flow_version_list'\
|
||||
':branch-name:__git_branch_names'
|
||||
;;
|
||||
|
||||
(finish)
|
||||
_arguments \
|
||||
-F'[Fetch from origin before performing finish]' \
|
||||
-s'[Sign the release tag cryptographically]'\
|
||||
-u'[Use the given GPG-key for the digital signature (implies -s)]'\
|
||||
-m'[Use the given tag message]'\
|
||||
-p'[Push to $ORIGIN after performing finish]'\
|
||||
':hotfix:__git_flow_hotfix_list'
|
||||
;;
|
||||
|
||||
(delete)
|
||||
_arguments \
|
||||
-f'[Force deletion]' \
|
||||
-r'[Delete remote branch]' \
|
||||
':hotfix:__git_flow_hotfix_list'
|
||||
;;
|
||||
|
||||
*)
|
||||
_arguments \
|
||||
-v'[Verbose (more) output]'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
__git-flow-feature ()
|
||||
{
|
||||
local curcontext="$curcontext" state line
|
||||
typeset -A opt_args
|
||||
|
||||
_arguments -C \
|
||||
':command:->command' \
|
||||
'*::options:->options'
|
||||
|
||||
case $state in
|
||||
(command)
|
||||
|
||||
local -a subcommands
|
||||
subcommands=(
|
||||
'start:Start a new feature branch.'
|
||||
'finish:Finish a feature branch.'
|
||||
'delete:Delete a feature branch.'
|
||||
'list:List all your feature branches. (Alias to `git flow feature`)'
|
||||
'publish:Publish feature branch to remote.'
|
||||
'track:Checkout remote feature branch.'
|
||||
'diff:Show all changes.'
|
||||
'rebase:Rebase from integration branch.'
|
||||
'checkout:Checkout local feature branch.'
|
||||
'pull:Pull changes from remote.'
|
||||
)
|
||||
_describe -t commands 'git flow feature' subcommands
|
||||
_arguments \
|
||||
-v'[Verbose (more) output]'
|
||||
;;
|
||||
|
||||
(options)
|
||||
case $line[1] in
|
||||
|
||||
(start)
|
||||
_arguments \
|
||||
-F'[Fetch from origin before performing finish]'\
|
||||
':feature:__git_flow_feature_list'\
|
||||
':branch-name:__git_branch_names'
|
||||
;;
|
||||
|
||||
(finish)
|
||||
_arguments \
|
||||
-F'[Fetch from origin before performing finish]' \
|
||||
-r'[Rebase instead of merge]'\
|
||||
':feature:__git_flow_feature_list'
|
||||
;;
|
||||
|
||||
(delete)
|
||||
_arguments \
|
||||
-f'[Force deletion]' \
|
||||
-r'[Delete remote branch]' \
|
||||
':feature:__git_flow_feature_list'
|
||||
;;
|
||||
|
||||
(publish)
|
||||
_arguments \
|
||||
':feature:__git_flow_feature_list'\
|
||||
;;
|
||||
|
||||
(track)
|
||||
_arguments \
|
||||
':feature:__git_flow_feature_list'\
|
||||
;;
|
||||
|
||||
(diff)
|
||||
_arguments \
|
||||
':branch:__git_branch_names'\
|
||||
;;
|
||||
|
||||
(rebase)
|
||||
_arguments \
|
||||
-i'[Do an interactive rebase]' \
|
||||
':branch:__git_branch_names'
|
||||
;;
|
||||
|
||||
(checkout)
|
||||
_arguments \
|
||||
':branch:__git_flow_feature_list'\
|
||||
;;
|
||||
|
||||
(pull)
|
||||
_arguments \
|
||||
':remote:__git_remotes'\
|
||||
':branch:__git_branch_names'
|
||||
;;
|
||||
|
||||
*)
|
||||
_arguments \
|
||||
-v'[Verbose (more) output]'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
__git-flow-config ()
|
||||
{
|
||||
local curcontext="$curcontext" state line
|
||||
typeset -A opt_args
|
||||
|
||||
_arguments -C \
|
||||
':command:->command' \
|
||||
'*::options:->options'
|
||||
|
||||
case $state in
|
||||
(command)
|
||||
|
||||
local -a subcommands
|
||||
subcommands=(
|
||||
'list:List the configuration. (Alias to `git flow config`)'
|
||||
'set:Set the configuration option'
|
||||
)
|
||||
_describe -t commands 'git flow config' subcommands
|
||||
;;
|
||||
|
||||
(options)
|
||||
case $line[1] in
|
||||
|
||||
(set)
|
||||
_arguments \
|
||||
--local'[Use repository config file]' \
|
||||
--global'[Use global config file]'\
|
||||
--system'[Use system config file]'\
|
||||
--file'[Use given config file]'\
|
||||
':option:(master develop feature hotfix release support versiontagprefix)'
|
||||
;;
|
||||
|
||||
*)
|
||||
_arguments \
|
||||
--local'[Use repository config file]' \
|
||||
--global'[Use global config file]'\
|
||||
--system'[Use system config file]'\
|
||||
--file'[Use given config file]'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
__git_flow_version_list ()
|
||||
{
|
||||
local expl
|
||||
declare -a versions
|
||||
|
||||
versions=(${${(f)"$(_call_program versions git flow release list 2> /dev/null | tr -d ' |*')"}})
|
||||
__git_command_successful || return
|
||||
|
||||
_wanted versions expl 'version' compadd $versions
|
||||
}
|
||||
|
||||
__git_flow_feature_list ()
|
||||
{
|
||||
local expl
|
||||
declare -a features
|
||||
|
||||
features=(${${(f)"$(_call_program features git flow feature list 2> /dev/null | tr -d ' |*')"}})
|
||||
__git_command_successful || return
|
||||
|
||||
_wanted features expl 'feature' compadd $features
|
||||
}
|
||||
|
||||
__git_remotes () {
|
||||
local expl gitdir remotes
|
||||
|
||||
gitdir=$(_call_program gitdir git rev-parse --git-dir 2>/dev/null)
|
||||
__git_command_successful || return
|
||||
|
||||
remotes=(${${(f)"$(_call_program remotes git config --get-regexp '"^remote\..*\.url$"')"}//#(#b)remote.(*).url */$match[1]})
|
||||
__git_command_successful || return
|
||||
|
||||
# TODO: Should combine the two instead of either or.
|
||||
if (( $#remotes > 0 )); then
|
||||
_wanted remotes expl remote compadd $* - $remotes
|
||||
else
|
||||
_wanted remotes expl remote _files $* - -W "($gitdir/remotes)" -g "$gitdir/remotes/*"
|
||||
fi
|
||||
}
|
||||
|
||||
__git_flow_hotfix_list ()
|
||||
{
|
||||
local expl
|
||||
declare -a hotfixes
|
||||
|
||||
hotfixes=(${${(f)"$(_call_program hotfixes git flow hotfix list 2> /dev/null | tr -d ' |*')"}})
|
||||
__git_command_successful || return
|
||||
|
||||
_wanted hotfixes expl 'hotfix' compadd $hotfixes
|
||||
}
|
||||
|
||||
__git_branch_names () {
|
||||
local expl
|
||||
declare -a branch_names
|
||||
|
||||
branch_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads 2>/dev/null)"}#refs/heads/})
|
||||
__git_command_successful || return
|
||||
|
||||
_wanted branch-names expl branch-name compadd $* - $branch_names
|
||||
}
|
||||
|
||||
__git_command_successful () {
|
||||
if (( ${#pipestatus:#0} > 0 )); then
|
||||
_message 'not a git repository'
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
zstyle ':completion:*:*:git:*' user-commands flow:'provide high-level repository operations'
|
||||
|
|
@ -88,6 +88,8 @@ __git-flow-release ()
|
|||
'start:Start a new release branch.'
|
||||
'finish:Finish a release branch.'
|
||||
'list:List all your release branches. (Alias to `git flow release`)'
|
||||
'publish: public'
|
||||
'track: track'
|
||||
)
|
||||
_describe -t commands 'git flow release' subcommands
|
||||
_arguments \
|
||||
|
|
@ -115,6 +117,16 @@ __git-flow-release ()
|
|||
':version:__git_flow_version_list'
|
||||
;;
|
||||
|
||||
(publish)
|
||||
_arguments \
|
||||
':version:__git_flow_version_list'\
|
||||
;;
|
||||
|
||||
(track)
|
||||
_arguments \
|
||||
':version:__git_flow_version_list'\
|
||||
;;
|
||||
|
||||
*)
|
||||
_arguments \
|
||||
-v'[Verbose (more) output]'
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@ _git_remote_branch() {
|
|||
compadd create publish rename delete track
|
||||
elif (( CURRENT == 3 )); then
|
||||
# second arg: remote branch name
|
||||
compadd `git branch -r | grep -v HEAD | sed "s/.*\///" | sed "s/ //g"`
|
||||
remotes=`git remote | tr '\n' '|' | sed "s/\|$//g"`
|
||||
compadd `git branch -r | grep -v HEAD | sed "s/$remotes\///" | sed "s/ //g"`
|
||||
elif (( CURRENT == 4 )); then
|
||||
# third arg: remote name
|
||||
compadd `git remote`
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ alias g='git'
|
|||
compdef g=git
|
||||
alias gst='git status'
|
||||
compdef _git gst=git-status
|
||||
alias gd='git diff'
|
||||
compdef _git gd=git-diff
|
||||
alias gl='git pull'
|
||||
compdef _git gl=git-pull
|
||||
alias gup='git pull --rebase'
|
||||
|
|
@ -50,6 +52,8 @@ alias glgg='git log --graph --max-count=5'
|
|||
compdef _git glgg=git-log
|
||||
alias glgga='git log --graph --decorate --all'
|
||||
compdef _git glgga=git-log
|
||||
alias glo='git log --oneline'
|
||||
compdef _git glo=git-log
|
||||
alias gss='git status -s'
|
||||
compdef _git gss=git-status
|
||||
alias ga='git add'
|
||||
|
|
@ -95,3 +99,12 @@ alias ggpush='git push origin $(current_branch)'
|
|||
compdef ggpush=git
|
||||
alias ggpnp='git pull origin $(current_branch) && git push origin $(current_branch)'
|
||||
compdef ggpnp=git
|
||||
|
||||
# Pretty log messages
|
||||
function _git_log_prettily(){
|
||||
if ! [ -z $1 ]; then
|
||||
git log --pretty=$1
|
||||
fi
|
||||
}
|
||||
alias glp="_git_log_prettily"
|
||||
compdef _git glp=git-log
|
||||
|
|
|
|||
|
|
@ -60,6 +60,15 @@ __gitcomp_nl ()
|
|||
compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
|
||||
}
|
||||
|
||||
__gitcomp_file ()
|
||||
{
|
||||
emulate -L zsh
|
||||
|
||||
local IFS=$'\n'
|
||||
compset -P '*[=:]'
|
||||
compadd -Q -p "${2-}" -f -- ${=1} && _ret=0
|
||||
}
|
||||
|
||||
_git ()
|
||||
{
|
||||
local _ret=1
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
# *) .git/remotes file names
|
||||
# *) git 'subcommands'
|
||||
# *) tree paths within 'ref:path/to/file' expressions
|
||||
# *) file paths within current working directory and index
|
||||
# *) common --long-options
|
||||
#
|
||||
# To use these routines:
|
||||
|
|
@ -23,10 +24,6 @@
|
|||
# 3) Consider changing your PS1 to also show the current branch,
|
||||
# see git-prompt.sh for details.
|
||||
|
||||
if [[ -n ${ZSH_VERSION-} ]]; then
|
||||
autoload -U +X bashcompinit && bashcompinit
|
||||
fi
|
||||
|
||||
case "$COMP_WORDBREAKS" in
|
||||
*:*) : great ;;
|
||||
*) COMP_WORDBREAKS="$COMP_WORDBREAKS:"
|
||||
|
|
@ -169,7 +166,6 @@ __git_reassemble_comp_words_by_ref()
|
|||
}
|
||||
|
||||
if ! type _get_comp_words_by_ref >/dev/null 2>&1; then
|
||||
if [[ -z ${ZSH_VERSION:+set} ]]; then
|
||||
_get_comp_words_by_ref ()
|
||||
{
|
||||
local exclude cur_ words_ cword_
|
||||
|
|
@ -197,32 +193,6 @@ _get_comp_words_by_ref ()
|
|||
shift
|
||||
done
|
||||
}
|
||||
else
|
||||
_get_comp_words_by_ref ()
|
||||
{
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
cur)
|
||||
cur=${COMP_WORDS[COMP_CWORD]}
|
||||
;;
|
||||
prev)
|
||||
prev=${COMP_WORDS[COMP_CWORD-1]}
|
||||
;;
|
||||
words)
|
||||
words=("${COMP_WORDS[@]}")
|
||||
;;
|
||||
cword)
|
||||
cword=$COMP_CWORD
|
||||
;;
|
||||
-n)
|
||||
# assume COMP_WORDBREAKS is already set sanely
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
}
|
||||
fi
|
||||
fi
|
||||
|
||||
# Generates completion reply with compgen, appending a space to possible
|
||||
|
|
@ -264,6 +234,124 @@ __gitcomp_nl ()
|
|||
COMPREPLY=($(compgen -P "${2-}" -S "${4- }" -W "$1" -- "${3-$cur}"))
|
||||
}
|
||||
|
||||
# Generates completion reply with compgen from newline-separated possible
|
||||
# completion filenames.
|
||||
# It accepts 1 to 3 arguments:
|
||||
# 1: List of possible completion filenames, separated by a single newline.
|
||||
# 2: A directory prefix to be added to each possible completion filename
|
||||
# (optional).
|
||||
# 3: Generate possible completion matches for this word (optional).
|
||||
__gitcomp_file ()
|
||||
{
|
||||
local IFS=$'\n'
|
||||
|
||||
# XXX does not work when the directory prefix contains a tilde,
|
||||
# since tilde expansion is not applied.
|
||||
# This means that COMPREPLY will be empty and Bash default
|
||||
# completion will be used.
|
||||
COMPREPLY=($(compgen -P "${2-}" -W "$1" -- "${3-$cur}"))
|
||||
|
||||
# Tell Bash that compspec generates filenames.
|
||||
compopt -o filenames 2>/dev/null
|
||||
}
|
||||
|
||||
__git_index_file_list_filter_compat ()
|
||||
{
|
||||
local path
|
||||
|
||||
while read -r path; do
|
||||
case "$path" in
|
||||
?*/*) echo "${path%%/*}/" ;;
|
||||
*) echo "$path" ;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
__git_index_file_list_filter_bash ()
|
||||
{
|
||||
local path
|
||||
|
||||
while read -r path; do
|
||||
case "$path" in
|
||||
?*/*)
|
||||
# XXX if we append a slash to directory names when using
|
||||
# `compopt -o filenames`, Bash will append another slash.
|
||||
# This is pretty stupid, and this the reason why we have to
|
||||
# define a compatible version for this function.
|
||||
echo "${path%%/*}" ;;
|
||||
*)
|
||||
echo "$path" ;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
# Process path list returned by "ls-files" and "diff-index --name-only"
|
||||
# commands, in order to list only file names relative to a specified
|
||||
# directory, and append a slash to directory names.
|
||||
__git_index_file_list_filter ()
|
||||
{
|
||||
# Default to Bash >= 4.x
|
||||
__git_index_file_list_filter_bash
|
||||
}
|
||||
|
||||
# Execute git ls-files, returning paths relative to the directory
|
||||
# specified in the first argument, and using the options specified in
|
||||
# the second argument.
|
||||
__git_ls_files_helper ()
|
||||
{
|
||||
(
|
||||
test -n "${CDPATH+set}" && unset CDPATH
|
||||
# NOTE: $2 is not quoted in order to support multiple options
|
||||
cd "$1" && git ls-files --exclude-standard $2
|
||||
) 2>/dev/null
|
||||
}
|
||||
|
||||
|
||||
# Execute git diff-index, returning paths relative to the directory
|
||||
# specified in the first argument, and using the tree object id
|
||||
# specified in the second argument.
|
||||
__git_diff_index_helper ()
|
||||
{
|
||||
(
|
||||
test -n "${CDPATH+set}" && unset CDPATH
|
||||
cd "$1" && git diff-index --name-only --relative "$2"
|
||||
) 2>/dev/null
|
||||
}
|
||||
|
||||
# __git_index_files accepts 1 or 2 arguments:
|
||||
# 1: Options to pass to ls-files (required).
|
||||
# Supported options are --cached, --modified, --deleted, --others,
|
||||
# and --directory.
|
||||
# 2: A directory path (optional).
|
||||
# If provided, only files within the specified directory are listed.
|
||||
# Sub directories are never recursed. Path must have a trailing
|
||||
# slash.
|
||||
__git_index_files ()
|
||||
{
|
||||
local dir="$(__gitdir)" root="${2-.}"
|
||||
|
||||
if [ -d "$dir" ]; then
|
||||
__git_ls_files_helper "$root" "$1" | __git_index_file_list_filter |
|
||||
sort | uniq
|
||||
fi
|
||||
}
|
||||
|
||||
# __git_diff_index_files accepts 1 or 2 arguments:
|
||||
# 1) The id of a tree object.
|
||||
# 2) A directory path (optional).
|
||||
# If provided, only files within the specified directory are listed.
|
||||
# Sub directories are never recursed. Path must have a trailing
|
||||
# slash.
|
||||
__git_diff_index_files ()
|
||||
{
|
||||
local dir="$(__gitdir)" root="${2-.}"
|
||||
|
||||
if [ -d "$dir" ]; then
|
||||
__git_diff_index_helper "$root" "$1" | __git_index_file_list_filter |
|
||||
sort | uniq
|
||||
fi
|
||||
}
|
||||
|
||||
__git_heads ()
|
||||
{
|
||||
local dir="$(__gitdir)"
|
||||
|
|
@ -321,7 +409,7 @@ __git_refs ()
|
|||
if [[ "$ref" == "$cur"* ]]; then
|
||||
echo "$ref"
|
||||
fi
|
||||
done | uniq -u
|
||||
done | sort | uniq -u
|
||||
fi
|
||||
return
|
||||
fi
|
||||
|
|
@ -428,7 +516,7 @@ __git_complete_revlist_file ()
|
|||
*) pfx="$ref:$pfx" ;;
|
||||
esac
|
||||
|
||||
__gitcomp_nl "$(git --git-dir="$(__gitdir)" ls-tree "$ls" \
|
||||
__gitcomp_nl "$(git --git-dir="$(__gitdir)" ls-tree "$ls" 2>/dev/null \
|
||||
| sed '/^100... blob /{
|
||||
s,^.* ,,
|
||||
s,$, ,
|
||||
|
|
@ -461,6 +549,46 @@ __git_complete_revlist_file ()
|
|||
}
|
||||
|
||||
|
||||
# __git_complete_index_file requires 1 argument: the options to pass to
|
||||
# ls-file
|
||||
__git_complete_index_file ()
|
||||
{
|
||||
local pfx cur_="$cur"
|
||||
|
||||
case "$cur_" in
|
||||
?*/*)
|
||||
pfx="${cur_%/*}"
|
||||
cur_="${cur_##*/}"
|
||||
pfx="${pfx}/"
|
||||
|
||||
__gitcomp_file "$(__git_index_files "$1" "$pfx")" "$pfx" "$cur_"
|
||||
;;
|
||||
*)
|
||||
__gitcomp_file "$(__git_index_files "$1")" "" "$cur_"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# __git_complete_diff_index_file requires 1 argument: the id of a tree
|
||||
# object
|
||||
__git_complete_diff_index_file ()
|
||||
{
|
||||
local pfx cur_="$cur"
|
||||
|
||||
case "$cur_" in
|
||||
?*/*)
|
||||
pfx="${cur_%/*}"
|
||||
cur_="${cur_##*/}"
|
||||
pfx="${pfx}/"
|
||||
|
||||
__gitcomp_file "$(__git_diff_index_files "$1" "$pfx")" "$pfx" "$cur_"
|
||||
;;
|
||||
*)
|
||||
__gitcomp_file "$(__git_diff_index_files "$1")" "" "$cur_"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
__git_complete_file ()
|
||||
{
|
||||
__git_complete_revlist_file
|
||||
|
|
@ -562,10 +690,19 @@ __git_complete_strategy ()
|
|||
return 1
|
||||
}
|
||||
|
||||
__git_commands () {
|
||||
if test -n "${GIT_TESTING_COMMAND_COMPLETION:-}"
|
||||
then
|
||||
printf "%s" "${GIT_TESTING_COMMAND_COMPLETION}"
|
||||
else
|
||||
git help -a|egrep '^ [a-zA-Z0-9]'
|
||||
fi
|
||||
}
|
||||
|
||||
__git_list_all_commands ()
|
||||
{
|
||||
local i IFS=" "$'\n'
|
||||
for i in $(git help -a|egrep '^ [a-zA-Z0-9]')
|
||||
for i in $(__git_commands)
|
||||
do
|
||||
case $i in
|
||||
*--*) : helper pattern;;
|
||||
|
|
@ -585,7 +722,7 @@ __git_list_porcelain_commands ()
|
|||
{
|
||||
local i IFS=" "$'\n'
|
||||
__git_compute_all_commands
|
||||
for i in "help" $__git_all_commands
|
||||
for i in $__git_all_commands
|
||||
do
|
||||
case $i in
|
||||
*--*) : helper pattern;;
|
||||
|
|
@ -594,6 +731,7 @@ __git_list_porcelain_commands ()
|
|||
archimport) : import;;
|
||||
cat-file) : plumbing;;
|
||||
check-attr) : plumbing;;
|
||||
check-ignore) : plumbing;;
|
||||
check-ref-format) : plumbing;;
|
||||
checkout-index) : plumbing;;
|
||||
commit-tree) : plumbing;;
|
||||
|
|
@ -753,6 +891,43 @@ __git_has_doubledash ()
|
|||
return 1
|
||||
}
|
||||
|
||||
# Try to count non option arguments passed on the command line for the
|
||||
# specified git command.
|
||||
# When options are used, it is necessary to use the special -- option to
|
||||
# tell the implementation were non option arguments begin.
|
||||
# XXX this can not be improved, since options can appear everywhere, as
|
||||
# an example:
|
||||
# git mv x -n y
|
||||
#
|
||||
# __git_count_arguments requires 1 argument: the git command executed.
|
||||
__git_count_arguments ()
|
||||
{
|
||||
local word i c=0
|
||||
|
||||
# Skip "git" (first argument)
|
||||
for ((i=1; i < ${#words[@]}; i++)); do
|
||||
word="${words[i]}"
|
||||
|
||||
case "$word" in
|
||||
--)
|
||||
# Good; we can assume that the following are only non
|
||||
# option arguments.
|
||||
((c = 0))
|
||||
;;
|
||||
"$1")
|
||||
# Skip the specified git command and discard git
|
||||
# main options
|
||||
((c = 0))
|
||||
;;
|
||||
?*)
|
||||
((c++))
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
printf "%d" $c
|
||||
}
|
||||
|
||||
__git_whitespacelist="nowarn warn error error-all fix"
|
||||
|
||||
_git_am ()
|
||||
|
|
@ -801,8 +976,6 @@ _git_apply ()
|
|||
|
||||
_git_add ()
|
||||
{
|
||||
__git_has_doubledash && return
|
||||
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
|
|
@ -811,7 +984,9 @@ _git_add ()
|
|||
"
|
||||
return
|
||||
esac
|
||||
COMPREPLY=()
|
||||
|
||||
# XXX should we check for --update and --all options ?
|
||||
__git_complete_index_file "--others --modified"
|
||||
}
|
||||
|
||||
_git_archive ()
|
||||
|
|
@ -961,15 +1136,15 @@ _git_cherry_pick ()
|
|||
|
||||
_git_clean ()
|
||||
{
|
||||
__git_has_doubledash && return
|
||||
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "--dry-run --quiet"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
COMPREPLY=()
|
||||
|
||||
# XXX should we check for -x option ?
|
||||
__git_complete_index_file "--others"
|
||||
}
|
||||
|
||||
_git_clone ()
|
||||
|
|
@ -989,6 +1164,8 @@ _git_clone ()
|
|||
--upload-pack
|
||||
--template=
|
||||
--depth
|
||||
--single-branch
|
||||
--branch
|
||||
"
|
||||
return
|
||||
;;
|
||||
|
|
@ -998,7 +1175,19 @@ _git_clone ()
|
|||
|
||||
_git_commit ()
|
||||
{
|
||||
__git_has_doubledash && return
|
||||
case "$prev" in
|
||||
-c|-C)
|
||||
__gitcomp_nl "$(__git_refs)" "" "${cur}"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$prev" in
|
||||
-c|-C)
|
||||
__gitcomp_nl "$(__git_refs)" "" "${cur}"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$cur" in
|
||||
--cleanup=*)
|
||||
|
|
@ -1027,7 +1216,13 @@ _git_commit ()
|
|||
"
|
||||
return
|
||||
esac
|
||||
COMPREPLY=()
|
||||
|
||||
if git rev-parse --verify --quiet HEAD >/dev/null; then
|
||||
__git_complete_diff_index_file "HEAD"
|
||||
else
|
||||
# This is the first commit
|
||||
__git_complete_index_file "--cached"
|
||||
fi
|
||||
}
|
||||
|
||||
_git_describe ()
|
||||
|
|
@ -1043,6 +1238,8 @@ _git_describe ()
|
|||
__gitcomp_nl "$(__git_refs)"
|
||||
}
|
||||
|
||||
__git_diff_algorithms="myers minimal patience histogram"
|
||||
|
||||
__git_diff_common_options="--stat --numstat --shortstat --summary
|
||||
--patch-with-stat --name-only --name-status --color
|
||||
--no-color --color-words --no-renames --check
|
||||
|
|
@ -1053,10 +1250,11 @@ __git_diff_common_options="--stat --numstat --shortstat --summary
|
|||
--no-ext-diff
|
||||
--no-prefix --src-prefix= --dst-prefix=
|
||||
--inter-hunk-context=
|
||||
--patience
|
||||
--patience --histogram --minimal
|
||||
--raw
|
||||
--dirstat --dirstat= --dirstat-by-file
|
||||
--dirstat-by-file= --cumulative
|
||||
--diff-algorithm=
|
||||
"
|
||||
|
||||
_git_diff ()
|
||||
|
|
@ -1064,6 +1262,10 @@ _git_diff ()
|
|||
__git_has_doubledash && return
|
||||
|
||||
case "$cur" in
|
||||
--diff-algorithm=*)
|
||||
__gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"
|
||||
return
|
||||
;;
|
||||
--*)
|
||||
__gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
|
||||
--base --ours --theirs --no-index
|
||||
|
|
@ -1116,6 +1318,14 @@ _git_fetch ()
|
|||
__git_complete_remote_or_refspec
|
||||
}
|
||||
|
||||
__git_format_patch_options="
|
||||
--stdout --attach --no-attach --thread --thread= --output-directory
|
||||
--numbered --start-number --numbered-files --keep-subject --signoff
|
||||
--signature --no-signature --in-reply-to= --cc= --full-index --binary
|
||||
--not --all --cover-letter --no-prefix --src-prefix= --dst-prefix=
|
||||
--inline --suffix= --ignore-if-in-upstream --subject-prefix=
|
||||
"
|
||||
|
||||
_git_format_patch ()
|
||||
{
|
||||
case "$cur" in
|
||||
|
|
@ -1126,21 +1336,7 @@ _git_format_patch ()
|
|||
return
|
||||
;;
|
||||
--*)
|
||||
__gitcomp "
|
||||
--stdout --attach --no-attach --thread --thread=
|
||||
--output-directory
|
||||
--numbered --start-number
|
||||
--numbered-files
|
||||
--keep-subject
|
||||
--signoff --signature --no-signature
|
||||
--in-reply-to= --cc=
|
||||
--full-index --binary
|
||||
--not --all
|
||||
--cover-letter
|
||||
--no-prefix --src-prefix= --dst-prefix=
|
||||
--inline --suffix= --ignore-if-in-upstream
|
||||
--subject-prefix=
|
||||
"
|
||||
__gitcomp "$__git_format_patch_options"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
|
@ -1251,8 +1447,6 @@ _git_init ()
|
|||
|
||||
_git_ls_files ()
|
||||
{
|
||||
__git_has_doubledash && return
|
||||
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "--cached --deleted --modified --others --ignored
|
||||
|
|
@ -1265,7 +1459,10 @@ _git_ls_files ()
|
|||
return
|
||||
;;
|
||||
esac
|
||||
COMPREPLY=()
|
||||
|
||||
# XXX ignore options like --modified and always suggest all cached
|
||||
# files.
|
||||
__git_complete_index_file "--cached"
|
||||
}
|
||||
|
||||
_git_ls_remote ()
|
||||
|
|
@ -1397,7 +1594,14 @@ _git_mv ()
|
|||
return
|
||||
;;
|
||||
esac
|
||||
COMPREPLY=()
|
||||
|
||||
if [ $(__git_count_arguments "mv") -gt 0 ]; then
|
||||
# We need to show both cached and untracked files (including
|
||||
# empty directories) since this may not be the last argument.
|
||||
__git_complete_index_file "--cached --others --directory"
|
||||
else
|
||||
__git_complete_index_file "--cached"
|
||||
fi
|
||||
}
|
||||
|
||||
_git_name_rev ()
|
||||
|
|
@ -1554,6 +1758,12 @@ _git_send_email ()
|
|||
__gitcomp "ssl tls" "" "${cur##--smtp-encryption=}"
|
||||
return
|
||||
;;
|
||||
--thread=*)
|
||||
__gitcomp "
|
||||
deep shallow
|
||||
" "" "${cur##--thread=}"
|
||||
return
|
||||
;;
|
||||
--*)
|
||||
__gitcomp "--annotate --bcc --cc --cc-cmd --chain-reply-to
|
||||
--compose --confirm= --dry-run --envelope-sender
|
||||
|
|
@ -1563,11 +1773,12 @@ _git_send_email ()
|
|||
--signed-off-by-cc --smtp-pass --smtp-server
|
||||
--smtp-server-port --smtp-encryption= --smtp-user
|
||||
--subject --suppress-cc= --suppress-from --thread --to
|
||||
--validate --no-validate"
|
||||
--validate --no-validate
|
||||
$__git_format_patch_options"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
COMPREPLY=()
|
||||
__git_complete_revlist
|
||||
}
|
||||
|
||||
_git_stage ()
|
||||
|
|
@ -1581,7 +1792,7 @@ __git_config_get_set_variables ()
|
|||
while [ $c -gt 1 ]; do
|
||||
word="${words[c]}"
|
||||
case "$word" in
|
||||
--global|--system|--file=*)
|
||||
--system|--global|--local|--file=*)
|
||||
config_file="$word"
|
||||
break
|
||||
;;
|
||||
|
|
@ -1687,7 +1898,7 @@ _git_config ()
|
|||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
--global --system --file=
|
||||
--system --global --local --file=
|
||||
--list --replace-all
|
||||
--get --get-all --get-regexp
|
||||
--add --unset --unset-all
|
||||
|
|
@ -1860,6 +2071,7 @@ _git_config ()
|
|||
diff.suppressBlankEmpty
|
||||
diff.tool
|
||||
diff.wordRegex
|
||||
diff.algorithm
|
||||
difftool.
|
||||
difftool.prompt
|
||||
fetch.recurseSubmodules
|
||||
|
|
@ -2096,15 +2308,14 @@ _git_revert ()
|
|||
|
||||
_git_rm ()
|
||||
{
|
||||
__git_has_doubledash && return
|
||||
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "--cached --dry-run --ignore-unmatch --quiet"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
COMPREPLY=()
|
||||
|
||||
__git_complete_index_file "--cached"
|
||||
}
|
||||
|
||||
_git_shortlog ()
|
||||
|
|
@ -2134,6 +2345,10 @@ _git_show ()
|
|||
" "" "${cur#*=}"
|
||||
return
|
||||
;;
|
||||
--diff-algorithm=*)
|
||||
__gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"
|
||||
return
|
||||
;;
|
||||
--*)
|
||||
__gitcomp "--pretty= --format= --abbrev-commit --oneline
|
||||
$__git_diff_common_options
|
||||
|
|
@ -2429,20 +2644,88 @@ __gitk_main ()
|
|||
__git_complete_revlist
|
||||
}
|
||||
|
||||
if [[ -n ${ZSH_VERSION-} ]]; then
|
||||
echo "WARNING: this script is deprecated, please see git-completion.zsh" 1>&2
|
||||
|
||||
autoload -U +X compinit && compinit
|
||||
|
||||
__gitcomp ()
|
||||
{
|
||||
emulate -L zsh
|
||||
|
||||
local cur_="${3-$cur}"
|
||||
|
||||
case "$cur_" in
|
||||
--*=)
|
||||
;;
|
||||
*)
|
||||
local c IFS=$' \t\n'
|
||||
local -a array
|
||||
for c in ${=1}; do
|
||||
c="$c${4-}"
|
||||
case $c in
|
||||
--*=*|*.) ;;
|
||||
*) c="$c " ;;
|
||||
esac
|
||||
array[$#array+1]="$c"
|
||||
done
|
||||
compset -P '*[=:]'
|
||||
compadd -Q -S '' -p "${2-}" -a -- array && _ret=0
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
__gitcomp_nl ()
|
||||
{
|
||||
emulate -L zsh
|
||||
|
||||
local IFS=$'\n'
|
||||
compset -P '*[=:]'
|
||||
compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
|
||||
}
|
||||
|
||||
__gitcomp_file ()
|
||||
{
|
||||
emulate -L zsh
|
||||
|
||||
local IFS=$'\n'
|
||||
compset -P '*[=:]'
|
||||
compadd -Q -p "${2-}" -f -- ${=1} && _ret=0
|
||||
}
|
||||
|
||||
__git_zsh_helper ()
|
||||
{
|
||||
emulate -L ksh
|
||||
local cur cword prev
|
||||
cur=${words[CURRENT-1]}
|
||||
prev=${words[CURRENT-2]}
|
||||
let cword=CURRENT-1
|
||||
__${service}_main
|
||||
}
|
||||
|
||||
_git ()
|
||||
{
|
||||
emulate -L zsh
|
||||
local _ret=1
|
||||
__git_zsh_helper
|
||||
let _ret && _default -S '' && _ret=0
|
||||
return _ret
|
||||
}
|
||||
|
||||
compdef _git git gitk
|
||||
return
|
||||
elif [[ -n ${BASH_VERSION-} ]]; then
|
||||
if ((${BASH_VERSINFO[0]} < 4)); then
|
||||
# compopt is not supported
|
||||
__git_index_file_list_filter ()
|
||||
{
|
||||
__git_index_file_list_filter_compat
|
||||
}
|
||||
fi
|
||||
fi
|
||||
|
||||
__git_func_wrap ()
|
||||
{
|
||||
if [[ -n ${ZSH_VERSION-} ]]; then
|
||||
emulate -L bash
|
||||
setopt KSH_TYPESET
|
||||
|
||||
# workaround zsh's bug that leaves 'words' as a special
|
||||
# variable in versions < 4.3.12
|
||||
typeset -h words
|
||||
|
||||
# workaround zsh's bug that quotes spaces in the COMPREPLY
|
||||
# array if IFS doesn't contain spaces.
|
||||
typeset -h IFS
|
||||
fi
|
||||
local cur words cword prev
|
||||
_get_comp_words_by_ref -n =: cur words cword prev
|
||||
$1
|
||||
|
|
|
|||
|
|
@ -10,9 +10,22 @@
|
|||
# 1) Copy this file to somewhere (e.g. ~/.git-prompt.sh).
|
||||
# 2) Add the following line to your .bashrc/.zshrc:
|
||||
# source ~/.git-prompt.sh
|
||||
# 3) Change your PS1 to also show the current branch:
|
||||
# Bash: PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
|
||||
# ZSH: PS1='[%n@%m %c$(__git_ps1 " (%s)")]\$ '
|
||||
# 3a) Change your PS1 to call __git_ps1 as
|
||||
# command-substitution:
|
||||
# Bash: PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
|
||||
# ZSH: PS1='[%n@%m %c$(__git_ps1 " (%s)")]\$ '
|
||||
# the optional argument will be used as format string.
|
||||
# 3b) Alternatively, if you are using bash, __git_ps1 can be
|
||||
# used for PROMPT_COMMAND with two parameters, <pre> and
|
||||
# <post>, which are strings you would put in $PS1 before
|
||||
# and after the status string generated by the git-prompt
|
||||
# machinery. e.g.
|
||||
# PROMPT_COMMAND='__git_ps1 "\u@\h:\w" "\\\$ "'
|
||||
# will show username, at-sign, host, colon, cwd, then
|
||||
# various status string, followed by dollar and SP, as
|
||||
# your prompt.
|
||||
# Optionally, you can supply a third argument with a printf
|
||||
# format string to finetune the output of the branch status
|
||||
#
|
||||
# The argument to __git_ps1 will be displayed only if you are currently
|
||||
# in a git repository. The %s token will be the name of the current
|
||||
|
|
@ -30,7 +43,10 @@
|
|||
#
|
||||
# If you would like to see if there're untracked files, then you can set
|
||||
# GIT_PS1_SHOWUNTRACKEDFILES to a nonempty value. If there're untracked
|
||||
# files, then a '%' will be shown next to the branch name.
|
||||
# files, then a '%' will be shown next to the branch name. You can
|
||||
# configure this per-repository with the bash.showUntrackedFiles
|
||||
# variable, which defaults to true once GIT_PS1_SHOWUNTRACKEDFILES is
|
||||
# enabled.
|
||||
#
|
||||
# If you would like to see the difference between HEAD and its upstream,
|
||||
# set GIT_PS1_SHOWUPSTREAM="auto". A "<" indicates you are behind, ">"
|
||||
|
|
@ -49,6 +65,19 @@
|
|||
# find one, or @{upstream} otherwise. Once you have set
|
||||
# GIT_PS1_SHOWUPSTREAM, you can override it on a per-repository basis by
|
||||
# setting the bash.showUpstream config variable.
|
||||
#
|
||||
# If you would like to see more information about the identity of
|
||||
# commits checked out as a detached HEAD, set GIT_PS1_DESCRIBE_STYLE
|
||||
# to one of these values:
|
||||
#
|
||||
# contains relative to newer annotated tag (v1.6.3.2~35)
|
||||
# branch relative to newer tag or branch (master~4)
|
||||
# describe relative to older annotated tag (v1.6.3.1-13-gdd42c2f)
|
||||
# default exactly matching tag
|
||||
#
|
||||
# If you would like a colored hint about the current dirty state, set
|
||||
# GIT_PS1_SHOWCOLORHINTS to a nonempty value. The colors are based on
|
||||
# the colored output of "git status -sb".
|
||||
|
||||
# __gitdir accepts 0 or 1 arguments (i.e., location)
|
||||
# returns location of .git repo
|
||||
|
|
@ -195,11 +224,43 @@ __git_ps1_show_upstream ()
|
|||
|
||||
|
||||
# __git_ps1 accepts 0 or 1 arguments (i.e., format string)
|
||||
# returns text to add to bash PS1 prompt (includes branch name)
|
||||
# when called from PS1 using command substitution
|
||||
# in this mode it prints text to add to bash PS1 prompt (includes branch name)
|
||||
#
|
||||
# __git_ps1 requires 2 or 3 arguments when called from PROMPT_COMMAND (pc)
|
||||
# in that case it _sets_ PS1. The arguments are parts of a PS1 string.
|
||||
# when two arguments are given, the first is prepended and the second appended
|
||||
# to the state string when assigned to PS1.
|
||||
# The optional third parameter will be used as printf format string to further
|
||||
# customize the output of the git-status string.
|
||||
# In this mode you can request colored hints using GIT_PS1_SHOWCOLORHINTS=true
|
||||
__git_ps1 ()
|
||||
{
|
||||
local pcmode=no
|
||||
local detached=no
|
||||
local ps1pc_start='\u@\h:\w '
|
||||
local ps1pc_end='\$ '
|
||||
local printf_format=' (%s)'
|
||||
|
||||
case "$#" in
|
||||
2|3) pcmode=yes
|
||||
ps1pc_start="$1"
|
||||
ps1pc_end="$2"
|
||||
printf_format="${3:-$printf_format}"
|
||||
;;
|
||||
0|1) printf_format="${1:-$printf_format}"
|
||||
;;
|
||||
*) return
|
||||
;;
|
||||
esac
|
||||
|
||||
local g="$(__gitdir)"
|
||||
if [ -n "$g" ]; then
|
||||
if [ -z "$g" ]; then
|
||||
if [ $pcmode = yes ]; then
|
||||
#In PC mode PS1 always needs to be set
|
||||
PS1="$ps1pc_start$ps1pc_end"
|
||||
fi
|
||||
else
|
||||
local r=""
|
||||
local b=""
|
||||
if [ -f "$g/rebase-merge/interactive" ]; then
|
||||
|
|
@ -226,7 +287,7 @@ __git_ps1 ()
|
|||
fi
|
||||
|
||||
b="$(git symbolic-ref HEAD 2>/dev/null)" || {
|
||||
|
||||
detached=yes
|
||||
b="$(
|
||||
case "${GIT_PS1_DESCRIBE_STYLE-}" in
|
||||
(contains)
|
||||
|
|
@ -259,24 +320,25 @@ __git_ps1 ()
|
|||
b="GIT_DIR!"
|
||||
fi
|
||||
elif [ "true" = "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then
|
||||
if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ]; then
|
||||
if [ "$(git config --bool bash.showDirtyState)" != "false" ]; then
|
||||
git diff --no-ext-diff --quiet --exit-code || w="*"
|
||||
if git rev-parse --quiet --verify HEAD >/dev/null; then
|
||||
git diff-index --cached --quiet HEAD -- || i="+"
|
||||
else
|
||||
i="#"
|
||||
fi
|
||||
if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ] &&
|
||||
[ "$(git config --bool bash.showDirtyState)" != "false" ]
|
||||
then
|
||||
git diff --no-ext-diff --quiet --exit-code || w="*"
|
||||
if git rev-parse --quiet --verify HEAD >/dev/null; then
|
||||
git diff-index --cached --quiet HEAD -- || i="+"
|
||||
else
|
||||
i="#"
|
||||
fi
|
||||
fi
|
||||
if [ -n "${GIT_PS1_SHOWSTASHSTATE-}" ]; then
|
||||
git rev-parse --verify refs/stash >/dev/null 2>&1 && s="$"
|
||||
fi
|
||||
|
||||
if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ]; then
|
||||
if [ -n "$(git ls-files --others --exclude-standard)" ]; then
|
||||
u="%%"
|
||||
fi
|
||||
if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ] &&
|
||||
[ "$(git config --bool bash.showUntrackedFiles)" != "false" ] &&
|
||||
[ -n "$(git ls-files --others --exclude-standard)" ]
|
||||
then
|
||||
u="%%"
|
||||
fi
|
||||
|
||||
if [ -n "${GIT_PS1_SHOWUPSTREAM-}" ]; then
|
||||
|
|
@ -285,6 +347,53 @@ __git_ps1 ()
|
|||
fi
|
||||
|
||||
local f="$w$i$s$u"
|
||||
printf -- "${1:- (%s)}" "$c${b##refs/heads/}${f:+ $f}$r$p"
|
||||
if [ $pcmode = yes ]; then
|
||||
local gitstring=
|
||||
if [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then
|
||||
local c_red='\e[31m'
|
||||
local c_green='\e[32m'
|
||||
local c_lblue='\e[1;34m'
|
||||
local c_clear='\e[0m'
|
||||
local bad_color=$c_red
|
||||
local ok_color=$c_green
|
||||
local branch_color="$c_clear"
|
||||
local flags_color="$c_lblue"
|
||||
local branchstring="$c${b##refs/heads/}"
|
||||
|
||||
if [ $detached = no ]; then
|
||||
branch_color="$ok_color"
|
||||
else
|
||||
branch_color="$bad_color"
|
||||
fi
|
||||
|
||||
# Setting gitstring directly with \[ and \] around colors
|
||||
# is necessary to prevent wrapping issues!
|
||||
gitstring="\[$branch_color\]$branchstring\[$c_clear\]"
|
||||
|
||||
if [ -n "$w$i$s$u$r$p" ]; then
|
||||
gitstring="$gitstring "
|
||||
fi
|
||||
if [ "$w" = "*" ]; then
|
||||
gitstring="$gitstring\[$bad_color\]$w"
|
||||
fi
|
||||
if [ -n "$i" ]; then
|
||||
gitstring="$gitstring\[$ok_color\]$i"
|
||||
fi
|
||||
if [ -n "$s" ]; then
|
||||
gitstring="$gitstring\[$flags_color\]$s"
|
||||
fi
|
||||
if [ -n "$u" ]; then
|
||||
gitstring="$gitstring\[$bad_color\]$u"
|
||||
fi
|
||||
gitstring="$gitstring\[$c_clear\]$r$p"
|
||||
else
|
||||
gitstring="$c${b##refs/heads/}${f:+ $f}$r$p"
|
||||
fi
|
||||
gitstring=$(printf -- "$printf_format" "$gitstring")
|
||||
PS1="$ps1pc_start$gitstring$ps1pc_end"
|
||||
else
|
||||
# NO color option unless in PROMPT_COMMAND mode
|
||||
printf -- "$printf_format" "$c${b##refs/heads/}${f:+ $f}$r$p"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,5 +3,6 @@ source $dir/../git/git.plugin.zsh
|
|||
source $dir/git-prompt.sh
|
||||
|
||||
function git_prompt_info() {
|
||||
__git_ps1 "${ZSH_THEME_GIT_PROMPT_PREFIX//\%/%%}%s${ZSH_THEME_GIT_PROMPT_SUFFIX//\%/%%}"
|
||||
dirty="$(parse_git_dirty)"
|
||||
__git_ps1 "${ZSH_THEME_GIT_PROMPT_PREFIX//\%/%%}%s${dirty//\%/%%}${ZSH_THEME_GIT_PROMPT_SUFFIX//\%/%%}"
|
||||
}
|
||||
|
|
|
|||
151
plugins/go/go.plugin.zsh
Normal file
151
plugins/go/go.plugin.zsh
Normal file
|
|
@ -0,0 +1,151 @@
|
|||
# install in /etc/zsh/zshrc or your personal .zshrc
|
||||
|
||||
# gc
|
||||
prefixes=(5 6 8)
|
||||
for p in $prefixes; do
|
||||
compctl -g "*.${p}" ${p}l
|
||||
compctl -g "*.go" ${p}g
|
||||
done
|
||||
|
||||
# standard go tools
|
||||
compctl -g "*.go" gofmt
|
||||
|
||||
# gccgo
|
||||
compctl -g "*.go" gccgo
|
||||
|
||||
# go tool
|
||||
__go_tool_complete() {
|
||||
typeset -a commands build_flags
|
||||
commands+=(
|
||||
'build[compile packages and dependencies]'
|
||||
'clean[remove object files]'
|
||||
'doc[run godoc on package sources]'
|
||||
'fix[run go tool fix on packages]'
|
||||
'fmt[run gofmt on package sources]'
|
||||
'get[download and install packages and dependencies]'
|
||||
'help[display help]'
|
||||
'install[compile and install packages and dependencies]'
|
||||
'list[list packages]'
|
||||
'run[compile and run Go program]'
|
||||
'test[test packages]'
|
||||
'tool[run specified go tool]'
|
||||
'version[print Go version]'
|
||||
'vet[run go tool vet on packages]'
|
||||
)
|
||||
if (( CURRENT == 2 )); then
|
||||
# explain go commands
|
||||
_values 'go tool commands' ${commands[@]}
|
||||
return
|
||||
fi
|
||||
build_flags=(
|
||||
'-a[force reinstallation of packages that are already up-to-date]'
|
||||
'-n[print the commands but do not run them]'
|
||||
"-p[number of parallel builds]:number"
|
||||
'-x[print the commands]'
|
||||
"-work[print temporary directory name and keep it]"
|
||||
"-gcflags[flags for 5g/6g/8g]:flags"
|
||||
"-ldflags[flags for 5l/6l/8l]:flags"
|
||||
"-gccgoflags[flags for gccgo]:flags"
|
||||
)
|
||||
__go_list() {
|
||||
local expl importpaths
|
||||
declare -a importpaths
|
||||
importpaths=($(go list ${words[$CURRENT]}... 2>/dev/null))
|
||||
_wanted importpaths expl 'import paths' compadd "$@" - "${importpaths[@]}"
|
||||
}
|
||||
case ${words[2]} in
|
||||
clean|doc)
|
||||
_arguments -s -w : '*:importpaths:__go_list'
|
||||
;;
|
||||
fix|fmt|list|vet)
|
||||
_alternative ':importpaths:__go_list' ':files:_path_files -g "*.go"'
|
||||
;;
|
||||
install)
|
||||
_arguments -s -w : ${build_flags[@]} \
|
||||
"-v[show package names]" \
|
||||
'*:importpaths:__go_list'
|
||||
;;
|
||||
get)
|
||||
_arguments -s -w : \
|
||||
${build_flags[@]}
|
||||
;;
|
||||
build)
|
||||
_arguments -s -w : \
|
||||
${build_flags[@]} \
|
||||
"-v[show package names]" \
|
||||
"-o[output file]:file:_files" \
|
||||
"*:args:{ _alternative ':importpaths:__go_list' ':files:_path_files -g \"*.go\"' }"
|
||||
;;
|
||||
test)
|
||||
_arguments -s -w : \
|
||||
${build_flags[@]} \
|
||||
"-c[do not run, compile the test binary]" \
|
||||
"-i[do not run, install dependencies]" \
|
||||
"-v[print test output]" \
|
||||
"-x[print the commands]" \
|
||||
"-short[use short mode]" \
|
||||
"-parallel[number of parallel tests]:number" \
|
||||
"-cpu[values of GOMAXPROCS to use]:number list" \
|
||||
"-run[run tests and examples matching regexp]:regexp" \
|
||||
"-bench[run benchmarks matching regexp]:regexp" \
|
||||
"-benchtime[run each benchmark during n seconds]:duration" \
|
||||
"-timeout[kill test after that duration]:duration" \
|
||||
"-cpuprofile[write CPU profile to file]:file:_files" \
|
||||
"-memprofile[write heap profile to file]:file:_files" \
|
||||
"-memprofilerate[set heap profiling rate]:number" \
|
||||
"*:args:{ _alternative ':importpaths:__go_list' ':files:_path_files -g \"*.go\"' }"
|
||||
;;
|
||||
help)
|
||||
_values "${commands[@]}" \
|
||||
'gopath[GOPATH environment variable]' \
|
||||
'importpath[description of import paths]' \
|
||||
'remote[remote import path syntax]' \
|
||||
'testflag[description of testing flags]' \
|
||||
'testfunc[description of testing functions]'
|
||||
;;
|
||||
run)
|
||||
_arguments -s -w : \
|
||||
${build_flags[@]} \
|
||||
'*:file:_path_files -g "*.go"'
|
||||
;;
|
||||
tool)
|
||||
if (( CURRENT == 3 )); then
|
||||
_values "go tool" $(go tool)
|
||||
return
|
||||
fi
|
||||
case ${words[3]} in
|
||||
[568]g)
|
||||
_arguments -s -w : \
|
||||
'-I[search for packages in DIR]:includes:_path_files -/' \
|
||||
'-L[show full path in file:line prints]' \
|
||||
'-S[print the assembly language]' \
|
||||
'-V[print the compiler version]' \
|
||||
'-e[no limit on number of errors printed]' \
|
||||
'-h[panic on an error]' \
|
||||
'-l[disable inlining]' \
|
||||
'-m[print optimization decisions]' \
|
||||
'-o[file specify output file]:file' \
|
||||
'-p[assumed import path for this code]:importpath' \
|
||||
'-u[disable package unsafe]' \
|
||||
"*:file:_files -g '*.go'"
|
||||
;;
|
||||
[568]l)
|
||||
local O=${words[3]%l}
|
||||
_arguments -s -w : \
|
||||
'-o[file specify output file]:file' \
|
||||
'-L[search for packages in DIR]:includes:_path_files -/' \
|
||||
"*:file:_files -g '*.[ao$O]'"
|
||||
;;
|
||||
dist)
|
||||
_values "dist tool" banner bootstrap clean env install version
|
||||
;;
|
||||
*)
|
||||
# use files by default
|
||||
_files
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
compdef __go_tool_complete go
|
||||
|
|
@ -1,26 +1,30 @@
|
|||
# Based on ssh-agent code
|
||||
|
||||
local GPG_ENV=$HOME/.gnupg/gpg-agent.env
|
||||
|
||||
function start_agent {
|
||||
/usr/bin/env gpg-agent --daemon --enable-ssh-support --write-env-file ${GPG_ENV} > /dev/null
|
||||
chmod 600 ${GPG_ENV}
|
||||
. ${GPG_ENV} > /dev/null
|
||||
function start_agent_nossh {
|
||||
eval $(/usr/bin/env gpg-agent --quiet --daemon --write-env-file ${GPG_ENV} 2> /dev/null)
|
||||
chmod 600 ${GPG_ENV}
|
||||
export GPG_AGENT_INFO
|
||||
}
|
||||
|
||||
# Source GPG agent settings, if applicable
|
||||
function start_agent_withssh {
|
||||
eval $(/usr/bin/env gpg-agent --quiet --daemon --enable-ssh-support --write-env-file ${GPG_ENV} 2> /dev/null)
|
||||
chmod 600 ${GPG_ENV}
|
||||
export GPG_AGENT_INFO
|
||||
export SSH_AUTH_SOCK
|
||||
export SSH_AGENT_PID
|
||||
}
|
||||
|
||||
# source settings of old agent, if applicable
|
||||
if [ -f "${GPG_ENV}" ]; then
|
||||
. ${GPG_ENV} > /dev/null
|
||||
ps -ef | grep ${SSH_AGENT_PID} | grep gpg-agent > /dev/null || {
|
||||
start_agent;
|
||||
}
|
||||
else
|
||||
start_agent;
|
||||
fi
|
||||
|
||||
export GPG_AGENT_INFO
|
||||
export SSH_AUTH_SOCK
|
||||
export SSH_AGENT_PID
|
||||
# check for existing ssh-agent
|
||||
if ssh-add -l > /dev/null 2> /dev/null; then
|
||||
start_agent_nossh;
|
||||
else
|
||||
start_agent_withssh;
|
||||
fi
|
||||
|
||||
GPG_TTY=$(tty)
|
||||
export GPG_TTY
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ _knife() {
|
|||
|
||||
case $state in
|
||||
knifecmd)
|
||||
compadd -Q "$@" bootstrap client configure cookbook "cookbook site" "data bag" exec environment index node recipe role search ssh status windows $cloudproviders
|
||||
compadd -Q "$@" bootstrap client configure cookbook "cookbook site" "data bag" diff exec environment index node recipe role search ssh status upload windows $cloudproviders
|
||||
;;
|
||||
knifesubcmd)
|
||||
case $words[2] in
|
||||
|
|
@ -47,9 +47,12 @@ _knife() {
|
|||
cookbook)
|
||||
compadd -Q "$@" test list create download delete "metadata from" show "bulk delete" metadata upload
|
||||
;;
|
||||
environment)
|
||||
diff)
|
||||
_arguments '*:file or directory:_files -g "*"'
|
||||
;;
|
||||
environment)
|
||||
compadd -Q "$@" list create delete edit show "from file"
|
||||
;;
|
||||
;;
|
||||
node)
|
||||
compadd -Q "$@" "from file" create show edit delete list run_list "bulk delete"
|
||||
;;
|
||||
|
|
@ -59,6 +62,9 @@ _knife() {
|
|||
role)
|
||||
compadd -Q "$@" "bulk delete" create delete edit "from file" list show
|
||||
;;
|
||||
upload)
|
||||
_arguments '*:file or directory:_files -g "*"'
|
||||
;;
|
||||
windows)
|
||||
compadd "$@" bootstrap
|
||||
;;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
alias hgc='hg commit'
|
||||
alias hgb='hg branch'
|
||||
alias hgba='hg branches'
|
||||
alias hgbk='hg bookmarks'
|
||||
alias hgco='hg checkout'
|
||||
alias hgd='hg diff'
|
||||
alias hged='hg diffmerge'
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ function listMavenCompletions {
|
|||
# jboss
|
||||
jboss:start jboss:stop jboss:deploy jboss:undeploy jboss:redeploy
|
||||
# tomcat
|
||||
tomcat:start tomcat:stop tomcat:deploy tomcat:undeploy tomcat:undeploy
|
||||
tomcat:start tomcat:stop tomcat:deploy tomcat:undeploy tomcat:redeploy
|
||||
# tomcat6
|
||||
tomcat6:run tomcat6:run-war tomcat6:run-war-only tomcat6:stop tomcat6:deploy tomcat6:undeploy
|
||||
# tomcat7
|
||||
|
|
|
|||
|
|
@ -10,6 +10,9 @@ alias migrate='rake db:migrate && rake db:test:prepare'
|
|||
alias sc='ruby script/console'
|
||||
alias sd='ruby script/server --debugger'
|
||||
alias devlog='tail -f log/development.log'
|
||||
alias -g RET='RAILS_ENV=test'
|
||||
alias -g REP='RAILS_ENV=production'
|
||||
alias -g RED='RAILS_ENV=development'
|
||||
|
||||
function remote_console() {
|
||||
/usr/bin/env ssh $1 "( cd $2 && ruby script/console production )"
|
||||
|
|
|
|||
|
|
@ -21,3 +21,6 @@ alias rsd='_rails_command server --debugger'
|
|||
alias devlog='tail -f log/development.log'
|
||||
alias rdm='rake db:migrate'
|
||||
alias rdr='rake db:rollback'
|
||||
alias -g RET='RAILS_ENV=test'
|
||||
alias -g REP='RAILS_ENV=production'
|
||||
alias -g RED='RAILS_ENV=development'
|
||||
|
|
|
|||
30
plugins/rails4/rails4.plugin.zsh
Normal file
30
plugins/rails4/rails4.plugin.zsh
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
# Rails 4 aliases
|
||||
|
||||
function _rails_command () {
|
||||
if [ -e "script/server" ]; then
|
||||
ruby script/$@
|
||||
elif [ -e "script/rails" ]; then
|
||||
ruby script/rails $@
|
||||
else
|
||||
ruby bin/rails $@
|
||||
fi
|
||||
}
|
||||
|
||||
alias rc='_rails_command console'
|
||||
alias rd='_rails_command destroy'
|
||||
alias rdb='_rails_command dbconsole'
|
||||
alias rdbm='rake db:migrate db:test:clone'
|
||||
alias rg='_rails_command generate'
|
||||
alias rgm='_rails_command generate migration'
|
||||
alias rp='_rails_command plugin'
|
||||
alias ru='_rails_command runner'
|
||||
alias rs='_rails_command server'
|
||||
alias rsd='_rails_command server --debugger'
|
||||
alias devlog='tail -f log/development.log'
|
||||
alias rdm='rake db:migrate'
|
||||
alias rdc='rake db:create'
|
||||
alias rdr='rake db:rollback'
|
||||
alias rds='rake db:seed'
|
||||
alias rlc='rake log:clear'
|
||||
alias rn='rake notes'
|
||||
alias rr='rake routes'
|
||||
|
|
@ -3,9 +3,9 @@ fpath=($rvm_path/scripts/zsh/Completion $fpath)
|
|||
alias rubies='rvm list rubies'
|
||||
alias gemsets='rvm gemset list'
|
||||
|
||||
local ruby18='ruby-1.8.7-p334'
|
||||
local ruby19='ruby-1.9.3-p385'
|
||||
local ruby20='ruby-2.0.0-rc2'
|
||||
local ruby18='ruby-1.8.7-p371'
|
||||
local ruby19='ruby-1.9.3-p392'
|
||||
local ruby20='ruby-2.0.0-p0'
|
||||
|
||||
function rb18 {
|
||||
if [ -z "$1" ]; then
|
||||
|
|
|
|||
|
|
@ -43,12 +43,12 @@ function _paste_insert() {
|
|||
|
||||
function _zle_line_init() {
|
||||
# Tell terminal to send escape codes around pastes.
|
||||
[[ $TERM == rxvt-unicode || $TERM == xterm || $TERM = xterm-256color ]] && printf '\e[?2004h'
|
||||
[[ $TERM == rxvt-unicode || $TERM == xterm || $TERM = xterm-256color || $TERM = screen || $TERM = screen-256color ]] && printf '\e[?2004h'
|
||||
}
|
||||
|
||||
function _zle_line_finish() {
|
||||
# Tell it to stop when we leave zle, so pasting in other programs
|
||||
# doesn't get the ^[[200~ codes around the pasted text.
|
||||
[[ $TERM == rxvt-unicode || $TERM == xterm || $TERM = xterm-256color ]] && printf '\e[?2004l'
|
||||
[[ $TERM == rxvt-unicode || $TERM == xterm || $TERM = xterm-256color || $TERM = screen || $TERM = screen-256color ]] && printf '\e[?2004l'
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ elif [[ $('uname') == 'Darwin' ]]; then
|
|||
for _sublime_path in $_sublime_darwin_paths; do
|
||||
if [[ -a $_sublime_path ]]; then
|
||||
alias st="'$_sublime_path'"
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -1,62 +1,76 @@
|
|||
|
||||
function svn_prompt_info {
|
||||
if [ $(in_svn) ]; then
|
||||
if [ "x$SVN_SHOW_BRANCH" = "xtrue" ]; then
|
||||
unset SVN_SHOW_BRANCH
|
||||
_DISPLAY=$(svn_get_branch_name)
|
||||
else
|
||||
_DISPLAY=$(svn_get_repo_name)
|
||||
fi
|
||||
echo "$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_PREFIX\
|
||||
$ZSH_THEME_REPO_NAME_COLOR$_DISPLAY$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_SUFFIX$ZSH_PROMPT_BASE_COLOR$(svn_dirty)$ZSH_PROMPT_BASE_COLOR"
|
||||
unset _DISPLAY
|
||||
# vim:ft=zsh ts=2 sw=2 sts=2
|
||||
#
|
||||
function svn_prompt_info() {
|
||||
if in_svn; then
|
||||
if [ "x$SVN_SHOW_BRANCH" = "xtrue" ]; then
|
||||
unset SVN_SHOW_BRANCH
|
||||
_DISPLAY=$(svn_get_branch_name)
|
||||
else
|
||||
_DISPLAY=$(svn_get_repo_name)
|
||||
fi
|
||||
echo "$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_PREFIX\
|
||||
$ZSH_THEME_REPO_NAME_COLOR$_DISPLAY$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_SUFFIX$ZSH_PROMPT_BASE_COLOR$(svn_dirty)$ZSH_PROMPT_BASE_COLOR"
|
||||
unset _DISPLAY
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
function in_svn() {
|
||||
if [[ -d .svn ]]; then
|
||||
echo 1
|
||||
fi
|
||||
if $(svn info >/dev/null 2>&1); then
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
function svn_get_repo_name {
|
||||
if [ $(in_svn) ]; then
|
||||
svn info | sed -n 's/Repository\ Root:\ .*\///p' | read SVN_ROOT
|
||||
|
||||
svn info | sed -n "s/URL:\ .*$SVN_ROOT\///p"
|
||||
fi
|
||||
function svn_get_repo_name() {
|
||||
if in_svn; then
|
||||
svn info | sed -n 's/Repository\ Root:\ .*\///p' | read SVN_ROOT
|
||||
svn info | sed -n "s/URL:\ .*$SVN_ROOT\///p"
|
||||
fi
|
||||
}
|
||||
|
||||
function svn_get_branch_name {
|
||||
_DISPLAY=$(svn info 2> /dev/null | awk -F/ '/^URL:/ { for (i=0; i<=NF; i++) { if ($i == "branches" || $i == "tags" ) { print $(i+1); break }; if ($i == "trunk") { print $i; break } } }')
|
||||
if [ "x$_DISPLAY" = "x" ]; then
|
||||
svn_get_repo_name
|
||||
function svn_get_branch_name() {
|
||||
_DISPLAY=$(
|
||||
svn info 2> /dev/null | \
|
||||
awk -F/ \
|
||||
'/^URL:/ { \
|
||||
for (i=0; i<=NF; i++) { \
|
||||
if ($i == "branches" || $i == "tags" ) { \
|
||||
print $(i+1); \
|
||||
break;\
|
||||
}; \
|
||||
if ($i == "trunk") { print $i; break; } \
|
||||
} \
|
||||
}'
|
||||
)
|
||||
|
||||
if [ "x$_DISPLAY" = "x" ]; then
|
||||
svn_get_repo_name
|
||||
else
|
||||
echo $_DISPLAY
|
||||
fi
|
||||
unset _DISPLAY
|
||||
}
|
||||
|
||||
function svn_get_rev_nr() {
|
||||
if in_svn; then
|
||||
svn info 2> /dev/null | sed -n 's/Revision:\ //p'
|
||||
fi
|
||||
}
|
||||
|
||||
function svn_dirty_choose() {
|
||||
if in_svn; then
|
||||
root=`svn info 2> /dev/null | sed -n 's/^Working Copy Root Path: //p'`
|
||||
if $(svn status $root 2> /dev/null | grep -Eq '^\s*[ACDIM!?L]'); then
|
||||
# Grep exits with 0 when "One or more lines were selected", return "dirty".
|
||||
echo $1
|
||||
else
|
||||
echo $_DISPLAY
|
||||
# Otherwise, no lines were found, or an error occurred. Return clean.
|
||||
echo $2
|
||||
fi
|
||||
unset _DISPLAY
|
||||
fi
|
||||
}
|
||||
|
||||
function svn_get_rev_nr {
|
||||
if [ $(in_svn) ]; then
|
||||
svn info 2> /dev/null | sed -n s/Revision:\ //p
|
||||
fi
|
||||
}
|
||||
|
||||
function svn_dirty_choose {
|
||||
if [ $(in_svn) ]; then
|
||||
svn status 2> /dev/null | grep -Eq '^\s*[ACDIM!?L]'
|
||||
if [ $pipestatus[-1] -eq 0 ]; then
|
||||
# Grep exits with 0 when "One or more lines were selected", return "dirty".
|
||||
echo $1
|
||||
else
|
||||
# Otherwise, no lines were found, or an error occurred. Return clean.
|
||||
echo $2
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function svn_dirty {
|
||||
svn_dirty_choose $ZSH_THEME_SVN_PROMPT_DIRTY $ZSH_THEME_SVN_PROMPT_CLEAN
|
||||
function svn_dirty() {
|
||||
svn_dirty_choose $ZSH_THEME_SVN_PROMPT_DIRTY $ZSH_THEME_SVN_PROMPT_CLEAN
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
# Symfony2 basic command completion
|
||||
|
||||
_symfony2_get_command_list () {
|
||||
app/console --no-ansi | sed "1,/Available commands/d" | awk '/^ [a-z]+/ { print $1 }'
|
||||
php app/console --no-ansi | sed "1,/Available commands/d" | awk '/^ [a-z]+/ { print $1 }'
|
||||
}
|
||||
|
||||
_symfony2 () {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,16 @@ alias etts='mate app config lib db public script spec test vendor/plugins vendor
|
|||
# Edit Ruby app in TextMate
|
||||
alias mr='mate CHANGELOG app config db lib public script spec test'
|
||||
|
||||
# If the tm command is called without an argument, open TextMate in the current directory
|
||||
# If tm is passed a directory, cd to it and open it in TextMate
|
||||
# If tm is passed a file, open it in TextMate
|
||||
function tm() {
|
||||
cd $1
|
||||
mate $1
|
||||
if [[ -z $1 ]]; then
|
||||
mate .
|
||||
else
|
||||
mate $1
|
||||
if [[ -d $1 ]]; then
|
||||
cd $1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
|
|
|||
9
plugins/virtualenv/virtualenv.plugin.zsh
Normal file
9
plugins/virtualenv/virtualenv.plugin.zsh
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
function virtualenv_prompt_info(){
|
||||
local virtualenv_path="$VIRTUAL_ENV"
|
||||
if [[ -n $virtualenv_path ]]; then
|
||||
local virtualenv_name=`basename $virtualenv_path`
|
||||
printf "%s[%s] " "%{${fg[yellow]}%}" $virtualenv_name
|
||||
fi
|
||||
}
|
||||
|
||||
export VIRTUAL_ENV_DISABLE_PROMPT=1
|
||||
34
plugins/zeus/_zeus
Normal file
34
plugins/zeus/_zeus
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
#compdef zeus
|
||||
#autoload
|
||||
|
||||
# in order to make this work, you will need to have the gem zeus installed
|
||||
|
||||
# zeus zsh completion, based on adb completion
|
||||
|
||||
local -a _1st_arguments
|
||||
_1st_arguments=(
|
||||
'console:Lets you interact with your Rails application from the command line. (alias = c)'
|
||||
'cucumber:Runs cucumber.'
|
||||
'dbconsole:Figures out which database you are using and drops you into whichever command line interface.'
|
||||
'destroy:Figures out what generate did, and undoes it. (alias = d)'
|
||||
'generate:Uses templates to create a whole lot of things. (alias = g)'
|
||||
'rake:Execute rake tasks.'
|
||||
'runner:Runs Ruby code in the context of Rails non-interactively. (alias = r)'
|
||||
'server:Launches a small web server named WEBrick which comes bundled with Ruby. (alias = s)'
|
||||
'start:Preloads the zeus environment'
|
||||
'test:Runs RSpec tests. (alias = rspec, testrb)'
|
||||
'version:Shows the version number.'
|
||||
)
|
||||
|
||||
local expl
|
||||
local -a pkgs installed_pkgs
|
||||
|
||||
_arguments \
|
||||
'*:: :->subcmds' && return 0
|
||||
|
||||
if (( CURRENT == 1 )); then
|
||||
_describe -t commands "zeus subcommand" _1st_arguments
|
||||
return
|
||||
fi
|
||||
|
||||
_files
|
||||
|
|
@ -17,7 +17,7 @@ ZSH_THEME="robbyrussell"
|
|||
# Comment this out to disable bi-weekly auto-update checks
|
||||
# DISABLE_AUTO_UPDATE="true"
|
||||
|
||||
# Uncomment to change how many often would you like to wait before auto-updates occur? (in days)
|
||||
# Uncomment to change how often before auto-updates occur? (in days)
|
||||
# export UPDATE_ZSH_DAYS=13
|
||||
|
||||
# Uncomment following line if you want to disable colors in ls
|
||||
|
|
@ -26,9 +26,17 @@ ZSH_THEME="robbyrussell"
|
|||
# Uncomment following line if you want to disable autosetting terminal title.
|
||||
# DISABLE_AUTO_TITLE="true"
|
||||
|
||||
# Uncomment following line if you want to disable command autocorrection
|
||||
# DISABLE_CORRECTION="true"
|
||||
|
||||
# Uncomment following line if you want red dots to be displayed while waiting for completion
|
||||
# COMPLETION_WAITING_DOTS="true"
|
||||
|
||||
# Uncomment following line if you want to disable marking untracked files under
|
||||
# VCS as dirty. This makes repository status check for large repositories much,
|
||||
# much faster.
|
||||
# DISABLE_UNTRACKED_FILES_DIRTY="true"
|
||||
|
||||
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
|
||||
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
|
||||
# Example format: plugins=(rails git textmate ruby lighthouse)
|
||||
|
|
|
|||
|
|
@ -71,7 +71,6 @@ prompt_context() {
|
|||
prompt_git() {
|
||||
local ref dirty
|
||||
if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then
|
||||
ZSH_THEME_GIT_PROMPT_DIRTY='±'
|
||||
dirty=$(parse_git_dirty)
|
||||
ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git show-ref --head -s --abbrev |head -n1 2> /dev/null)"
|
||||
if [[ -n $dirty ]]; then
|
||||
|
|
@ -79,7 +78,19 @@ prompt_git() {
|
|||
else
|
||||
prompt_segment green black
|
||||
fi
|
||||
echo -n "${ref/refs\/heads\//⭠ }$dirty"
|
||||
|
||||
setopt promptsubst
|
||||
autoload -Uz vcs_info
|
||||
|
||||
zstyle ':vcs_info:*' enable git
|
||||
zstyle ':vcs_info:*' get-revision true
|
||||
zstyle ':vcs_info:*' check-for-changes true
|
||||
zstyle ':vcs_info:*' stagedstr '✚'
|
||||
zstyle ':vcs_info:git:*' unstagedstr '●'
|
||||
zstyle ':vcs_info:*' formats ' %u%c'
|
||||
zstyle ':vcs_info:*' actionformats '%u%c'
|
||||
vcs_info
|
||||
echo -n "${ref/refs\/heads\//⭠ }${vcs_info_msg_0_}"
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
|
|||
120
themes/avit.zsh-theme
Normal file
120
themes/avit.zsh-theme
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
#
|
||||
# Author:: Andrew Vit (<andrew@avit.ca>)
|
||||
#
|
||||
# AVIT ZSH Theme
|
||||
#
|
||||
# Copyright 2011, Andrew Vit
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
PROMPT='
|
||||
$(_user_host)${_current_dir} $(git_prompt_info) $(_ruby_version)
|
||||
▶ '
|
||||
|
||||
PROMPT2='%{$fg[grey]%}◀%{$reset_color%} '
|
||||
|
||||
RPROMPT='$(_vi_status)%{$(echotc UP 1)%}$(_git_time_since_commit) $(git_prompt_status) ${_return_status}%{$(echotc DO 1)%}'
|
||||
|
||||
local _current_dir="%{$fg[blue]%}%3~%{$reset_color%} "
|
||||
local _return_status="%{$fg[red]%}%(?..⍉)%{$reset_color%}"
|
||||
local _hist_no="%{$fg[grey]%}%h%{$reset_color%}"
|
||||
|
||||
function _user_host() {
|
||||
if [[ -n $SSH_CONNECTION ]]; then
|
||||
me="%n@%m"
|
||||
elif [[ $LOGNAME != $USER ]]; then
|
||||
me="%n"
|
||||
fi
|
||||
if [[ -n $me ]]; then
|
||||
echo "%{$fg[cyan]%}$me%{$reset_color%}:"
|
||||
fi
|
||||
}
|
||||
|
||||
function _vi_status() {
|
||||
if {echo $fpath | grep -q "plugins/vi-mode"}; then
|
||||
echo "$(vi_mode_prompt_info)"
|
||||
fi
|
||||
}
|
||||
|
||||
function _ruby_version() {
|
||||
if {echo $fpath | grep -q "plugins/rvm"}; then
|
||||
echo "%{$fg[grey]%}$(rvm_prompt_info)%{$reset_color%}"
|
||||
fi
|
||||
}
|
||||
|
||||
# Determine the time since last commit. If branch is clean,
|
||||
# use a neutral color, otherwise colors will vary according to time.
|
||||
function _git_time_since_commit() {
|
||||
if git rev-parse --git-dir > /dev/null 2>&1; then
|
||||
# Only proceed if there is actually a commit.
|
||||
if [[ $(git log 2>&1 > /dev/null | grep -c "^fatal: bad default revision") == 0 ]]; then
|
||||
# Get the last commit.
|
||||
last_commit=$(git log --pretty=format:'%at' -1 2> /dev/null)
|
||||
now=$(date +%s)
|
||||
seconds_since_last_commit=$((now-last_commit))
|
||||
|
||||
# Totals
|
||||
minutes=$((seconds_since_last_commit / 60))
|
||||
hours=$((seconds_since_last_commit/3600))
|
||||
|
||||
# Sub-hours and sub-minutes
|
||||
days=$((seconds_since_last_commit / 86400))
|
||||
sub_hours=$((hours % 24))
|
||||
sub_minutes=$((minutes % 60))
|
||||
|
||||
if [ $hours -gt 24 ]; then
|
||||
commit_age="${days}d"
|
||||
elif [ $minutes -gt 60 ]; then
|
||||
commit_age="${sub_hours}h${sub_minutes}m"
|
||||
else
|
||||
commit_age="${minutes}m"
|
||||
fi
|
||||
|
||||
color=$ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL
|
||||
echo "$color$commit_age%{$reset_color%}"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
if [[ $USER == "root" ]]; then
|
||||
CARETCOLOR="red"
|
||||
else
|
||||
CARETCOLOR="white"
|
||||
fi
|
||||
|
||||
MODE_INDICATOR="%{$fg_bold[yellow]%}❮%{$reset_color%}%{$fg[yellow]%}❮❮%{$reset_color%}"
|
||||
|
||||
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[green]%}"
|
||||
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
|
||||
|
||||
ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg[red]%}✗%{$reset_color%}"
|
||||
ZSH_THEME_GIT_PROMPT_CLEAN=" %{$fg[green]%}✔%{$reset_color%}"
|
||||
ZSH_THEME_GIT_PROMPT_ADDED="%{$fg[green]%}✚ "
|
||||
ZSH_THEME_GIT_PROMPT_MODIFIED="%{$fg[yellow]%}⚑ "
|
||||
ZSH_THEME_GIT_PROMPT_DELETED="%{$fg[red]%}✖ "
|
||||
ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg[blue]%}▴ "
|
||||
ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg[cyan]%}§ "
|
||||
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[grey]%}◒ "
|
||||
|
||||
# Colors vary depending on time lapsed.
|
||||
ZSH_THEME_GIT_TIME_SINCE_COMMIT_SHORT="%{$fg[green]%}"
|
||||
ZSH_THEME_GIT_TIME_SHORT_COMMIT_MEDIUM="%{$fg[yellow]%}"
|
||||
ZSH_THEME_GIT_TIME_SINCE_COMMIT_LONG="%{$fg[red]%}"
|
||||
ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL="%{$fg[grey]%}"
|
||||
|
||||
# LS colors, made with http://geoff.greer.fm/lscolors/
|
||||
export LSCOLORS="exfxcxdxbxegedabagacad"
|
||||
export LS_COLORS='di=34;40:ln=35;40:so=32;40:pi=33;40:ex=31;40:bd=34;46:cd=34;43:su=0;41:sg=0;46:tw=0;42:ow=0;43:'
|
||||
export GREP_COLOR='1;33'
|
||||
|
||||
|
|
@ -29,7 +29,7 @@ ZSH_THEME_GIT_PROMPT_DIRTY=" $CRUNCH_GIT_DIRTY_COLOR✗"
|
|||
|
||||
# Our elements:
|
||||
CRUNCH_TIME_="$CRUNCH_BRACKET_COLOR{$CRUNCH_TIME_COLOR%T$CRUNCH_BRACKET_COLOR}%{$reset_color%}"
|
||||
if which rvm-prompt &> /dev/null; then
|
||||
if [ -e ~/.rvm/bin/rvm-prompt ]; then
|
||||
CRUNCH_RVM_="$CRUNCH_BRACKET_COLOR"["$CRUNCH_RVM_COLOR\${\$(~/.rvm/bin/rvm-prompt i v g)#ruby-}$CRUNCH_BRACKET_COLOR"]"%{$reset_color%}"
|
||||
else
|
||||
if which rbenv &> /dev/null; then
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
# Grab the current date (%D) and time (%T) wrapped in {}: {%D %T}
|
||||
DALLAS_CURRENT_TIME_="%{$fg[white]%}{%{$fg[yellow]%}%D %T%{$fg[white]%}}%{$reset_color%}"
|
||||
# Grab the current version of ruby in use (via RVM): [ruby-1.8.7]
|
||||
if which rvm-prompt &> /dev/null; then
|
||||
if [ -e ~/.rvm/bin/rvm-prompt ]; then
|
||||
DALLAS_CURRENT_RUBY_="%{$fg[white]%}[%{$fg[magenta]%}\$(~/.rvm/bin/rvm-prompt i v)%{$fg[white]%}]%{$reset_color%}"
|
||||
else
|
||||
if which rbenv &> /dev/null; then
|
||||
|
|
|
|||
31
themes/essembeh.zsh-theme
Normal file
31
themes/essembeh.zsh-theme
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
# Theme with full path names and hostname
|
||||
# Handy if you work on different servers all the time;
|
||||
|
||||
|
||||
local return_code="%(?..%{$fg_bold[red]%}%? ↵%{$reset_color%})"
|
||||
|
||||
function my_git_prompt_info() {
|
||||
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
|
||||
GIT_STATUS=$(git_prompt_status)
|
||||
[[ -n $GIT_STATUS ]] && GIT_STATUS=" $GIT_STATUS"
|
||||
echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$GIT_STATUS$ZSH_THEME_GIT_PROMPT_SUFFIX"
|
||||
}
|
||||
|
||||
# Colored prompt
|
||||
ZSH_THEME_COLOR_USER="green"
|
||||
ZSH_THEME_COLOR_HOST="green"
|
||||
ZSH_THEME_COLOR_PWD="yellow"
|
||||
test -n "$SSH_CONNECTION" && ZSH_THEME_COLOR_USER="red" && ZSH_THEME_COLOR_HOST="red"
|
||||
test `id -u` = 0 && ZSH_THEME_COLOR_USER="magenta" && ZSH_THEME_COLOR_HOST="magenta"
|
||||
PROMPT='%{$fg_bold[$ZSH_THEME_COLOR_USER]%}%n@%{$fg_bold[$ZSH_THEME_COLOR_HOST]%}%M%{$reset_color%}:%{$fg_bold[$ZSH_THEME_COLOR_PWD]%}%~%{$reset_color%} $(my_git_prompt_info)%(!.#.$) '
|
||||
RPS1="${return_code}"
|
||||
|
||||
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[cyan]%}("
|
||||
ZSH_THEME_GIT_PROMPT_SUFFIX=") %{$reset_color%}"
|
||||
ZSH_THEME_GIT_PROMPT_UNTRACKED="%%"
|
||||
ZSH_THEME_GIT_PROMPT_ADDED="+"
|
||||
ZSH_THEME_GIT_PROMPT_MODIFIED="*"
|
||||
ZSH_THEME_GIT_PROMPT_RENAMED="~"
|
||||
ZSH_THEME_GIT_PROMPT_DELETED="!"
|
||||
ZSH_THEME_GIT_PROMPT_UNMERGED="?"
|
||||
|
||||
|
|
@ -1,8 +1,13 @@
|
|||
# ZSH Theme emulating the Fish shell's default prompt.
|
||||
|
||||
_fishy_collapsed_wd() {
|
||||
echo $(pwd | perl -pe "s|^$HOME|~|g; s|/([^/])[^/]*(?=/)|/\$1|g")
|
||||
}
|
||||
echo $(pwd | perl -pe "
|
||||
BEGIN {
|
||||
binmode STDIN, ':encoding(UTF-8)';
|
||||
binmode STDOUT, ':encoding(UTF-8)';
|
||||
}; s|^$HOME|~|g; s|/([^/])[^/]*(?=/)|/\$1|g
|
||||
")
|
||||
}
|
||||
|
||||
local user_color='green'; [ $UID -eq 0 ] && user_color='red'
|
||||
PROMPT='%n@%m %{$fg[$user_color]%}$(_fishy_collapsed_wd)%{$reset_color%}%(!.#.>) '
|
||||
|
|
|
|||
99
themes/half-life.zsh-theme
Normal file
99
themes/half-life.zsh-theme
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
# prompt style and colors based on Steve Losh's Prose theme:
|
||||
# http://github.com/sjl/oh-my-zsh/blob/master/themes/prose.zsh-theme
|
||||
#
|
||||
# vcs_info modifications from Bart Trojanowski's zsh prompt:
|
||||
# http://www.jukie.net/bart/blog/pimping-out-zsh-prompt
|
||||
#
|
||||
# git untracked files modification from Brian Carper:
|
||||
# http://briancarper.net/blog/570/git-info-in-your-zsh-prompt
|
||||
|
||||
function virtualenv_info {
|
||||
[ $VIRTUAL_ENV ] && echo '('`basename $VIRTUAL_ENV`') '
|
||||
}
|
||||
PR_GIT_UPDATE=1
|
||||
|
||||
setopt prompt_subst
|
||||
autoload colors
|
||||
colors
|
||||
|
||||
autoload -U add-zsh-hook
|
||||
autoload -Uz vcs_info
|
||||
|
||||
#use extended color pallete if available
|
||||
if [[ $TERM = *256color* || $TERM = *rxvt* ]]; then
|
||||
turquoise="%F{81}"
|
||||
orange="%F{166}"
|
||||
purple="%F{135}"
|
||||
hotpink="%F{161}"
|
||||
limegreen="%F{118}"
|
||||
else
|
||||
turquoise="$fg[cyan]"
|
||||
orange="$fg[yellow]"
|
||||
purple="$fg[magenta]"
|
||||
hotpink="$fg[red]"
|
||||
limegreen="$fg[green]"
|
||||
fi
|
||||
|
||||
# enable VCS systems you use
|
||||
zstyle ':vcs_info:*' enable git svn
|
||||
|
||||
# check-for-changes can be really slow.
|
||||
# you should disable it, if you work with large repositories
|
||||
zstyle ':vcs_info:*:prompt:*' check-for-changes true
|
||||
|
||||
# set formats
|
||||
# %b - branchname
|
||||
# %u - unstagedstr (see below)
|
||||
# %c - stagedstr (see below)
|
||||
# %a - action (e.g. rebase-i)
|
||||
# %R - repository path
|
||||
# %S - path in the repository
|
||||
PR_RST="%{${reset_color}%}"
|
||||
FMT_BRANCH=" on %{$turquoise%}%b%u%c${PR_RST}"
|
||||
FMT_ACTION=" performing a %{$limegreen%}%a${PR_RST}"
|
||||
FMT_UNSTAGED="%{$orange%}●"
|
||||
FMT_STAGED="%{$limegreen%}●"
|
||||
|
||||
zstyle ':vcs_info:*:prompt:*' unstagedstr "${FMT_UNSTAGED}"
|
||||
zstyle ':vcs_info:*:prompt:*' stagedstr "${FMT_STAGED}"
|
||||
zstyle ':vcs_info:*:prompt:*' actionformats "${FMT_BRANCH}${FMT_ACTION}"
|
||||
zstyle ':vcs_info:*:prompt:*' formats "${FMT_BRANCH}"
|
||||
zstyle ':vcs_info:*:prompt:*' nvcsformats ""
|
||||
|
||||
|
||||
function steeef_preexec {
|
||||
case "$(history $HISTCMD)" in
|
||||
*git*)
|
||||
PR_GIT_UPDATE=1
|
||||
;;
|
||||
*svn*)
|
||||
PR_GIT_UPDATE=1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
add-zsh-hook preexec steeef_preexec
|
||||
|
||||
function steeef_chpwd {
|
||||
PR_GIT_UPDATE=1
|
||||
}
|
||||
add-zsh-hook chpwd steeef_chpwd
|
||||
|
||||
function steeef_precmd {
|
||||
if [[ -n "$PR_GIT_UPDATE" ]] ; then
|
||||
# check for untracked files or updated submodules, since vcs_info doesn't
|
||||
if [[ ! -z $(git ls-files --other --exclude-standard 2> /dev/null) ]]; then
|
||||
PR_GIT_UPDATE=1
|
||||
FMT_BRANCH="${PM_RST} on %{$turquoise%}%b%u%c%{$hotpink%}●${PR_RST}"
|
||||
else
|
||||
FMT_BRANCH="${PM_RST} on %{$turquoise%}%b%u%c${PR_RST}"
|
||||
fi
|
||||
zstyle ':vcs_info:*:prompt:*' formats "${FMT_BRANCH}"
|
||||
|
||||
vcs_info 'prompt'
|
||||
PR_GIT_UPDATE=
|
||||
fi
|
||||
}
|
||||
add-zsh-hook precmd steeef_precmd
|
||||
|
||||
PROMPT=$'
|
||||
%{$purple%}%n%{$reset_color%} in %{$limegreen%}%~%{$reset_color%}$(rvm-prompt " with%{$fg[red]%} " v g "%{$reset_color%}")$vcs_info_msg_0_%{$orange%} λ%{$reset_color%} '
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
# ZSH Theme - Preview: http://gyazo.com/8becc8a7ed5ab54a0262a470555c3eed.png
|
||||
local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
|
||||
|
||||
if which rvm-prompt &> /dev/null; then
|
||||
if [ -e ~/.rvm/bin/rvm-prompt ]; then
|
||||
PROMPT='%{$fg[green]%}%~%{$reset_color%} %{$fg[red]%}‹$(~/.rvm/bin/rvm-prompt i v)› %{$reset_color%} $(git_prompt_info)%{$reset_color%}%B$%b '
|
||||
else
|
||||
if which rbenv &> /dev/null; then
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
# ZSH Theme - Preview: http://gyazo.com/8becc8a7ed5ab54a0262a470555c3eed.png
|
||||
local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
|
||||
|
||||
if which rvm-prompt &> /dev/null; then
|
||||
if [ -e ~/.rvm/bin/rvm-prompt ]; then
|
||||
PROMPT='%{$fg[green]%}%~%{$reset_color%} %{$fg[red]%}‹$(~/.rvm/bin/rvm-prompt i v)› %{$reset_color%} $(git_prompt_info)%{$reset_color%}%B$%b '
|
||||
else
|
||||
if which rbenv &> /dev/null; then
|
||||
|
|
|
|||
|
|
@ -24,6 +24,6 @@ function mygit() {
|
|||
|
||||
# alternate prompt with git & hg
|
||||
PROMPT=$'%{\e[0;34m%}%B┌─[%b%{\e[0m%}%{\e[1;32m%}%n%{\e[1;30m%}@%{\e[0m%}%{\e[0;36m%}%m%{\e[0;34m%}%B]%b%{\e[0m%} - %b%{\e[0;34m%}%B[%b%{\e[1;37m%}%~%{\e[0;34m%}%B]%b%{\e[0m%} - %{\e[0;34m%}%B[%b%{\e[0;33m%}'%D{"%Y-%m-%d %I:%M:%S"}%b$'%{\e[0;34m%}%B]%b%{\e[0m%}
|
||||
%{\e[0;34m%}%B└─%B[%{\e[1;35m%}$%{\e[0;34m%}%B] <$(mygit)$(hg_prompt_info)>%{\e[0m%}%b '
|
||||
%{\e[0;34m%}%B└─%B[%{\e[1;35m%}%?$(retcode)%{\e[0;34m%}%B] <$(mygit)$(hg_prompt_info)>%{\e[0m%}%b '
|
||||
PS2=$' \e[0;34m%}%B>%{\e[0m%}%b '
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,6 @@
|
|||
# entry in a nice long thread on the Arch Linux forums: http://bbs.archlinux.org/viewtopic.php?pid=521888#p521888
|
||||
|
||||
PROMPT=$'%{\e[0;34m%}%B┌─[%b%{\e[0m%}%{\e[1;32m%}%n%{\e[1;30m%}@%{\e[0m%}%{\e[0;36m%}%m%{\e[0;34m%}%B]%b%{\e[0m%} - %b%{\e[0;34m%}%B[%b%{\e[1;37m%}%~%{\e[0;34m%}%B]%b%{\e[0m%} - %{\e[0;34m%}%B[%b%{\e[0;33m%}'%D{"%Y-%m-%d %I:%M:%S"}%b$'%{\e[0;34m%}%B]%b%{\e[0m%}
|
||||
%{\e[0;34m%}%B└─%B[%{\e[1;35m%}$%{\e[0;34m%}%B]%{\e[0m%}%b '
|
||||
%{\e[0;34m%}%B└─%B[%{\e[1;35m%}%?$(retcode)%{\e[0;34m%}%B]%{\e[0m%}%b '
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# Grab the current version of ruby in use (via RVM): [ruby-1.8.7]
|
||||
if which rvm-prompt &> /dev/null; then
|
||||
if [ -e ~/.rvm/bin/rvm-prompt ]; then
|
||||
JARIN_CURRENT_RUBY_="%{$fg[white]%}[%{$fg[red]%}\$(~/.rvm/bin/rvm-prompt i v)%{$fg[white]%}]%{$reset_color%}"
|
||||
else
|
||||
if which rbenv &> /dev/null; then
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
PROMPT='%{$fg_bold[green]%}%p %{$fg[cyan]%}%c%{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
|
||||
|
||||
if which rvm-prompt &> /dev/null; then
|
||||
if [ -e ~/.rvm/bin/rvm-prompt ]; then
|
||||
RPROMPT='%{$reset_color%} %{$fg[red]%}$(~/.rvm/bin/rvm-prompt i v g) %{$reset_color%}'
|
||||
else
|
||||
if which rbenv &> /dev/null; then
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue