diff --git a/README.textile b/README.textile index d01c3310a..38216398d 100644 --- a/README.textile +++ b/README.textile @@ -6,13 +6,6 @@ h2. Setup @oh-my-zsh@ should work with any recent release of "zsh":http://www.zsh.org/, the minimum recommended version is 4.3.9. -h3. The automatic installer... (do you trust me?) - -@wget --no-check-certificate https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh@ - -h3. The manual way - - 1. Clone the repository @git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh@ @@ -47,25 +40,16 @@ the "refcard":http://www.bash2zsh.com/zsh_refcard/refcard.pdf is pretty tasty fo h3. Customization -If you want to override any of the default behavior, just add a new file (ending in @.zsh@) into the @custom/@ directory. -If you have many functions which go good together you can put them as a *.plugin.zsh file in the @plugin/@ directory and then enable this plugin. - -h3. Uninstalling - -If you want to uninstall it, just run @uninstall_oh_my_zsh@ from the command line and it'll remove itself and revert you to bash (or your previous zsh config). +If you have many functions which go good together you can put them as a *.plugin.zsh file in the @plugins/@ directory and then enable this plugin. h2. Help out! I'm far from being a zsh-expert and suspect there are many ways to improve. If you have ideas on how to make the configuration easier to maintain (and faster), don't hesitate to fork and send pull requests! -h3. Send us your theme! - -I'm hoping to collect a bunch of themes for our command prompts. You can see existing ones in the @themes/@ directory. - h2. Contributors This project wouldn't exist without all of our awesome users and contributors. * "View our growing list of contributors":https://github.com/robbyrussell/oh-my-zsh/contributors -Thank you so much! \ No newline at end of file +Thank you so much! diff --git a/custom/aliases.zsh b/custom/aliases.zsh deleted file mode 100644 index cd8b0bd26..000000000 --- a/custom/aliases.zsh +++ /dev/null @@ -1,84 +0,0 @@ -# The 'ls' family -# ------------------------------------------------------------------------------ -[[ "$DISABLE_COLOR" != 'true' ]] && { - [[ -x "${commands[gdircolors]}" ]] && use_color_gnu='true' || use_color_bsd='true' -} - -[[ "$use_color_gnu" == 'true' && -e "$HOME/.dir_colors" ]] && eval $(gdircolors $HOME/.dir_colors) -[[ "$use_color_bsd" == 'true' ]] && export CLICOLOR=1 -[[ "$use_color_bsd" == 'true' ]] && export LSCOLORS="exfxcxdxbxegedabagacad" - -# add colors for filetype recognition -[[ "$use_color_gnu" == 'true' ]] && alias ls='ls -hF --group-directories-first --color=auto' -[[ "$use_color_bsd" == 'true' ]] && alias ls='ls -G -F' - -alias la='ls -Ahl' # show hidden files -alias lx='ls -lhXB' # sort by extension -alias lk='ls -lhSr' # sort by size, biggest last -alias lc='ls -lhtcr' # sort by and show change time, most recent last -alias lu='ls -lhtur' # sort by and show access time, most recent last -alias lt='ls -lhtr' # sort by date, most recent last -alias lm='ls -ahl | more' # pipe through 'more' -alias lr='ls -lhR' # recursive ls -alias l='ls -lha' -alias ll='ls -lh' - -# General -# ------------------------------------------------------------------------------ -alias rm='nocorrect rm -i' -alias cp='nocorrect cp -i' -alias mv='nocorrect mv -i' -alias ln='nocorrect ln -i' -alias mkdir='nocorrect mkdir -p' -alias du='du -kh' -alias df='df -kh' -alias e="$EDITOR" -alias get='curl -C - -O' -alias q='exit' -alias ssh='ssh -X' -alias h='history' -alias j='jobs -l' -alias f='fg' -alias gr='grep -r' -alias type='type -a' -alias print-path='echo -e ${PATH//:/\\n}' -alias print-libpath='echo -e ${LD_LIBRARY_PATH//:/\\n}' -alias lsbom='lsbom -f -l -s -pf' -alias t="$HOME/.local/bin/t --task-dir ~/.tasks --list todo.txt --delete-if-empty" - -alias v.='vim .' -alias v='vim ~/.vimrc' -alias VS='vim -S Session.vim' - -alias z='vim -o ~/.zshenv ~/.oh-my-zsh/custom/aliases.zsh ~/.zshrc' -alias zs='source ~/.zshrc' - - -if [[ -x "${commands[htop]}" ]]; then - alias top=htop -else - alias topm='top -o vsize' - alias topc='top -o cpu' -fi - -[[ "$DISABLE_COLOR" != 'true' ]] && { - [[ -x "${commands[colordiff]}" ]] && alias diff='colordiff' - [[ -x "${commands[colormake]}" ]] && alias make='colormake' -} - -# Screen -# ------------------------------------------------------------------------------ -[[ "$TERM" == 'xterm-color' && -e "$HOME/.screenrc" ]] && screenrc="-c '$HOME/.screenrc'" -[[ "$TERM" == 'xterm-256color' && -e "$HOME/.screenrc256" ]] && screenrc="-c '$HOME/.screenrc256'" -alias screen="screen $screenrc" -alias sl="screen $screenrc -list" -alias sr="screen $screenrc -a -A -U -D -R" -alias S="screen $screenrc -U -S" - -# TMUX -# ------------------------------------------------------------------------------ -[[ "$TERM" == 'xterm-color' && -e "$HOME/.tmux.conf" ]] && tmuxconf="-f '$HOME/.tmux.conf'" -[[ "$TERM" == 'xterm-256color' && -e "$HOME/.tmux256.conf" ]] && tmuxconf="-f '$HOME/.tmux256.conf'" -alias tmux="tmux $tmuxconf" -alias tls="tmux list-sessions" - diff --git a/custom/directories.zsh b/custom/directories.zsh deleted file mode 100644 index 1237335b4..000000000 --- a/custom/directories.zsh +++ /dev/null @@ -1 +0,0 @@ -unsetopt auto_pushd \ No newline at end of file diff --git a/custom/functions.zsh b/custom/functions.zsh deleted file mode 100644 index 91d624b57..000000000 --- a/custom/functions.zsh +++ /dev/null @@ -1,47 +0,0 @@ -function cdll() { - if [[ -n "$1" ]]; then - builtin cd "$1" - ls -lFhA - else - ls -lFhA - fi -} - -function pushdll() { - if [[ -n "$1" ]]; then - builtin pushd "$1" - ls -lFhA - else - ls -lFhA - fi -} - -function popdll() { - builtin popd - ls -lFhA -} - -function grab() { - sudo chown -R ${USER} ${1:-.} -} - -function reload() { - source "$HOME/.zshrc" -} - -function calc() { - echo "scale=4; $@" | bc -l -} - -function pmine() { - ps $@ -u $USER -o pid,%cpu,%mem,command -} - -function findexec() { - find . -type f -iname '*'${1:-}'*' -exec ${2:-file} {} \; -} - -function httpserve() { - python -m SimpleHTTPServer -} - diff --git a/custom/grep.zsh b/custom/grep.zsh deleted file mode 100644 index 23d9d55f9..000000000 --- a/custom/grep.zsh +++ /dev/null @@ -1,8 +0,0 @@ -if [[ "$DISABLE_COLOR" != "true" ]]; then - export GREP_OPTIONS='--color=auto' - export GREP_COLOR='37;45' -else - export GREP_OPTIONS='--color=none' - export GREP_COLOR='' -fi - diff --git a/custom/history-substring-search.zsh b/custom/history-substring-search.zsh deleted file mode 100644 index 6c54f0451..000000000 --- a/custom/history-substring-search.zsh +++ /dev/null @@ -1,4 +0,0 @@ -if [[ "$DISABLE_COLOR" == "true" ]]; then - F_ordinary_highlight="bg=none,fg=none" - F_out_of_matches_highlight="bg=none,fg=none" -fi diff --git a/custom/shortcuts.zsh b/custom/shortcuts.zsh deleted file mode 100644 index 28ffcae25..000000000 --- a/custom/shortcuts.zsh +++ /dev/null @@ -1,5 +0,0 @@ -# Add yourself some shortcuts to projects you often work on -# Example: -# -# brainstormr=/Users/robbyrussell/Projects/development/planetargon/brainstormr -# \ No newline at end of file diff --git a/lib/aliases.zsh b/lib/aliases.zsh index 0555be264..1892521d1 100644 --- a/lib/aliases.zsh +++ b/lib/aliases.zsh @@ -1,24 +1,112 @@ -# Push and pop directories on directory stack +# The 'ls' family +# ------------------------------------------------------------------------------ +if [[ "$DISABLE_COLOR" != 'true' ]]; then + if (( ${+commands[dircolors]} )); then + dircolors="${commands[dircolors]}" + fi + if (( ${+commands[gdircolors]} )); then + dircolors="${commands[gdircolors]}" + fi + if [[ -x "$dircolors" ]] && [[ -e "$HOME/.dir_colors" ]]; then + eval $("$dircolors" "$HOME/.dir_colors") + alias ls='ls -hF --group-directories-first --color=auto' + else + export CLICOLOR=1 + export LSCOLORS="exfxcxdxbxegedabagacad" + alias ls='ls -G -F' + fi +fi + +alias ll='ls -lh' # Show human readable. +alias l='ls -lha' # Show hidden files. +alias la='ls -lhA' # Show hidden files. +alias lx='ls -lhXB' # Sort by extension. +alias lk='ls -lhSr' # Sort by size, biggest last. +alias lc='ls -lhtcr' # Sort by and show change time, most recent lasa. +alias lu='ls -lhtur' # Sort by and show access time, most recent last. +alias lt='ls -lhtr' # Sort by date, most recent last. +alias lm='ls -lha | more' # Pipe through 'more'. +alias lr='ls -lhR' # Recursive ls. + +# General +# ------------------------------------------------------------------------------ +alias rm='nocorrect rm -i' +alias cp='nocorrect cp -i' +alias mv='nocorrect mv -i' +alias ln='nocorrect ln -i' +alias mkdir='nocorrect mkdir -p' +alias du='du -kh' +alias df='df -kh' alias pu='pushd' alias po='popd' - -# Basic directory operations -alias ...='cd ../..' -alias -- -='cd -' - -# Super user alias _='sudo' - -#alias g='grep -in' - -# Show history +alias e="$EDITOR" alias history='fc -l 1' +alias get='curl -C - -O' +alias q='exit' +alias ssh='ssh -X' +alias h='history' +alias j='jobs -l' +alias f='fg' +alias gr='grep -r' +alias afind='ack -il' +alias type='type -a' +# alias ssh='ssh -X' +alias print-path='echo -e ${PATH//:/\\n}' +alias t="t --task-dir ~/.tasks --list todo.txt --delete-if-empty" -# List direcory contents -alias lsa='ls -lah' -alias l='ls -la' -alias ll='ls -l' -alias sl=ls # often screw this up +alias z='vim -o ~/.zshenv ~/.oh-my-zsh/lib/aliases.zsh ~/.zshrc' +alias zs='source ~/.zshrc' -alias afind='ack-grep -il' +if [[ "$EDITOR" = vi* ]]; then + alias v.='vim .' + alias v='vim ~/.vimrc' + alias VS='vim -S Session.vim' +fi + +if [[ -x "${commands[htop]}" ]]; then + alias top=htop +else + alias topm='top -o vsize' + alias topc='top -o cpu' +fi + +if [[ "$DISABLE_COLOR" != 'true' ]]; then + if [[ -x "${commands[colordiff]}" ]]; then + alias diff='colordiff' + fi + + if [[ -x "${commands[colormake]}" ]]; then + alias make='colormake' + fi +fi + +# Terminal Multiplexer +# ------------------------------------------------------------------------------ +local screenrc tmuxconf +if [[ "$TERM" == 'xterm-color' ]]; then + if [[ -e "$HOME/.screenrc" ]]; then + screenrc="-c '$HOME/.screenrc'" + fi + if [[ -e "$HOME/.tmux.conf" ]]; then + tmuxconf="-f '$HOME/.tmux.conf'" + fi +fi + +if [[ "$TERM" == 'xterm-256color' ]]; then + if [[ -e "$HOME/.screenrc256" ]]; then + screenrc="-c '$HOME/.screenrc256'" + fi + if [[ -e "$HOME/.tmux256.conf" ]]; then + tmuxconf="-f '$HOME/.tmux256.conf'" + fi +fi + +alias screen="screen $screenrc" +alias sl="screen $screenrc -list" +alias sr="screen $screenrc -a -A -U -D -R" +alias S="screen $screenrc -U -S" + +alias tmux="tmux $tmuxconf" +alias tls="tmux list-sessions" diff --git a/lib/completion.zsh b/lib/completion.zsh index 7c81f77bd..c60faf636 100644 --- a/lib/completion.zsh +++ b/lib/completion.zsh @@ -1,19 +1,21 @@ -# fixme - the load process here seems a bit bizarre -[[ "$TERM" == "dumb" ]] && return +# Dumb terminals lack support. +if [[ "$TERM" == 'dumb' ]]; then + return +fi -unsetopt menu_complete # do not autoselect the first completion entry -unsetopt flowcontrol -setopt auto_menu # show completion menu on succesive tab press -setopt complete_in_word -setopt always_to_end +unsetopt menu_complete # Do not autoselect the first completion entry. +unsetopt flow_control # Disable start/stop characters in shell editor. +setopt auto_menu # Show completion menu on a succesive tab press. +setopt complete_in_word # Complete from both ends of a word. +setopt always_to_end # Move cursor to the end of a completed word. WORDCHARS='' -# fixme - complist is crashing ZSH on menu completion +# FIXME: complist is crashing ZSH on menu completion. # zmodload -i zsh/complist -## case-insensitive (all),partial-word and then substring completion -if [ "x$CASE_SENSITIVE" = "xtrue" ]; then +## Case-insensitive (all), partial-word, and then substring completion. +if [[ "$CASE_SENSITIVE" == "true" ]]; then zstyle ':completion:*' matcher-list 'r:|[._-]=* r:|=*' 'l:|=* r:|=*' unset CASE_SENSITIVE else @@ -22,18 +24,19 @@ fi zstyle ':completion:*' list-colors '' -# should this be in keybindings? +# FIXME: It depends on complist which crashes ZSH on menu completion. +# Should this be in key-bindings.zsh? # bindkey -M menuselect '^o' accept-and-infer-next-history zstyle ':completion:*:*:*:*:*' menu select zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01' zstyle ':completion:*:*:*:*:processes' command "ps -u `whoami` -o pid,user,comm -w -w" -# disable named-directories autocompletion +# Disable named-directories autocompletion. zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-directories cdpath=(.) -# use /etc/hosts and known_hosts for hostname completion +# Use /etc/hosts and known_hosts for hostname completion. [ -r ~/.ssh/known_hosts ] && _ssh_hosts=(${${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[\|]*}%%\ *}%%,*}) || _ssh_hosts=() [ -r /etc/hosts ] && : ${(A)_etc_hosts:=${(s: :)${(ps:\t:)${${(f)~~"$( /dev/null) || return - echo "($ruby_version)" -} - - diff --git a/lib/spectrum.zsh b/lib/spectrum.zsh index 4006a7fe1..3261d9f01 100644 --- a/lib/spectrum.zsh +++ b/lib/spectrum.zsh @@ -1,20 +1,20 @@ -#! /bin/zsh -# A script to make using 256 colors in zsh less painful. +# A script to make using 256 colors in ZSH less painful in your PROMPT. # P.C. Shyamshankar # Copied from http://github.com/sykora/etc/blob/master/zsh/functions/spectrum/ typeset -Ag FX FG BG FX=( - reset "%{%}" - bold "%{%}" no-bold "%{%}" - italic "%{%}" no-italic "%{%}" - underline "%{%}" no-underline "%{%}" - blink "%{%}" no-blink "%{%}" - reverse "%{%}" no-reverse "%{%}" + reset "%{%}" + bold "%{%}" no-bold "%{%}" + italic "%{%}" no-italic "%{%}" + underline "%{%}" no-underline "%{%}" + blink "%{%}" no-blink "%{%}" + reverse "%{%}" no-reverse "%{%}" ) for color in {000..255}; do - FG[$color]="%{[38;5;${color}m%}" - BG[$color]="%{[48;5;${color}m%}" + FG[$color]="%{[38;5;${color}m%}" + BG[$color]="%{[48;5;${color}m%}" done + diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh index 9a5765709..5c1c812d1 100644 --- a/lib/termsupport.zsh +++ b/lib/termsupport.zsh @@ -1,31 +1,40 @@ -[[ "$TERM" == "dumb" ]] && return +# Dumb terminals lack support. +if [[ "$TERM" == 'dumb' ]]; then + return +fi -#usage: title short_tab_title looooooooooooooooooooooggggggg_windows_title -#http://www.faqs.org/docs/Linux-mini/Xterm-Title.html#ss3.1 -#Fully support screen, iterm, and probably most modern xterm and rxvt -#Limited support for Apple Terminal (Terminal can't set window or tab separately) +# Fully supports GNU Screen, iTerm, and most modern xterm and rxvt terminals. +# Partially supports Mac OS X Terminal since it can't set window and tab separately. +# Usage: title "tab title" "window title" function title { - [ "$DISABLE_AUTO_TITLE" != "true" ] || return - 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 - 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) + if [[ "$DISABLE_AUTO_TITLE" != 'true' ]]; then + if [[ "$TERM" == screen* ]]; then + # Set GNU Screen's hardstatus (usually truncated at 20 characters). + print -Pn "\ek$1:q\e\\" + elif [[ "$TERM" == xterm* ]] || [[ "$TERM" == rxvt* ]]; then + # Set the window title. + print -Pn "\e]2;$2:q\a" + # Set the tab title (will override window title on a broken terminal). + print -Pn "\e]1;$1:q\a" + fi fi } -ZSH_THEME_TERM_TAB_TITLE_IDLE="%15<..<%~%<<" #15 char left truncated PWD +# 15 character, left-truncated current working directory. +ZSH_THEME_TERM_TAB_TITLE_IDLE="%15<..<%~%<<" ZSH_THEME_TERM_TITLE_IDLE="%n@%m: %~" -#Appears when you have the prompt +# Set the tab and window titles before the prompt is displayed. function precmd { - title $ZSH_THEME_TERM_TAB_TITLE_IDLE $ZSH_THEME_TERM_TITLE_IDLE + title "$ZSH_THEME_TERM_TAB_TITLE_IDLE" "$ZSH_THEME_TERM_TITLE_IDLE" } -#Appears at the beginning of (and during) of command execution +# Set the tab and window titles before command execution. function preexec { emulate -L zsh setopt extended_glob - local CMD=${1[(wr)^(*=*|sudo|ssh|-*)]} #cmd name only, or if this is sudo or ssh, the next cmd + # Command name only, or if this is sudo or ssh, the next command. + local CMD=${1[(wr)^(*=*|sudo|ssh|-*)]} title "$CMD" "%100>...>$2%<<" } + diff --git a/lib/theme-and-appearance.zsh b/lib/theme-and-appearance.zsh index ab5aba4da..2596013b6 100644 --- a/lib/theme-and-appearance.zsh +++ b/lib/theme-and-appearance.zsh @@ -1,35 +1,23 @@ -# ls colors -autoload colors; colors; -[[ -z "$LSCOLORS" ]] && export LSCOLORS="Gxfxcxdxbxegedabagacad" +# Load and run colors. +autoload -U colors +colors -i -# Enable ls colors -if [ "$DISABLE_COLOR" != "true" ] -then - # Find the option for using colors in ls, depending on the version: Linux or BSD - ls --color -d . &>/dev/null 2>&1 && alias ls='ls --color=tty' || alias ls='ls -G' -fi - -#setopt no_beep -setopt auto_cd -setopt multios -setopt cdablevarS - -if [[ x$WINDOW != x ]] -then - SCREEN_NO="%B$WINDOW%b " +# Set the GNU Screen window number. +if [[ -n "$WINDOW" ]]; then + SCREEN_NO="%B$WINDOW%b " else - SCREEN_NO="" + SCREEN_NO="" fi -# Apply theming defaults +# Set the default prompt theme. PS1="%n@%m:%~%# " -# git theming default: Variables for theming the git info prompt -ZSH_THEME_GIT_PROMPT_PREFIX="git:(" # Prefix at the very beginning of the prompt, before the branch name -ZSH_THEME_GIT_PROMPT_SUFFIX=")" # At the very end of the prompt -ZSH_THEME_GIT_PROMPT_DIRTY="*" # Text to display if the branch is dirty -ZSH_THEME_GIT_PROMPT_CLEAN="" # Text to display if the branch is clean +# Set the default Git prompt theme. +ZSH_THEME_GIT_PROMPT_PREFIX="git:(" # Prefix before the branch name. +ZSH_THEME_GIT_PROMPT_SUFFIX=")" # Suffix after the branch name. +ZSH_THEME_GIT_PROMPT_DIRTY="*" # Indicator to display if the branch is dirty. +ZSH_THEME_GIT_PROMPT_CLEAN="" # Indicator to display if the branch is clean. -# Setup the prompt with pretty colors +# Enable parameter, arithmentic expansion and command substitution in prompt. setopt prompt_subst diff --git a/log/.easter-egg b/log/.easter-egg deleted file mode 100644 index 2533149e2..000000000 --- a/log/.easter-egg +++ /dev/null @@ -1,4 +0,0 @@ -This file is only here so that Git will keep a log directory as .gitignore is ignoring all the log files within it. - -feel free to add love notes for people here. - diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh index 29b1d3bc7..e67c2df69 100644 --- a/oh-my-zsh.sh +++ b/oh-my-zsh.sh @@ -1,58 +1,45 @@ -# Initializes Oh My Zsh +# Initializes OH MY ZSH. -# Disable colors on dumb terminals -if [ "$TERM" = "dumb" ]; then - DISABLE_COLOR="true" +# Disable color in dumb terminals. +if [[ "$TERM" == 'dumb' ]]; then + DISABLE_COLOR='true' fi -# add a function path -fpath=($ZSH/functions $fpath) +# Load all files in $ZSH/oh-my-zsh/lib/ that end in .zsh. +for config_file in $ZSH/lib/*.zsh; do + source "$config_file" +done -# Load all of the config files in ~/oh-my-zsh that end in .zsh -# TIP: Add files you don't want in git to .gitignore -for config_file ($ZSH/lib/*.zsh) source $config_file - -# Add all defined plugins to fpath +# Add all defined plugins to fpath. plugin=${plugin:=()} -for plugin ($plugins) fpath=($ZSH/plugins/$plugin $fpath) +for plugin in $plugins; do + fpath=($ZSH/plugins/$plugin $fpath) +done -# Load and run compinit +# Load and run compinit. autoload -U compinit compinit -i -# Load all of the plugins that were defined in ~/.zshrc -for plugin ($plugins); do - if [ -f $ZSH/plugins/$plugin/$plugin.plugin.zsh ]; then - source $ZSH/plugins/$plugin/$plugin.plugin.zsh +# Load all plugins defined in ~/.zshrc. +for plugin in $plugins; do + if [[ -f "$ZSH/plugins/$plugin/$plugin.plugin.zsh" ]]; then + source "$ZSH/plugins/$plugin/$plugin.plugin.zsh" fi done -# Load the theme -# Check for updates on initial load... -if [ "$ZSH_THEME" = "random" ] -then - themes=($ZSH/themes/*zsh-theme) - N=${#themes[@]} - ((N=RANDOM%N)) - RANDOM_THEME=${themes[$N]} - source "$RANDOM_THEME" - echo "[oh-my-zsh] Random theme '$RANDOM_THEME' loaded..." +# Load the theme. +if [[ "$ZSH_THEME" == "random" ]]; then + themes=($ZSH/themes/*.zsh-theme) + theme_index=${#themes[@]} + (( theme_index=((RANDOM % theme_index) + 1) )) + random_theme="${themes[$theme_index]}" + source "$random_theme" else source "$ZSH/themes/$ZSH_THEME.zsh-theme" fi -# Load all of your custom configurations from custom/ -for config_file ($ZSH/custom/*.zsh) source $config_file - # Compile zcompdump, if modified, to increase startup speed. -if [ "$HOME/.zcompdump" -nt "$HOME/.zcompdump.zwc" -o ! -e "$HOME/.zcompdump.zwc" ]; then +if [[ "$HOME/.zcompdump" -nt "$HOME/.zcompdump.zwc" ]] || [[ ! -e "$HOME/.zcompdump.zwc" ]]; then zcompile "$HOME/.zcompdump" fi -# Check for updates on initial load... -if [ "$DISABLE_AUTO_UPDATE" = "true" ] -then - return -else - /usr/bin/env zsh $ZSH/tools/check_for_upgrade.sh -fi diff --git a/plugins/ant/ant.plugin.zsh b/plugins/ant/ant.plugin.zsh new file mode 100644 index 000000000..23bc7756a --- /dev/null +++ b/plugins/ant/ant.plugin.zsh @@ -0,0 +1,26 @@ +stat -f%m . > /dev/null 2>&1 +if [ "$?" = 0 ]; then + stat_cmd=(stat -f%m) +else + stat_cmd=(stat -L --format=%y) +fi + +_ant_does_target_list_need_generating () { + if [ ! -f .ant_targets ]; then return 0; + else + accurate=$($stat_cmd -f%m .ant_targets) + changed=$($stat_cmd -f%m build.xml) + return $(expr $accurate '>=' $changed) + fi +} + +_ant () { + if [ -f build.xml ]; then + if _ant_does_target_list_need_generating; then + sed -n '/ .ant_targets + fi + compadd `cat .ant_targets` + fi +} + +compdef _ant ant diff --git a/plugins/autojump/autojump.plugin.zsh b/plugins/autojump/autojump.plugin.zsh new file mode 100644 index 000000000..da0a12765 --- /dev/null +++ b/plugins/autojump/autojump.plugin.zsh @@ -0,0 +1,3 @@ +if [ -f `brew --prefix`/etc/autojump ]; then + . `brew --prefix`/etc/autojump +fi diff --git a/plugins/brew/_brew b/plugins/brew/_brew index cee1e25f0..1dcf0a4bf 100644 --- a/plugins/brew/_brew +++ b/plugins/brew/_brew @@ -25,10 +25,12 @@ _1st_arguments=( 'link:link a formula' 'list:list files in a formula or not-installed formulae' 'log:git commit log for a formula' + 'missing:check all installed formuale for missing dependencies.' 'outdated:list formulas for which a newer version is available' 'prune:remove dead links' 'remove:remove a formula' 'search:search for a formula (/regex/ or string)' + 'server:start a local web app that lets you browse formulae (requires Sinatra)' 'unlink:unlink a formula' 'update:freshen up links' 'upgrade:upgrade outdated formulae' @@ -36,10 +38,14 @@ _1st_arguments=( ) local expl -local -a formula installed_formulae +local -a formulae installed_formulae _arguments \ - '(-v --verbose)'{-v,--verbose}'[verbose]' \ + '(-v)-v[verbose]' \ + '(--cellar)--cellar[brew cellar]' \ + '(--config)--config[brew configuration]' \ + '(--env)--env[brew environment]' \ + '(--repository)--repository[brew repository]' \ '(--version)--version[version information]' \ '(--prefix)--prefix[where brew lives on this system]' \ '(--cache)--cache[brew cache]' \ @@ -51,20 +57,24 @@ if (( CURRENT == 1 )); then fi case "$words[1]" in - list) + search|-S) + _arguments \ + '(--macports)--macports[search the macports repository]' \ + '(--fink)--fink[search the fink repository]' ;; + list|ls) _arguments \ '(--unbrewed)--unbrewed[files in brew --prefix not controlled by brew]' \ + '(--versions)--versions[list all installed versions of a formula]' \ '1: :->forms' && return 0 if [[ "$state" == forms ]]; then _brew_installed_formulae - _requested installed_formulae expl 'installed formulae' compadd -a installed_formulae + _wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae fi ;; - install|home|log|info|uses|cat|deps) + install|home|homepage|log|info|abv|uses|cat|deps|edit|options) _brew_all_formulae _wanted formulae expl 'all formulae' compadd -a formulae ;; - remove|edit|xo) + remove|rm|uninstall|unlink|cleanup|link|ln) _brew_installed_formulae _wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae ;; esac - diff --git a/plugins/cap/cap.plugin.zsh b/plugins/cap/cap.plugin.zsh index a0fa21d00..8336182d5 100644 --- a/plugins/cap/cap.plugin.zsh +++ b/plugins/cap/cap.plugin.zsh @@ -18,4 +18,4 @@ function _cap () { fi } -compctl -K _cap cap \ No newline at end of file +compctl -K _cap cap diff --git a/plugins/compleat/compleat.plugin.zsh b/plugins/compleat/compleat.plugin.zsh index 8d16a5687..7fbd2b953 100644 --- a/plugins/compleat/compleat.plugin.zsh +++ b/plugins/compleat/compleat.plugin.zsh @@ -5,10 +5,9 @@ # VERSION: 1.0.0 # ------------------------------------------------------------------------------ - if (( ${+commands[compleat]} )); then local prefix="${commands[compleat]:h:h}" - local setup="${prefix}/share/compleat-1.0/compleat_setup" + local setup="${prefix}/share/compleat-1.0/compleat_setup" if [[ -f "$setup" ]]; then if ! bashcompinit >/dev/null 2>&1; then @@ -16,7 +15,6 @@ if (( ${+commands[compleat]} )); then bashcompinit -i fi - source "$setup" + source "$setup" fi fi - diff --git a/plugins/dirpersist/dirpersist.plugin.zsh b/plugins/dirpersist/dirpersist.plugin.zsh index 6a2b289a2..baf21b1da 100644 --- a/plugins/dirpersist/dirpersist.plugin.zsh +++ b/plugins/dirpersist/dirpersist.plugin.zsh @@ -1,9 +1,9 @@ #!/bin/zsh -# +# # Make the dirstack more persistant -# +# # Add dirpersist to $plugins in ~/.zshrc to load -# +# # $zdirstore is the file used to persist the stack zdirstore=~/.zdirstore diff --git a/plugins/extract/extract.plugin.zsh b/plugins/extract/extract.plugin.zsh index d2b28ad1a..aa55234ad 100644 --- a/plugins/extract/extract.plugin.zsh +++ b/plugins/extract/extract.plugin.zsh @@ -23,7 +23,7 @@ function extract() { remove_archive=1 if [[ "$1" == "-r" ]] || [[ "$1" == "--remove" ]]; then - remove_archive=0 + remove_archive=0 shift fi @@ -64,10 +64,10 @@ function extract() { cd ..; rm *.tar.gz debian-binary cd .. ;; - (*) + (*) echo "extract: '$1' cannot be extracted" 1>&2 - success=1 - ;; + success=1 + ;; esac (( success = $success > 0 ? $success : $? )) diff --git a/plugins/git-flow/git-flow.plugin.zsh b/plugins/git-flow/git-flow.plugin.zsh index 270bcbe38..a889473e8 100644 --- a/plugins/git-flow/git-flow.plugin.zsh +++ b/plugins/git-flow/git-flow.plugin.zsh @@ -329,4 +329,4 @@ __git_command_successful () { return 0 } -zstyle ':completion:*:*:git:*' user-commands flow:'description for foo' \ No newline at end of file +zstyle ':completion:*:*:git:*' user-commands flow:'description for foo' diff --git a/plugins/git/_git b/plugins/git/_git index ac9fd1c70..e062705ee 100644 --- a/plugins/git/_git +++ b/plugins/git/_git @@ -131,7 +131,7 @@ _git-archive () { '--format=-[format of the resulting archive]:archive format:__git_archive_formats' \ '(- :)'{-l,--list}'[list available archive formats]' \ '(-v --verbose)'{-v,--verbose}'[report progress to stderr]' \ - '--prefix=-[prepend the given path prefix to to each filename]:path prefix:_directories -r ""' \ + '--prefix=-[prepend the given path prefix to each filename]:path prefix:_directories -r ""' \ '--output=[write archive to argument instead of stdout]:archive:_files' \ '--worktree-attributes[look for attributes in .gitattributes in working directory too]' \ $backend_args \ @@ -258,16 +258,22 @@ _git-branch () { d='-d -D' declare -a dependent_creation_args - dependent_creation_args=( - "($l $m $d): :__git_branch_names" - "::start-point:__git_revisions") + if (( words[(I)-r] == 0 )); then + dependent_creation_args=( + "($l $m $d): :__git_branch_names" + "::start-point:__git_revisions") + fi declare -a dependent_deletion_args if (( words[(I)-d] || words[(I)-D] )); then dependent_creation_args= dependent_deletion_args=( - '-r[delete remote-tracking branches]' - '*: :__git_ignore_line_inside_arguments __git_branch_names') + '-r[delete only remote-tracking branches]') + if (( words[(I)-r] )); then + dependent_deletion_args+='*: :__git_ignore_line_inside_arguments __git_remote_branch_names' + else + dependent_deletion_args+='*: :__git_ignore_line_inside_arguments __git_branch_names' + fi fi declare -a dependent_modification_args @@ -281,7 +287,7 @@ _git-branch () { _arguments -w -S -s \ "($c $m $d --no-color :)--color=-[turn on branch coloring]:: :__git_color_whens" \ "($c $m $d : --color)--no-color[turn off branch coloring]" \ - "($c $m $d : -a)-r[list only the remote-tracking branches]" \ + "($c $m -a)-r[list or delete only remote-tracking branches]" \ "($c $m $d : -r)-a[list both remote-tracking branches and local branches]" \ "($c $m $d : -v --verbose)"{-v,--verbose}'[show SHA1 and commit subject line for each head]' \ "($c $m $d :)--abbrev=[set minimum SHA1 display-length]: :__git_guard_number length" \ @@ -2941,7 +2947,7 @@ _git-rev-parse () { else # TODO: Parse option specification? _arguments -w -S -s \ - '(- *)'{-h,--help}'[display usage]' + '(- *)'{-h,--help}'[display usage]' \ '--keep-dashdash[do not skip first -- option]' \ '--stop-at-non-option[stop parsing options at first non-option argument]' \ '*:option specification' && ret=0 @@ -3958,7 +3964,7 @@ _git-name-rev () { '--refs=[only use refs matching given pattern]: :_guard "?#" "shell pattern"' \ '(--stdin :)--all[list all commits reachable from all refs]' \ '(--all :)--stdin[read from stdin and append revision-name]' \ - '--name-only[display only name of commits]' + '--name-only[display only name of commits]' \ '--no-undefined[die with non-zero return when a reference is undefined]' \ '--always[show uniquely abbreviated commit object as fallback]' \ '(--stdin --all)*: :__git_commits' && ret=0 @@ -4919,7 +4925,7 @@ __git_remote_branch_names () { local expl declare -a branch_names - branch_names=(${${(f)"$(_call_program remote-branch-refs git for-each-ref --format='%(refname)' refs/remotes 2>/dev/null)"}#refs/remotes/}) + branch_names=(${${(f)"$(_call_program remote-branch-refs git for-each-ref --format='"%(refname)"' refs/remotes 2>/dev/null)"}#refs/remotes/}) __git_command_successful $pipestatus || return _wanted remote-branch-names expl 'remote branch name' compadd $* - $branch_names @@ -5162,7 +5168,7 @@ __git_files_relative () { files=() - # Collapse "//" and "/./" into "/". Strip any remaining "/." and "/". + # Collapse “//” and “/./” into “/”. Strip any remaining “/.” and “/”. for file in ${${${${${(0)1}//\/\///}//\/.\///}%/.}%/}; do integer i n (( n = $#file > $#prefix ? $#file : $#prefix )) @@ -5413,6 +5419,10 @@ __git_guard_diff-stat-width () { (( $+functions[__git_guard_number] )) || __git_guard_number () { + declare -A opts + + zparseopts -K -D -A opts M: J: V: 1 2 n F: X: + _guard "[[:digit:]]#" ${1:-number} } diff --git a/plugins/git/git-aliases.plugin.zsh b/plugins/git/git-aliases.plugin.zsh index 859b637c6..a8f85c4d7 100644 --- a/plugins/git/git-aliases.plugin.zsh +++ b/plugins/git/git-aliases.plugin.zsh @@ -1,5 +1,5 @@ # Aliases -alias g='git' ; compdef g=git +# alias g='git' ; compdef g=git alias ga='git add' ; compdef _git ga=git-add alias gaa='git add --all' ; compdef _git gaa=git-add alias gs='git status' ; compdef _git gs=git-status @@ -25,6 +25,7 @@ alias gcount='git shortlog -sn' ; compdef gcount=git alias gcp='git cherry-pick' ; compdef _git gcp=git-cherry-pick alias gm='git merge' ; compdef _git gm=git-merge alias glg='git log --stat --max-count=5'; compdef _git glg=git-log +alias gls='git shortlog' ; compdef _git gls=shortlog # Git history (pretty) local pretty_format_oneline='--pretty=format:"%C(yellow)%h %C(green)%cd %C(cyan)%an %C(bold cyan)%d%C(reset) %s" --date=short' diff --git a/plugins/git/git-prompt-old.plugin.zsh b/plugins/git/git-prompt-old.plugin.zsh deleted file mode 100644 index ece86e6d3..000000000 --- a/plugins/git/git-prompt-old.plugin.zsh +++ /dev/null @@ -1,79 +0,0 @@ -# Renders the name of the current branch. -function git_prompt_info() { - local branch=$(git_current_branch) - if [[ -n "$branch" ]]; then - echo "${ZSH_THEME_GIT_PROMPT_PREFIX}${branch}$(parse_git_dirty)${ZSH_THEME_GIT_PROMPT_SUFFIX}" - fi -} - -# Gets the current branch. -function git_current_branch() { - local ref=$(git symbolic-ref HEAD 2> /dev/null) - if [[ -n "$ref" ]]; then - echo "${ref#refs/heads/}" - fi -} - -# Checks if the working tree is dirty. -function parse_git_dirty() { - if [[ -n $(git status -s 2> /dev/null) ]]; then - echo "$ZSH_THEME_GIT_PROMPT_DIRTY" - else - echo "$ZSH_THEME_GIT_PROMPT_CLEAN" - fi -} - -# Checks if there are commits ahead from remote. -function git_prompt_ahead() { - if $(echo "$(git log origin/$(git_current_branch)..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then - echo "$ZSH_THEME_GIT_PROMPT_AHEAD" - fi -} - -# Formats the prompt string for current git commit short SHA. -function git_prompt_short_sha() { - local sha=$(git rev-parse --short HEAD 2> /dev/null) - if [[ -n "$sha" ]]; then - echo "${ZSH_THEME_GIT_PROMPT_SHA_BEFORE}${sha}${ZSH_THEME_GIT_PROMPT_SHA_AFTER}" - fi -} - -# Formats the prompt string for current git commit long SHA. -function git_prompt_long_sha() { - local sha=$(git rev-parse HEAD 2> /dev/null) - if [[ -n "$sha" ]]; then - echo "${ZSH_THEME_GIT_PROMPT_SHA_BEFORE}${sha}${ZSH_THEME_GIT_PROMPT_SHA_AFTER}" - fi -} - -# Gets the status of the working tree. -function git_prompt_status() { - local indicators line untracked added modified renamed deleted - while IFS=$'\n' read line; do - if [[ "$line" =~ '^\?\? ' ]]; then - [[ -n $untracked ]] && continue || untracked='yes' - indicators="${ZSH_THEME_GIT_PROMPT_UNTRACKED}${indicators}" - fi - if [[ "$line" =~ '^(((A|M|D|T) )|(AD|AM|AT|MM)) ' ]]; then - [[ -n $added ]] && continue || added='yes' - indicators="${ZSH_THEME_GIT_PROMPT_ADDED}${indicators}" - fi - if [[ "$line" =~ '^(( (M|T))|(AM|AT|MM)) ' ]]; then - [[ -n $modified ]] && continue || modified='yes' - indicators="${ZSH_THEME_GIT_PROMPT_MODIFIED}${indicators}" - fi - if [[ "$line" =~ '^R ' ]]; then - [[ -n $renamed ]] && continue || renamed='yes' - indicators="${ZSH_THEME_GIT_PROMPT_RENAMED}${indicators}" - fi - if [[ "$line" =~ '^( D|AD) ' ]]; then - [[ -n $deleted ]] && continue || deleted='yes' - indicators="${ZSH_THEME_GIT_PROMPT_DELETED}${indicators}" - fi - if [[ "$line" =~ '^UU ' ]]; then - [[ -n $unmerged ]] && continue || unmerged='yes' - indicators="${ZSH_THEME_GIT_PROMPT_UNMERGED}${indicators}" - fi - done < <(git status --porcelain 2> /dev/null) - echo $indicators -} diff --git a/plugins/git/git-prompt.plugin.zsh b/plugins/git/git-prompt.plugin.zsh index bafe903e0..6984397d8 100644 --- a/plugins/git/git-prompt.plugin.zsh +++ b/plugins/git/git-prompt.plugin.zsh @@ -2,8 +2,9 @@ # FILE: git-prompt.plugin.zsh # DESCRIPTION: oh-my-zsh git information for your PROMPT. # AUTHOR: Ashley Dev (the.ashley.dev+git-prompt@gmail.com) -# VERSION: 2.1 -# SCREENSHOT: +# VERSION: 3.0 +# SCREENSHOT: http://i.imgur.com/Yw1KG.png +# http://i.imgur.com/wx6MU.png # ------------------------------------------------------------------------------ # USAGE: @@ -11,547 +12,466 @@ # Add 'git' to your list of oh-my-zsh plugins (in your .zshrc) otherwise this # git prompt info will not show up in your prompt. # -# This example shows some of the things you can do with this plugin. This is -# how the author uses it: +# This simple example shows some of the things you can do with this plugin. +# (See the ashleydev theme for more complex usage.) # ---------------------- SAMPLE THEME FILE ------------------------ # -# # this is a simple example PROMPT with only git -# # info from this plugin in it: -# PROMPT='$__GIT_PROMPT_INFO# ' +# # this is a simple example PROMPT with only git +# # info from this plugin in it: +# PROMPT='$GIT_PROMPT_INFO# ' # -# # Set GIT_PROMPT_SHORTCIRCUIT='off' to turn the -# # short-circuit logic off. The short-circuit -# # logic will turn off the showing of dirty -# # state in your git prompt if ctrl-c is pressed -# # while the prompt is updating the dirty state -# # info. Gathering dirty-state info can take a -# # long time on large repositories, so if you -# # find that your prompt is taking for ever to -# # return, and you press ctrl-c, the short- -# # circuit logic will turn off the showing of -# # dirty state for this repository (locally) and -# # let you know, that way you won't be slowed -# # down waiting for your prompt in large git -# # repositories. -# #GIT_PROMPT_SHORTCIRCUIT='off' -# -# GIT_PROMPT_SHOWUPSTREAM="verbose" -# #GIT_PROMPT_SHOWREBASEINFO='off' -# #GIT_PROMPT_SHOWBRANCH='off' -# #GIT_PROMPT_SHOWSTASHSTATE='off' -# #GIT_PROMPT_SHORTCIRCUIT='off' -# #GIT_PROMPT_SHOWDIRTYSTATE='off' -# -# # Some color settings for my prompt format -# # '_C' for color: -# if [[ "$DISABLE_COLOR" != "true" ]]; then -# local _Cerror_="%{$fg[yellow]%}" # bad (empty) .git/ directory -# local _Cb_new_repo_="%{$fg_bold[default]%}" # branch color of new repo -# local _Cb_clean_="%{$fg_no_bold[green]%}" # branch color when clean -# local _Cb_dirty_="%{$fg_no_bold[red]%}" # branch color when dirty -# local _Cr_="%{$bold_color$fg[yellow]%}" # rebase info -# local _Ci_="%{$bold_color$fg[red]%}" # index info -# local _Cu_clean_="" # untracked files state when clean -# local _Cu_dirty_="%{$fg_bold[red]%}" # untracked files state when dirty -# local _Cp_="%{${fg[cyan]}%}" # upstream info -# local _Cs_="" # stash state -# # 'R'eset formating -# local R="%{$terminfo[sgr0]%}" +# # ... +# # If you want to override the default format you can define your own +# # git_prompt_info() function that sets $GIT_PROMPT_INFO (or other variables) +# # with your format: +# git_prompt_info () +# { +# if [ -z "$(git_prompt__git_dir)" ]; then +# GIT_PROMPT_INFO='' +# return # fi # -# # GIT_PROMPT_INFO_FUNC must be set to the -# # function that defines your prompt info -# # in order to turn this plugin on. -# # $GIT_PROMPT_INFO_FUNC to be called when the -# # git prompt info variable needs to be updated. -# GIT_PROMPT_INFO_FUNC='update__GIT_PROMPT_INFO' +# git_prompt__branch +# local branch_=$GIT_PROMPT_BRANCH +# +# git_prompt__dirty_state +# local work_=$GIT_PROMPT_DIRTY_STATE_WORKTREE_DIRTY +# local index_=$GIT_PROMPT_DIRTY_STATE_INDEX_DIRTY +# +# # Reset color +# local R="%{$terminfo[sgr0]%}" # -# # update__GIT_PROMPT_INFO creates the format and -# # content of the git prompt info and puts the -# # result in $__GIT_PROMPT_INFO. Which you can -# # use in your $PROMPT (see above). This is an -# # example of some of the ways you can set up -# # your prompt with this plugin. -# # -# # NOTE: This function must set a global variable -# # (with the your git prompt format) that you -# # include in your PROMPT string. -# # It cannot echo this info as in: -# # PROMPT="$(update__GIT_PROMPT_INFO)" -# # or the short-circuit logic will not work. -# # -# local __GIT_PROMPT_INFO='' -# update__GIT_PROMPT_INFO () -# { -# local g="$(_git_promt__git_dir)" -# # short circuit if we're not in a git repo: -# if [ -z "$g" ]; then -# __GIT_PROMPT_INFO='' -# return -# fi -# -# _git_prompt__stash -# local s=$GIT_PROMPT_STASH_STATE_DIRTY -# -# _git_prompt__upstream -# local p=$GIT_PROMPT_UPSTREAM_STATE -# -# _git_prompt__branch -# local b=$GIT_PROMPT_BRANCH -# -# _git_prompt__rebase_info -# local r=$GIT_PROMPT_REBASE_INFO -# -# _git_prompt__dirty_state -# local w=$GIT_PROMPT_DIRTY_STATE_WORKTREE_DIRTY -# local i=$GIT_PROMPT_DIRTY_STATE_INDEX_DIRTY -# local u=$GIT_PROMPT_DIRTY_STATE_WORKTREE_UNTRACKED -# local f=$GIT_PROMPT_DIRTY_STATE_FRESH_REPO -# -# if [ -z "$b$i$w$u" ]; then -# if [ -n "$g" ]; then -# __GIT_PROMPT_INFO="$R$_Cerror_(Error: bad ./$g dir)$R" -# return -# fi -# fi -# -# if [ "$s" = 'yes' ]; then -# s="$_Cs_\$$R" -# else -# s="" -# fi -# -# if [ -n "$p" ]; then -# p="$_Cp_$p$R" -# fi -# -# if [ "$i" = "yes" ]; then -# i="$_Ci_+$R" -# else -# i="" -# fi -# -# if [ -n "$b" ]; then -# if [ "$f" = "yes" ]; then -# # this is a fresh repo, nothing here... -# b="$_Cb_new_repo_$b$R" -# elif [ "$w" = 'yes' ]; then -# b="$_Cb_dirty_$b$R" -# elif [ "$w" = 'no' ]; then -# b="$_Cb_clean_$b$R" -# fi -# fi -# -# if [ -n "$r" ]; then -# r="$_Cr_$r$R" -# fi -# -# local _prompt="$b$r$i$s$p" -# # add ( ) around _prompt: -# if [ "$u" = "yes" ]; then -# _prompt="$_Cu_dirty_($_prompt$_Cu_dirty_)" -# elif [ "$u" = "no" ]; then -# _prompt="$_Cu_clean_($_prompt$_Cu_clean_)" -# else -# fi -# -# __GIT_PROMPT_INFO="$R$_prompt$R" -# } +# if [[ "$index_" = "yes" ]]; then +# index_="%{$bold_color$fg[red]%}+$R" +# else +# index_="" +# fi +# +# if [[ -n "$branch_" ]]; then +# if [[ "$work_" = 'yes' ]]; then +# branch_="%{$fg_no_bold[red]%}$branch_$R" +# elif [[ "$work_" = 'no' ]]; then +# branch_="%{$fg_no_bold[green]%}$branch_$R" +# fi +# fi +# +# GIT_PROMPT_INFO="$R($branch_$index_)$R" +# } # ----------------------------------------------------------------- # # +#------------------ Default Prompt Format ------------------ +# You can override this by defining your own git_prompt_info in your theme that +# sets some global variable(s); i.e. $GIT_PROMPT_INFO. +# (See the ashleydev theme for more complex usage). +git_prompt_info () +{ + if [ -z "$(git_prompt__git_dir)" ]; then + GIT_PROMPT_INFO='' + return + fi + + git_prompt__branch + local branch=$GIT_PROMPT_BRANCH + + git_prompt__dirty_state + local dirty=$GIT_PROMPT_DIRTY_STATE_ANY_DIRTY + + local prompt=$branch + + if [[ "$dirty" = 'yes' ]]; then + prompt="$prompt$ZSH_THEME_GIT_PROMPT_DIRTY" + elif [[ "$dirty" = 'no' ]]; then + prompt="$prompt$ZSH_THEME_GIT_PROMPT_CLEAN" + fi + + GIT_PROMPT_INFO="$ZSH_THEME_GIT_PROMPT_PREFIX$prompt$ZSH_THEME_GIT_PROMPT_SUFFIX" +} + #------------------ git information utils ------------------ # For some of the following functions, I borrowed some from: # https://github.com/git/git/blob/master/contrib/completion/git-completion.bash # -# _git_promt__git_dir accepts 0 or 1 arguments (i.e., location) +# sets a bunch of variables, see below: +git_prompt__dirty_state () +{ + GIT_PROMPT_DIRTY_STATE_ANY_DIRTY='' + GIT_PROMPT_DIRTY_STATE_FRESH_REPO='' + GIT_PROMPT_DIRTY_STATE_INDEX_ADDED='' + GIT_PROMPT_DIRTY_STATE_INDEX_COPIED='' + GIT_PROMPT_DIRTY_STATE_INDEX_DELETED='' + GIT_PROMPT_DIRTY_STATE_INDEX_DIRTY='' + GIT_PROMPT_DIRTY_STATE_INDEX_MODIFIED='' + GIT_PROMPT_DIRTY_STATE_INDEX_RENAMED='' + GIT_PROMPT_DIRTY_STATE_INDEX_UNMERGED='' + GIT_PROMPT_DIRTY_STATE_WORKTREE_DELETED='' + GIT_PROMPT_DIRTY_STATE_WORKTREE_DIRTY='' + GIT_PROMPT_DIRTY_STATE_WORKTREE_MODIFIED='' + GIT_PROMPT_DIRTY_STATE_WORKTREE_UNTRACKED='' + + if [[ "true" != "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]]; then + return + fi + + local dir_="$(git_prompt__git_dir)" + if [[ -z "$dir_" ]]; then + return + fi + if [[ "$GIT_PROMPT_SHOWDIRTYSTATE" = 'off' ]]; then + return + fi + if [[ "$(git config --bool prompt.showDirtyState)" = "false" ]]; then + return + fi + + GIT_PROMPT_DIRTY_STATE_ANY_DIRTY='no' + GIT_PROMPT_DIRTY_STATE_FRESH_REPO='no' + GIT_PROMPT_DIRTY_STATE_INDEX_ADDED='no' + GIT_PROMPT_DIRTY_STATE_INDEX_COPIED='no' + GIT_PROMPT_DIRTY_STATE_INDEX_DELETED='no' + GIT_PROMPT_DIRTY_STATE_INDEX_DIRTY='no' + GIT_PROMPT_DIRTY_STATE_INDEX_MODIFIED='no' + GIT_PROMPT_DIRTY_STATE_INDEX_RENAMED='no' + GIT_PROMPT_DIRTY_STATE_INDEX_UNMERGED='no' + GIT_PROMPT_DIRTY_STATE_WORKTREE_DELETED='no' + GIT_PROMPT_DIRTY_STATE_WORKTREE_DIRTY='no' + GIT_PROMPT_DIRTY_STATE_WORKTREE_MODIFIED='no' + GIT_PROMPT_DIRTY_STATE_WORKTREE_UNTRACKED='no' + + if git rev-parse --quiet --verify HEAD >/dev/null; then + else + GIT_PROMPT_DIRTY_STATE_FRESH_REPO='yes' + fi + + _big_repo='yes' + local line + while IFS=$'\n' read line; do + if [[ "$line" = M* ]]; then + GIT_PROMPT_DIRTY_STATE_INDEX_MODIFIED='yes' + GIT_PROMPT_DIRTY_STATE_INDEX_DIRTY='yes' + GIT_PROMPT_DIRTY_STATE_ANY_DIRTY='yes' + fi + if [[ "$line" = A* ]]; then + GIT_PROMPT_DIRTY_STATE_INDEX_ADDED='yes' + GIT_PROMPT_DIRTY_STATE_INDEX_DIRTY='yes' + GIT_PROMPT_DIRTY_STATE_ANY_DIRTY='yes' + fi + if [[ "$line" = R* ]]; then + GIT_PROMPT_DIRTY_STATE_INDEX_RENAMED='yes' + GIT_PROMPT_DIRTY_STATE_INDEX_DIRTY='yes' + GIT_PROMPT_DIRTY_STATE_ANY_DIRTY='yes' + fi + if [[ "$line" = C* ]]; then + GIT_PROMPT_DIRTY_STATE_INDEX_COPIED='yes' + GIT_PROMPT_DIRTY_STATE_INDEX_DIRTY='yes' + GIT_PROMPT_DIRTY_STATE_ANY_DIRTY='yes' + fi + if [[ "$line" = D* ]]; then + GIT_PROMPT_DIRTY_STATE_INDEX_DELETED='yes' + GIT_PROMPT_DIRTY_STATE_INDEX_DIRTY='yes' + GIT_PROMPT_DIRTY_STATE_ANY_DIRTY='yes' + fi + + if [[ "$line" = \?\?* ]]; then + GIT_PROMPT_DIRTY_STATE_WORKTREE_UNTRACKED='yes' + GIT_PROMPT_DIRTY_STATE_ANY_DIRTY='yes' + fi + if [[ "$line" = ?M* ]]; then + GIT_PROMPT_DIRTY_STATE_WORKTREE_MODIFIED='yes' + GIT_PROMPT_DIRTY_STATE_WORKTREE_DIRTY='yes' + GIT_PROMPT_DIRTY_STATE_ANY_DIRTY='yes' + fi + if [[ "$line" = ?D* ]]; then + GIT_PROMPT_DIRTY_STATE_WORKTREE_DELETED='yes' + GIT_PROMPT_DIRTY_STATE_WORKTREE_DIRTY='yes' + GIT_PROMPT_DIRTY_STATE_ANY_DIRTY='yes' + fi + + if [[ "$line" = UU* ]]; then + GIT_PROMPT_DIRTY_STATE_INDEX_UNMERGED='yes' + GIT_PROMPT_DIRTY_STATE_INDEX_DIRTY='yes' + GIT_PROMPT_DIRTY_STATE_ANY_DIRTY='yes' + fi + done < <(git status --porcelain 2> /dev/null) + _big_repo='' +} + +# git_prompt__git_dir accepts 0 or 1 arguments (i.e., location) # echos the location of .git repo. # Useful for quickly figuring out if cwd is under a git repo. -_git_promt__git_dir () +git_prompt__git_dir () { - if [ -z "${1-}" ]; then - if [ -d .git ]; then - echo .git - else - git rev-parse --git-dir 2>/dev/null - fi - elif [ -d "$1/.git" ]; then - echo "$1/.git" + if [[ -z "${1-}" ]]; then + if [[ -d .git ]]; then + echo .git else - echo "$1" + git rev-parse --git-dir 2>/dev/null fi + elif [[ -d "$1/.git" ]]; then + echo "$1/.git" + else + echo "$1" + fi } # sets GIT_PROMPT_UPSTREAM_STATE # # output format: -# A "<" indicates you are behind, ">" indicates you are ahead, "<>" -# indicates you have diverged, "=" indicates no divergence, and "" indicates -# there is no upstream or this feature is turned 'off' (see below). +# A "-1" indicates you are behind by one commit, "+3" indicates you are ahead by +# 3 commits, "-1+3" indicates you have diverged, "=" indicates no divergence, +# and "" indicates there is no upstream or this feature is turned 'off' (see +# below). # # You can control behaviour by setting GIT_PROMPT_SHOWUPSTREAM to a # space-separated list of values: # off no output -# verbose show number of commits ahead/behind (+/-) upstream instead -# of using "<" and ">". +# simple Instead of '+/-', a "<" indicates you are behind, ">" +# indicates you are ahead, "<>" indicates you have diverged, +# "=" indicates no divergence. # legacy don't use the '--count' option available in recent # versions of git-rev-list # git always compare HEAD to @{upstream} # svn always compare HEAD to your SVN upstream -# By default, _git_prompt__upstream will compare HEAD to your SVN upstream +# By default, git_prompt__upstream will compare HEAD to your SVN upstream # if it can find one, or @{upstream} otherwise. Once you have # set GIT_PROMPT_SHOWUPSTREAM, you can override it on a # per-repository basis by setting the prompt.showUpstream config -# variable (i.e. `git config prompt.showUpstream 'verbose legacy'`). +# variable (i.e. `git config prompt.showUpstream 'simple legacy'`). # -# _git_prompt__upstream accepts 0 or 1 arguments. If an argument is given, it +# git_prompt__upstream accepts 0 or 1 arguments. If an argument is given, it # must be a string of the form specified above for GIT_PROMPT_SHOWUPSTREAM. # Setting this argument will override any value set for GIT_PROMPT_SHOWUPSTREAM # or in the .git/config. -_git_prompt__upstream () +git_prompt__upstream () { - GIT_PROMPT_UPSTREAM_STATE='' + GIT_PROMPT_UPSTREAM_STATE='' - if [ "true" != "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then - return - fi + if [[ "true" != "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]]; then + return + fi - local key value - local svn_remote svn_url_pattern count n - local upstream=git legacy="" verbose="" - local p + local key value + local svn_remote svn_url_pattern count n + local upstream=git legacy="" simple="" + local p - # get some config options from git-config - while read key value; do - case "$key" in - prompt.showupstream*) - GIT_PROMPT_SHOWUPSTREAM="$value" - ;; - svn-remote.*.url) - svn_remote=( "${svn_remote[@]}" $value ) - svn_url_pattern="$svn_url_pattern\\|$value" - upstream=svn+git # default upstream is SVN if available, else git - ;; - esac - done < <(git config --get-regexp '^(svn-remote\..*\.url|prompt\.showupstream)' 2>/dev/null) - - if [ -n "${1-}" ]; then - GIT_PROMPT_SHOWUPSTREAM=$1 - fi - - # parse configuration values - for option in ${GIT_PROMPT_SHOWUPSTREAM}; do - case "$option" in - off) return ;; - git|svn) upstream="$option" ;; - verbose) verbose=1 ;; - legacy) legacy=1 ;; - esac - done - - # Find our upstream - case "$upstream" in - git) upstream="@{upstream}" ;; - svn*) - # get the upstream from the "git-svn-id: ..." in a commit message - # (git-svn uses essentially the same procedure internally) - local svn_upstream=$(git log --first-parent -1 --grep="^git-svn-id: \(${svn_url_pattern#??}\)" 2>/dev/null | awk '/commit / { print $2 }') - if [[ 0 -ne ${#svn_upstream[@]} ]]; then - if [[ -z "$svn_upstream" ]]; then - # default branch name for checkouts with no layout: - upstream='git-svn' - else - upstream=${svn_upstream#/} - fi - elif [[ "svn+git" = "$upstream" ]]; then - upstream="@{upstream}" - fi - ;; + # get some config options from git-config + while read key value; do + case "$key" in + prompt.showupstream*) + GIT_PROMPT_SHOWUPSTREAM="$value" + ;; + svn-remote.*.url) + svn_remote=( "${svn_remote[@]}" $value ) + svn_url_pattern="$svn_url_pattern\\|$value" + upstream=svn+git # default upstream is SVN if available, else git + ;; esac + done < <(git config --get-regexp '^(svn-remote\..*\.url|prompt\.showupstream)' 2>/dev/null) - # Find how many commits we are ahead/behind our upstream - # produce equivalent output to --count for older versions of git - local ahead behind - if git rev-list --left-right "$upstream"...HEAD >/dev/null 2>&1; then - behind="$(git rev-list --left-right "$upstream"...HEAD 2>/dev/null | grep '^<' | wc -l | tr -d ' ' 2>/dev/null)" - ahead="$(git rev-list --left-right "$upstream"...HEAD 2>/dev/null | grep '^[^<]' | wc -l | tr -d ' ' 2>/dev/null)" - count="$behind $ahead" + if [[ -n "${1-}" ]]; then + GIT_PROMPT_SHOWUPSTREAM=$1 + fi + + # parse configuration values + for option in ${GIT_PROMPT_SHOWUPSTREAM}; do + case "$option" in + off) return ;; + git|svn) upstream="$option" ;; + simple) simple=1 ;; + legacy) legacy=1 ;; + esac + done + + # Find our upstream + case "$upstream" in + git) upstream="@{upstream}" ;; + svn*) + # get the upstream from the "git-svn-id: ..." in a commit message + # (git-svn uses essentially the same procedure internally) + local svn_upstream=$(git log --first-parent -1 --grep="^git-svn-id: \(${svn_url_pattern#??}\)" 2>/dev/null | awk '/commit / { print $2 }') + if [[ 0 -ne ${#svn_upstream[@]} ]]; then + if [[ -z "$svn_upstream" ]]; then + # default branch name for checkouts with no layout: + upstream='git-svn' + else + upstream=${svn_upstream#/} + fi + elif [[ "svn+git" = "$upstream" ]]; then + upstream="@{upstream}" fi + ;; + esac - # calculate the result - if [[ -z "$verbose" ]]; then - case "$count" in - "") # no upstream - p="" ;; - "0 0") # equal to upstream - p="=" ;; - "0 "*) # ahead of upstream - p=">" ;; - *" 0") # behind upstream - p="<" ;; - *) # diverged from upstream - p="<>" ;; - esac - else - case "$count" in - "") # no upstream - p="" ;; - "0 0") # equal to upstream - p="=" ;; - "0 "*) # ahead of upstream - p="+${count#0 }" ;; - *" 0") # behind upstream - p="-${count% 0}" ;; - *) # diverged from upstream - p="-${count% *}+${count#* }" ;; - esac - fi + # Find how many commits we are ahead/behind our upstream + # produce equivalent output to --count for older versions of git + local ahead behind + if git rev-list --left-right "$upstream"...HEAD >/dev/null 2>&1; then + behind="$(git rev-list --left-right "$upstream"...HEAD 2>/dev/null | grep '^<' | wc -l | tr -d ' ' 2>/dev/null)" + ahead="$(git rev-list --left-right "$upstream"...HEAD 2>/dev/null | grep '^[^<]' | wc -l | tr -d ' ' 2>/dev/null)" + count="$behind $ahead" + fi - GIT_PROMPT_UPSTREAM_STATE=$p + # calculate the result + if [[ -n "$simple" ]]; then + case "$count" in + "") # no upstream + p="" ;; + "0 0") # equal to upstream + p="=" ;; + "0 "*) # ahead of upstream + p=">" ;; + *" 0") # behind upstream + p="<" ;; + *) # diverged from upstream + p="<>" ;; + esac + else + case "$count" in + "") # no upstream + p="" ;; + "0 0") # equal to upstream + p="=" ;; + "0 "*) # ahead of upstream + p="+${count#0 }" ;; + *" 0") # behind upstream + p="-${count% 0}" ;; + *) # diverged from upstream + p="-${count% *}+${count#* }" ;; + esac + fi + + GIT_PROMPT_UPSTREAM_STATE=$p } -_git_prompt__rebase_info () +# sets GIT_PROMPT_REBASE_INFO +# with info about a rebase/merge/etc if it's in progress. +git_prompt__rebase_info () { - GIT_PROMPT_REBASE_INFO='' + GIT_PROMPT_REBASE_INFO='' - if [ "true" != "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then - return - fi - if [ "$GIT_PROMPT_SHOWREBASEINFO" = 'off' ]; then - return - fi - if [ "$(git config --bool prompt.showRebaseInfo)" = "false" ]; then - return - fi + if [[ "true" != "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]]; then + return + fi + if [[ "$GIT_PROMPT_SHOWREBASEINFO" = 'off' ]]; then + return + fi + if [[ "$(git config --bool prompt.showRebaseInfo)" = "false" ]]; then + return + fi - local r="" - local g="$(_git_promt__git_dir)" - if [ -n "$g" ]; then - if [ -f "$g/rebase-merge/interactive" ]; then - r="|REBASE-i" - elif [ -d "$g/rebase-merge" ]; then - r="|REBASE-m" + local rebase_="" + local dir_="$(git_prompt__git_dir)" + if [[ -n "$dir_" ]]; then + if [[ -f "$dir_/rebase-merge/interactive" ]]; then + rebase_="|REBASE-i" + elif [[ -d "$dir_/rebase-merge" ]]; then + rebase_="|REBASE-m" + else + if [[ -d "$dir_/rebase-apply" ]]; then + if [[ -f "$dir_/rebase-apply/rebasing" ]]; then + rebase_="|REBASE" + elif [[ -f "$dir_/rebase-apply/applying" ]]; then + rebase_="|AM" else - if [ -d "$g/rebase-apply" ]; then - if [ -f "$g/rebase-apply/rebasing" ]; then - r="|REBASE" - elif [ -f "$g/rebase-apply/applying" ]; then - r="|AM" - else - r="|AM/REBASE" - fi - elif [ -f "$g/MERGE_HEAD" ]; then - r="|MERGING" - elif [ -f "$g/CHERRY_PICK_HEAD" ]; then - r="|CHERRY-PICKING" - elif [ -f "$g/BISECT_LOG" ]; then - r="|BISECTING" - fi - + rebase_="|AM/REBASE" fi - fi + elif [[ -f "$dir_/MERGE_HEAD" ]]; then + rebase_="|MERGING" + elif [[ -f "$dir_/CHERRY_PICK_HEAD" ]]; then + rebase_="|CHERRY-PICKING" + elif [[ -f "$dir_/BISECT_LOG" ]]; then + rebase_="|BISECTING" + fi - GIT_PROMPT_REBASE_INFO=$r + fi + fi + + GIT_PROMPT_REBASE_INFO=$rebase_ } -_git_prompt__branch () +# sets GIT_PROMPT_BRANCH +# with the branch name +git_prompt__branch () { - GIT_PROMPT_BRANCH='' + GIT_PROMPT_BRANCH='' - if [ "true" != "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then - return - fi + if [[ "true" != "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]]; then + return + fi - if [ "$GIT_PROMPT_SHOWBRANCH" = 'off' ]; then - return - fi - if [ "$(git config --bool prompt.showBranch)" = "false" ]; then - return - fi + if [[ "$GIT_PROMPT_SHOWBRANCH" = 'off' ]]; then + return + fi + if [[ "$(git config --bool prompt.showBranch)" = "false" ]]; then + return + fi - local b="" - local g="$(_git_promt__git_dir)" - if [ -n "$g" ]; then - if [ -f "$g/rebase-merge/interactive" ]; then - b="$(cat "$g/rebase-merge/head-name")" - elif [ -d "$g/rebase-merge" ]; then - b="$(cat "$g/rebase-merge/head-name")" - else - b="$(git symbolic-ref HEAD 2>/dev/null)" || { - - b="$( - case "${GIT_PROMPT_DESCRIBE_STYLE-}" in - (contains) - git describe --contains HEAD ;; - (branch) - git describe --contains --all HEAD ;; - (describe) - git describe HEAD ;; - (* | default) - git describe --tags --exact-match HEAD ;; - esac 2>/dev/null)" || - - b="$(cut -c1-7 "$g/HEAD" 2>/dev/null)" || - b="$b" - } - fi - b=${b##refs/heads/} - if [ "true" = "$(git rev-parse --is-inside-git-dir 2>/dev/null)" ]; then - if [ "true" = "$(git rev-parse --is-bare-repository 2>/dev/null)" ]; then - b="BARE:$b" - else - b="GIT_DIR!" - fi - fi - fi - - GIT_PROMPT_BRANCH=$b -} - - -_git_prompt__stash () -{ - GIT_PROMPT_STASH_STATE_DIRTY='' - - if [ "true" != "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then - return - fi - - if [ "$GIT_PROMPT_SHOWSTASHSTATE" = 'off' ]; then - return - fi - if [ "$(git config --bool prompt.showStashState)" = "false" ]; then - return - fi - - if git rev-parse --verify refs/stash >/dev/null 2>&1; then - GIT_PROMPT_STASH_STATE_DIRTY='yes' + local branch_="" + local dir_="$(git_prompt__git_dir)" + if [[ -n "$dir_" ]]; then + if [[ -f "$dir_/rebase-merge/interactive" ]]; then + branch_="$(cat "$dir_/rebase-merge/head-name")" + elif [[ -d "$dir_/rebase-merge" ]]; then + branch_="$(cat "$dir_/rebase-merge/head-name")" else - GIT_PROMPT_STASH_STATE_DIRTY='no' + branch_="$(git symbolic-ref HEAD 2>/dev/null)" || { + + branch_="$( + case "${GIT_PROMPT_DESCRIBE_STYLE-}" in + (contains) + git describe --contains HEAD ;; + (branch) + git describe --contains --all HEAD ;; + (describe) + git describe HEAD ;; + (* | default) + git describe --tags --exact-match HEAD ;; + esac 2>/dev/null)" || + + branch_="$(cut -c1-7 "$dir_/HEAD" 2>/dev/null)" || + branch_="$branch_" + } fi + branch_=${branch_##refs/heads/} + if [[ "true" = "$(git rev-parse --is-inside-git-dir 2>/dev/null)" ]]; then + if [[ "true" = "$(git rev-parse --is-bare-repository 2>/dev/null)" ]]; then + branch_="BARE:$branch_" + else + branch_="GIT_DIR!" + fi + fi + fi + + GIT_PROMPT_BRANCH=$branch_ } -# This is the short-circuit logic: -local _big_repo='init' -__git_prompt_shortcircuit () +# sets GIT_PROMPT_STASH_STATE_DIRTY +# if the git stash state is dirty +git_prompt__stash () { - if [[ "$_big_repo" == 'yes' ]]; then - _big_repo='' - if [ "$GIT_PROMPT_SHORTCIRCUIT" != 'off' ]; then - echo "$fg[red]" > /dev/stderr - echo "${bold_color}SHELL PROMPT$fg_no_bold[red]: Looks like you hit ctrl-c." > /dev/stderr - echo "${bold_color}SHELL PROMPT$fg_no_bold[red]: So for this repo I'm setting:" > /dev/stderr - echo "${bold_color}SHELL PROMPT$fg_no_bold[red]: git config prompt.showDirtyState false" > /dev/stderr - echo "${bold_color}SHELL PROMPT$fg_no_bold[red]: On big git repos it takes a long time to get info for your prompt." > /dev/stderr - echo "${bold_color}SHELL PROMPT$fg_no_bold[red]: To revert it, run:" > /dev/stderr - echo "${bold_color}SHELL PROMPT$fg_no_bold[red]:$reset_color git config prompt.showDirtyState true" > /dev/stderr - echo '' > /dev/stderr + GIT_PROMPT_STASH_STATE_DIRTY='' - git config prompt.showDirtyState 'false' - $GIT_PROMPT_INFO_FUNC - fi - fi -} -TRAPINT () -{ - __git_prompt_shortcircuit - return $(( 128 + $1 )) -} + if [[ "true" != "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]]; then + return + fi -_git_prompt__dirty_state () -{ - GIT_PROMPT_DIRTY_STATE_FRESH_REPO='' - GIT_PROMPT_DIRTY_STATE_INDEX_ADDED='' - GIT_PROMPT_DIRTY_STATE_INDEX_COPIED='' - GIT_PROMPT_DIRTY_STATE_INDEX_DELETED='' - GIT_PROMPT_DIRTY_STATE_INDEX_DIRTY='' - GIT_PROMPT_DIRTY_STATE_INDEX_MODIFIED='' - GIT_PROMPT_DIRTY_STATE_INDEX_RENAMED='' - GIT_PROMPT_DIRTY_STATE_INDEX_UNMERGED='' - GIT_PROMPT_DIRTY_STATE_WORKTREE_DELETED='' - GIT_PROMPT_DIRTY_STATE_WORKTREE_DIRTY='' - GIT_PROMPT_DIRTY_STATE_WORKTREE_MODIFIED='' - GIT_PROMPT_DIRTY_STATE_WORKTREE_UNTRACKED='' + if [[ "$GIT_PROMPT_SHOWSTASHSTATE" = 'off' ]]; then + return + fi + if [[ "$(git config --bool prompt.showStashState)" = "false" ]]; then + return + fi - if [ "true" != "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then - return - fi - - local g="$(_git_promt__git_dir)" - if [ -z "$g" ]; then - return - fi - if [ "$GIT_PROMPT_SHOWDIRTYSTATE" = 'off' ]; then - return - fi - if [ "$(git config --bool prompt.showDirtyState)" = "false" ]; then - return - fi - - GIT_PROMPT_DIRTY_STATE_FRESH_REPO='no' - GIT_PROMPT_DIRTY_STATE_INDEX_ADDED='no' - GIT_PROMPT_DIRTY_STATE_INDEX_COPIED='no' - GIT_PROMPT_DIRTY_STATE_INDEX_DELETED='no' - GIT_PROMPT_DIRTY_STATE_INDEX_DIRTY='no' - GIT_PROMPT_DIRTY_STATE_INDEX_MODIFIED='no' - GIT_PROMPT_DIRTY_STATE_INDEX_RENAMED='no' - GIT_PROMPT_DIRTY_STATE_INDEX_UNMERGED='no' - GIT_PROMPT_DIRTY_STATE_WORKTREE_DELETED='no' - GIT_PROMPT_DIRTY_STATE_WORKTREE_DIRTY='no' - GIT_PROMPT_DIRTY_STATE_WORKTREE_MODIFIED='no' - GIT_PROMPT_DIRTY_STATE_WORKTREE_UNTRACKED='no' - - if git rev-parse --quiet --verify HEAD >/dev/null; then - else - GIT_PROMPT_DIRTY_STATE_FRESH_REPO='yes' - fi - - _big_repo='yes' - local line - while IFS=$'\n' read line; do - if [[ "$line" = M* ]]; then - GIT_PROMPT_DIRTY_STATE_INDEX_MODIFIED='yes' - GIT_PROMPT_DIRTY_STATE_INDEX_DIRTY='yes' - fi - if [[ "$line" = A* ]]; then - GIT_PROMPT_DIRTY_STATE_INDEX_ADDED='yes' - GIT_PROMPT_DIRTY_STATE_INDEX_DIRTY='yes' - fi - if [[ "$line" = R* ]]; then - GIT_PROMPT_DIRTY_STATE_INDEX_RENAMED='yes' - GIT_PROMPT_DIRTY_STATE_INDEX_DIRTY='yes' - fi - if [[ "$line" = C* ]]; then - GIT_PROMPT_DIRTY_STATE_INDEX_COPIED='yes' - GIT_PROMPT_DIRTY_STATE_INDEX_DIRTY='yes' - fi - if [[ "$line" = D* ]]; then - GIT_PROMPT_DIRTY_STATE_INDEX_DELETED='yes' - GIT_PROMPT_DIRTY_STATE_INDEX_DIRTY='yes' - fi - - if [[ "$line" = \?\?* ]]; then - GIT_PROMPT_DIRTY_STATE_WORKTREE_UNTRACKED='yes' - fi - if [[ "$line" = ?M* ]]; then - GIT_PROMPT_DIRTY_STATE_WORKTREE_MODIFIED='yes' - GIT_PROMPT_DIRTY_STATE_WORKTREE_DIRTY='yes' - fi - if [[ "$line" = ?D* ]]; then - GIT_PROMPT_DIRTY_STATE_WORKTREE_DELETED='yes' - GIT_PROMPT_DIRTY_STATE_WORKTREE_DIRTY='yes' - fi - - if [[ "$line" = UU* ]]; then - GIT_PROMPT_DIRTY_STATE_INDEX_UNMERGED='yes' - GIT_PROMPT_DIRTY_STATE_INDEX_DIRTY='yes' - fi - done < <(git status --porcelain 2> /dev/null) - _big_repo='' + if git rev-parse --verify refs/stash >/dev/null 2>&1; then + GIT_PROMPT_STASH_STATE_DIRTY='yes' + else + GIT_PROMPT_STASH_STATE_DIRTY='no' + fi } #------------------ Fast Prompt ------------------ @@ -573,30 +493,74 @@ chpwd_functions+="_git_prompt_info" PERIOD=15 periodic_functions+="_git_prompt_info" -_git_prompt_info () { $GIT_PROMPT_INFO_FUNC } -_git_prompt_info +_git_prompt_info () +{ + if [[ -z $GIT_PROMPT_INFO_DISABLED ]]; then + git_prompt_info + fi +} _git_prompt__precmd_update_git_vars() { - if [[ $ZSH_VERSION = *\ 4.2* ]]; then - # some older versions of zsh don't have periodic_functions, so do the - # slow path if that's the case: - $GIT_PROMPT_INFO_FUNC + if [[ $ZSH_VERSION = *\ 4.2* ]]; then + # some older versions of zsh don't have periodic_functions, so do the + # slow path if that's the case: + _git_prompt_info - elif [ -n "$__EXECUTED_GIT_COMMAND" ]; then - $GIT_PROMPT_INFO_FUNC - unset __EXECUTED_GIT_COMMAND - fi + elif [[ -n "$__EXECUTED_GIT_COMMAND" ]]; then + _git_prompt_info + unset __EXECUTED_GIT_COMMAND + fi } _git_prompt__preexec_update_git_vars () { - case "$1" in - $EDITOR*) __EXECUTED_GIT_COMMAND=1 ;; - g*) __EXECUTED_GIT_COMMAND=1 ;; - rm*) __EXECUTED_GIT_COMMAND=1 ;; - touch*) __EXECUTED_GIT_COMMAND=1 ;; - mkdir*) __EXECUTED_GIT_COMMAND=1 ;; - esac + case "$1" in + g*) __EXECUTED_GIT_COMMAND=1 ;; + rm*) __EXECUTED_GIT_COMMAND=1 ;; + touch*) __EXECUTED_GIT_COMMAND=1 ;; + mkdir*) __EXECUTED_GIT_COMMAND=1 ;; + echo*) __EXECUTED_GIT_COMMAND=1 ;; + $EDITOR*) + if [[ -n "$EDITOR" ]]; then + __EXECUTED_GIT_COMMAND=1 + fi + ;; + esac } -#-------------------------------------------------- +#------------------ Short Circuit ------------------ +# This is the short-circuit logic: +# +# Set GIT_PROMPT_SHORTCIRCUIT='off' to turn the short-circuit logic off. +# +# Gathering dirty-state info can take a long time on large repositories. The +# short-circuit logic is engaged by pressing ctrl-c while the prompt is trying +# to gather information about a large repository. When this happens the +# short-circuit logic will display a warning and turn off the showing of dirty +# state in your git prompt (for the local repo only). +local _big_repo='init' +__git_prompt_shortcircuit () +{ + if [[ "$_big_repo" == 'yes' ]]; then + _big_repo='' + if [[ "$GIT_PROMPT_SHORTCIRCUIT" != 'off' ]]; then + echo "$fg[red]" > /dev/stderr + echo "${bold_color}SHELL PROMPT$fg_no_bold[red]: Looks like you hit ctrl-c." > /dev/stderr + echo "${bold_color}SHELL PROMPT$fg_no_bold[red]: So for this repo I'm setting:" > /dev/stderr + echo "${bold_color}SHELL PROMPT$fg_no_bold[red]: git config prompt.showDirtyState false" > /dev/stderr + echo "${bold_color}SHELL PROMPT$fg_no_bold[red]: On big git repos it takes a long time to get info for your prompt." > /dev/stderr + echo "${bold_color}SHELL PROMPT$fg_no_bold[red]: To revert it, run:" > /dev/stderr + echo "${bold_color}SHELL PROMPT$fg_no_bold[red]:$reset_color git config prompt.showDirtyState true" > /dev/stderr + echo '' > /dev/stderr + + git config prompt.showDirtyState 'false' + _git_prompt_info + fi + fi +} +TRAPINT () +{ + __git_prompt_shortcircuit + return $(( 128 + $1 )) +} +#---------------------------------------------------- diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index bb515c73a..8bfe492bd 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -1,3 +1,2 @@ source $ZSH/plugins/git/git-aliases.plugin.zsh -source $ZSH/plugins/git/git-prompt-old.plugin.zsh source $ZSH/plugins/git/git-prompt.plugin.zsh diff --git a/plugins/github/github.plugin.zsh b/plugins/github/github.plugin.zsh index df7053ba7..1eb338113 100644 --- a/plugins/github/github.plugin.zsh +++ b/plugins/github/github.plugin.zsh @@ -4,4 +4,3 @@ if [ "$commands[(I)hub]" ]; then # eval `hub alias -s zsh` function git(){hub "$@"} fi - diff --git a/plugins/gnu-utils/gnu-utils.plugin.zsh b/plugins/gnu-utils/gnu-utils.plugin.zsh index e59265d66..28317ff99 100644 --- a/plugins/gnu-utils/gnu-utils.plugin.zsh +++ b/plugins/gnu-utils/gnu-utils.plugin.zsh @@ -6,7 +6,7 @@ # ------------------------------------------------------------------------------ -if [[ -x "${commands[gwhoami]}" ]]; then +if [[ -x "${commands[gwhoami]}" ]]; then __gnu_utils() { emulate -L zsh local gcmds @@ -14,7 +14,7 @@ if [[ -x "${commands[gwhoami]}" ]]; then local cmd local prefix - # coreutils + # coreutils gcmds=('g[' 'gbase64' 'gbasename' 'gcat' 'gchcon' 'gchgrp' 'gchmod' 'gchown' 'gchroot' 'gcksum' 'gcomm' 'gcp' 'gcsplit' 'gcut' 'gdate' 'gdd' 'gdf' 'gdir' 'gdircolors' 'gdirname' 'gdu' 'gecho' 'genv' 'gexpand' @@ -35,7 +35,7 @@ if [[ -x "${commands[gwhoami]}" ]]; then for gcmd in "${gcmds[@]}"; do # # This method allows for builtin commands to be primary but it's - # lost if hash -r or rehash -f is executed. Thus, those two + # lost if hash -r or rehash -f is executed. Thus, those two # functions have to be wrapped. # (( ${+commands[$gcmd]} )) && hash ${gcmd[2,-1]}=${commands[$gcmd]} diff --git a/plugins/gpg-agent/gpg-agent.plugin.zsh b/plugins/gpg-agent/gpg-agent.plugin.zsh new file mode 100644 index 000000000..8cc71fd57 --- /dev/null +++ b/plugins/gpg-agent/gpg-agent.plugin.zsh @@ -0,0 +1,26 @@ +# 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 +} + +# Source GPG agent settings, 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 + +GPG_TTY=$(tty) +export GPG_TTY diff --git a/plugins/macports/_port b/plugins/macports/_port index 06d7fb426..c4de6eabb 100644 --- a/plugins/macports/_port +++ b/plugins/macports/_port @@ -1,6 +1,6 @@ #compdef port -local subcmds +local subcmds # we cache the list of ports # we shall use some cache policy to avoid problems with new ports @@ -31,8 +31,8 @@ subcmds=( 'file' 'help' 'info' -'install' -'installed' +'install' +'installed' 'list' 'livecheck' 'location' @@ -48,7 +48,7 @@ subcmds=( 'test' 'unarchive' 'uninstall' -'upgrade' +'upgrade' 'variants' 'version' ) diff --git a/plugins/node/node.plugin.zsh b/plugins/node/node.plugin.zsh new file mode 100644 index 000000000..e803e96a8 --- /dev/null +++ b/plugins/node/node.plugin.zsh @@ -0,0 +1,5 @@ +# Open the node api for your current version to the optional section. +# TODO: Make the section part easier to use. +function node-docs { + open "http://nodejs.org/docs/$(node --version)/api/all.html#$1" +} diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh index 62f7ccd75..682bb2667 100644 --- a/plugins/osx/osx.plugin.zsh +++ b/plugins/osx/osx.plugin.zsh @@ -44,7 +44,7 @@ EOF } function pfd() { - osascript 2>/dev/null </dev/null </dev/null </dev/null < /dev/stderr phing -l |grep -v ":" |grep -v "^$"|grep -v "\-" > .phing_targets fi compadd `cat .phing_targets` diff --git a/plugins/pow/pow.plugin.zsh b/plugins/pow/pow.plugin.zsh new file mode 100644 index 000000000..6b2a6f2be --- /dev/null +++ b/plugins/pow/pow.plugin.zsh @@ -0,0 +1,10 @@ +# Thanks to Christopher Sexton +# https://gist.github.com/965032 +function kapow { + touch ~/.pow/$1/tmp/restart.txt + if [ $? -eq 0 ]; then + echo "$fg[yellow]Pow restarting $1...$reset_color" + fi +} + +compctl -W ~/.pow -/ kapow diff --git a/plugins/redis-cli/_redis-cli b/plugins/redis-cli/_redis-cli index 3789add18..ae82dcd58 100644 --- a/plugins/redis-cli/_redis-cli +++ b/plugins/redis-cli/_redis-cli @@ -139,4 +139,4 @@ _arguments \ if (( CURRENT == 1 )); then _describe -t commands "redis-cli subcommand" _1st_arguments return -fi \ No newline at end of file +fi diff --git a/plugins/ruby/ruby.plugin.zsh b/plugins/ruby/ruby.plugin.zsh index 82bf5d49d..08ca9c601 100644 --- a/plugins/ruby/ruby.plugin.zsh +++ b/plugins/ruby/ruby.plugin.zsh @@ -1,4 +1,6 @@ +# TODO: Make this compatible with rvm. +# Run sudo gem on the system ruby, not the active ruby. alias sgem='sudo gem' # Find ruby file -alias rfind='find . -name *.rb | xargs grep -n' \ No newline at end of file +alias rfind='find . -name *.rb | xargs grep -n' diff --git a/plugins/rvm/_rvm b/plugins/rvm/_rvm new file mode 100644 index 000000000..977e14a78 --- /dev/null +++ b/plugins/rvm/_rvm @@ -0,0 +1,147 @@ +#compdef rvm + +local curcontext="$curcontext" state line cmds ret=1 + +_arguments -C \ + '(- 1 *)'{-v,--version}'[display version information]' \ + '(-l|--level)'{-l,--level}'+[patch level to use with rvm use / install]:number' \ + '(--prefix)--prefix[path for all rvm files (~/.rvm/), with trailing slash!]:path:_files' \ + '(--bin)--bin[path for binaries to be placed (~/.rvm/bin/)]:path:_files' \ + '(--source)--source[src directory to use (~/.rvm/src/)]:path:_files' \ + '(--archives)--archives[directory for downladed files (~/.rvm/archives/)]:path:_files' \ + '-S[Specify a script file to attempt to load and run (rubydo)]:file:_files' \ + '-e[Execute code from the command line]:code' \ + '(-G)-G[root gem path to use]:path:_files' \ + '(--gems)--gems[Used to set the gems_flag, use with remove to remove gems]' \ + '(--archive)--archive[Used to set the archive_flag, use with remove to remove archive]' \ + '(--patch)--patch[With MRI Rubies you may specify one or more full paths to patches]' \ + '(-C|--configure)'{-C,--configure}'=[custom configure options]' \ + '(--nice)--nice[process niceness (for slow computers, default 0)]:number' \ + '(--ree)--ree-options[Options passed directly to ree ./installer on the command line]:options' \ + '(--head)--head[with update, updates rvm to git head version]' \ + '(--rubygems)--rubygems[with update, updates rubygems for selected ruby]' \ + '(--default)--default[with ruby select, sets a default ruby for new shells]' \ + '(--debug)--debug[Toggle debug mode on for very verbose output]' \ + '(--trace)--trace[Toggle trace mode on to see EVERYTHING rvm is doing]' \ + '(--force)--force[Force install, removes old install & source before install]' \ + '(--summary)--summary[Used with rubydo to print out a summary of the commands run]' \ + '(--latest)--latest[with gemset --dump skips version strings for latest gem]' \ + '(--gems)--gems[with uninstall/remove removes gems with the interpreter]' \ + '(--docs)--docs[with install, attempt to generate ri after installation]' \ + '(--reconfigure)--reconfigure[Force ./configure on install even if Makefile already exists]' \ + '1: :->cmds' \ + '*: :->args' && ret=0 + +case $state in + cmds) + cmds=( + "version:show the rvm version installed in rvm_path" + "use:setup current shell to use a specific ruby version" + "reload:reload rvm source itself (useful after changing rvm source)" + "implode:(seppuku) removes the rvm installation completely. This means everything in $rvm_path (~/.rvm)." + "update:upgrades rvm to the latest version." + "reset:remove current and stored default & system settings." + "info :show the *current* environment information for current ruby" + "current:print the *current* ruby version and the name of any gemset being used." + "debug:show info plus additional information for common issues" + "install:install one or many ruby versions" + "uninstall:uninstall one or many ruby versions, leaves their sources" + "remove:uninstall one or many ruby versions and remove their sources" + "migrate:Lets you migrate all gemsets from one ruby to another." + "upgrade:Lets you upgrade from one version of a ruby to another, including migrating your gemsets semi-automatically." + "wrapper:generates a set of wrapper executables for a given ruby with the specified ruby and gemset combination. Used under the hood for passenger support and the like." + "cleanup:Lets you remove stale source folders / archives and other miscellaneous data associated with rvm." + "repair:Lets you repair parts of your environment e.g. wrappers, env files and and similar files (e.g. general maintenance)." + "snapshot:Lets your backup / restore an rvm installation in a lightweight manner." + "disk-usage:Tells you how much disk space rvm install is using." + "tools:Provides general information about the ruby environment, primarily useful when scripting rvm." + "docs:Tools to make installing ri and rdoc documentation easier." + "rvmrc:Tools related to managing rvmrc trust and loading." + "exec:runs an arbitrary command as a set operation." + "ruby:runs a named ruby file against specified and/or all rubies" + "gem:runs a gem command using selected ruby's 'gem'" + "rake:runs a rake task against specified and/or all rubies" + "tests:runs 'rake test' across selected ruby versions" + "specs:runs 'rake spec' across selected ruby versions" + "monitor:Monitor cwd for testing, run rake {spec,test} on changes." + "gemset:gemsets: http://rvm.beginrescueend.com/gemsets/" + "rubygems:Switches the installed version of rubygems for the current ruby." + "gemdir:display the path to the current gem directory (GEM_HOME)." + "srcdir:display the path to rvm source directory (may be yanked)" + "fetch:Performs an archive / src fetch only of the selected ruby." + "list:show currently installed rubies, interactive output." + "package:Install a dependency package {readline,iconv,zlib,openssl}" + "notes:Display notes, with operating system specifics." + "export:Temporarily set an environment variable in the current shell." + "unexport:Undo changes made to the environment by 'rvm export'." + ) + _describe -t commands 'rvm command' cmds && ret=0 + ;; + args) + case $line[1] in + (use|uninstall|remove|list) + _values -S , 'rubies' $(rvm list strings | sed -e 's/ruby-\([^) ]*\)-\([^) ]*\)/ruby-\1-\2 \1-\2 \1/g') default system && ret=0 + ;; + (install|fetch) + _values -S , 'rubies' $(rvm list known_strings) && ret=0 + ;; + gemset) + if (( CURRENT == 3 )); then + _values 'gemset_commands' \ + 'import' \ + 'export' \ + 'create' \ + 'copy' \ + 'rename' \ + 'empty' \ + 'delete' \ + 'name' \ + 'dir' \ + 'list' \ + 'list_all' \ + 'gemdir' \ + 'install' \ + 'pristine' \ + 'clear' \ + 'use' \ + 'update' \ + 'unpack' \ + 'globalcache' + else + _values -S , 'gemsets' $(rvm gemset list | grep -v gemset 2>/dev/null) + fi + ret=0 + ;; + package) + if (( CURRENT == 3 )); then + _values 'package_commands' \ + 'install' \ + 'uninstall' + else + _values 'packages' \ + 'readline' \ + 'iconv' \ + 'curl' \ + 'openssl' \ + 'zlib' \ + 'autoconf' \ + 'ncurses' \ + 'pkgconfig' \ + 'gettext' \ + 'glib' \ + 'mono' \ + 'llvm' \ + 'libxml2' \ + 'libxslt' \ + 'libyaml' + fi + ret=0 + ;; + *) + (( ret )) && _message 'no more arguments' + ;; + esac + ;; +esac + +return ret diff --git a/plugins/rvm/rvm.plugin.zsh b/plugins/rvm/rvm.plugin.zsh new file mode 100644 index 000000000..cda28795a --- /dev/null +++ b/plugins/rvm/rvm.plugin.zsh @@ -0,0 +1,57 @@ +# Get the name of the current branch. +function rvm_prompt_info() { + local ruby_version=$(~/.rvm/bin/rvm-prompt 2> /dev/null) + if [[ -n "$ruby_version" ]]; then + echo "($ruby_version)" + fi +} + +alias rubies='rvm list rubies' +alias gemsets='rvm gemset list' + +local ruby18='ruby-1.8.7-p334' +local ruby19='ruby-1.9.2-p180' + +function rb18 { + if [ -z "$1" ]; then + rvm use "$ruby18" + else + rvm use "$ruby18@$1" + fi +} + +_rb18() {compadd `ls -1 $rvm_path/gems | grep "^$ruby18@" | sed -e "s/^$ruby18@//" | awk '{print $1}'`} +compdef _rb18 rb18 + +function rb19 { + if [ -z "$1" ]; then + rvm use "$ruby19" + else + rvm use "$ruby19@$1" + fi +} + +_rb19() {compadd `ls -1 $rvm_path/gems | grep "^$ruby19@" | sed -e "s/^$ruby19@//" | awk '{print $1}'`} +compdef _rb19 rb19 + +function rvm-update { + rvm get head + rvm reload # TODO: Reload rvm completion? +} + +function rvm-link-completion { + ln -s "$rvm_path/scripts/zsh/Completion/_rvm" "$ZSH/plugins/rvm/_rvm.official" +} + +# TODO: Make this usable w/o rvm. +function gems { + local current_ruby=`rvm-prompt i v p` + local current_gemset=`rvm-prompt g` + + gem list $@ | sed \ + -Ee "s/\([0-9\.]+( .+)?\)/$fg[blue]&$reset_color/g" \ + -Ee "s|$(echo $rvm_path)|$fg[magenta]\$rvm_path$reset_color|g" \ + -Ee "s/$current_ruby@global/$fg[yellow]&$reset_color/g" \ + -Ee "s/$current_ruby$current_gemset$/$fg[green]&$reset_color/g" +} + diff --git a/plugins/svn/svn.plugin.zsh b/plugins/svn/svn.plugin.zsh index 45d461306..0e6f63c11 100644 --- a/plugins/svn/svn.plugin.zsh +++ b/plugins/svn/svn.plugin.zsh @@ -15,7 +15,7 @@ function in_svn() { function svn_get_repo_name { if [ is_svn ]; then svn info | sed -n 's/Repository\ Root:\ .*\///p' | read SVN_ROOT - + svn info | sed -n "s/URL:\ .*$SVN_ROOT\///p" | sed "s/\/.*$//" fi } @@ -29,9 +29,9 @@ function svn_get_rev_nr { function svn_dirty_choose { if [ is_svn ]; then s=$(svn status 2>/dev/null) - if [ $s ]; then + if [ $s ]; then echo $1 - else + else echo $2 fi fi @@ -39,4 +39,4 @@ function svn_dirty_choose { function svn_dirty { svn_dirty_choose $ZSH_THEME_SVN_PROMPT_DIRTY $ZSH_THEME_SVN_PROMPT_CLEAN -} \ No newline at end of file +} diff --git a/plugins/textmate/textmate.plugin.zsh b/plugins/textmate/textmate.plugin.zsh index 7b73e2751..aa2f75f4f 100644 --- a/plugins/textmate/textmate.plugin.zsh +++ b/plugins/textmate/textmate.plugin.zsh @@ -1,11 +1,9 @@ +alias et='mate .' +alias ett='mate app config lib db public spec test Rakefile Capfile Todo' +alias etp='mate app config lib db public spec test vendor/plugins vendor/gems Rakefile Capfile Todo' +alias etts='mate app config lib db public script spec test vendor/plugins vendor/gems Rakefile Capfile Todo' -# TextMate -alias et='mate . &' -alias ett='mate app config lib db public spec test Rakefile Capfile Todo &' -alias etp='mate app config lib db public spec test vendor/plugins vendor/gems Rakefile Capfile Todo &' -alias etts='mate app config lib db public script spec test vendor/plugins vendor/gems Rakefile Capfile Todo &' - -# Editor Ruby file in TextMate +# Edit Ruby app in TextMate alias mr='mate CHANGELOG app config db lib public script spec test' function tm() { diff --git a/plugins/thor/_thor b/plugins/thor/_thor new file mode 100644 index 000000000..9f7ed5aef --- /dev/null +++ b/plugins/thor/_thor @@ -0,0 +1,4 @@ +#compdef thor +#autoload + +compadd `thor list | grep thor | cut -d " " -f 2` diff --git a/plugins/vagrant/_vagrant b/plugins/vagrant/_vagrant index 483b29c53..2e76d2ec2 100644 --- a/plugins/vagrant/_vagrant +++ b/plugins/vagrant/_vagrant @@ -1,4 +1,4 @@ -#compdef vagrant +#compdef vagrant #autoload # vagrant zsh completion @@ -64,7 +64,7 @@ __vagrant-box () (options) case $line[1] in (repackage|remove) - _arguments ':feature:__box_list' + _arguments ':feature:__box_list' ;; esac ;; @@ -93,7 +93,7 @@ case $state in (options) case $line[1] in (help) - _arguments ':feature:__task_list' + _arguments ':feature:__task_list' ;; (box) diff --git a/templates/zshrc.zsh-template b/templates/zshrc.zsh-template index 65299df3e..6746feb28 100644 --- a/templates/zshrc.zsh-template +++ b/templates/zshrc.zsh-template @@ -1,28 +1,24 @@ -# Path to your oh-my-zsh configuration. -export ZSH=$HOME/.oh-my-zsh +# Path to oh-my-zsh. +export ZSH="$HOME/.oh-my-zsh" -# Set name of the theme to load. -# Look in ~/.oh-my-zsh/themes/ -# Optionally, if you set this to "random", it'll load a random theme each -# time that oh-my-zsh is loaded. +# Set the name of the theme to load (see $ZSH/themes/). +# Setting it to 'random' loads a random theme. export ZSH_THEME="robbyrussell" -# Set to this to use case-sensitive completion -# export CASE_SENSITIVE="true" +# Set to 'true' to enable case-sensitivity. +export CASE_SENSITIVE='false' -# Comment this out to disable weekly auto-update checks -# export DISABLE_AUTO_UPDATE="true" +# Set to 'true' to disable color (auto set on dumb terminals). +export DISABLE_COLOR='false' -# Uncomment following line if you want to disable colors in ls -# export DISABLE_COLOR="true" +# Set to 'true' to disable auto setting the tab and window titles. +export DISABLE_AUTO_TITLE='false' -# Uncomment following line if you want to disable autosetting terminal title. -# export DISABLE_AUTO_TITLE="true" - -# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*) -# Example format: plugins=(rails git textmate ruby lighthouse) +# Set the plugins to load (see $ZSH/plugins/). +# Example: plugins=(rails git textmate ruby lighthouse) plugins=(git) -source $ZSH/oh-my-zsh.sh +source "$ZSH/oh-my-zsh.sh" # Customize to your needs... + diff --git a/themes/Soliah.zsh-theme b/themes/Soliah.zsh-theme index 237e70fda..2f3fbbde1 100644 --- a/themes/Soliah.zsh-theme +++ b/themes/Soliah.zsh-theme @@ -1,14 +1,30 @@ -PROMPT='%{$fg[blue]%}%n%{$reset_color%} on %{$fg[red]%}%M%{$reset_color%} in %{$fg[blue]%}%~%b%{$reset_color%}$(git_time_since_commit)$(check_git_prompt_info) +local R="%{$terminfo[sgr0]%}" + +PROMPT='%{$fg[blue]%}%n$R on %{$fg[red]%}%M$R in %{$fg[blue]%}%~%b$R$GIT_PROMPT_INFO $ ' -ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[white]%}" -ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%})" +git_prompt_info () +{ + if [ -z "$(git_prompt__git_dir)" ]; then + GIT_PROMPT_INFO="($(rvm_gemset)$R)" + return + fi -# Text to display if the branch is dirty -ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}*%{$reset_color%}" + local prompt='' -# Text to display if the branch is clean -ZSH_THEME_GIT_PROMPT_CLEAN="" + git_prompt__branch + prompt="%{$fg[white]%}$GIT_PROMPT_BRANCH" + + git_prompt__rebase_info + prompt="${prompt}$GIT_PROMPT_REBASE_INFO" + + git_prompt__dirty_state + if [[ "$GIT_PROMPT_DIRTY_STATE_ANY_DIRTY" = 'yes' ]]; then + prompt="${prompt}%{$fg[red]%}*" + fi + + GIT_PROMPT_INFO="($(rvm_gemset)$(git_time_since_commit)$prompt$R)" +} # Colors vary depending on time lapsed. ZSH_THEME_GIT_TIME_SINCE_COMMIT_SHORT="%{$fg[green]%}" @@ -17,25 +33,12 @@ ZSH_THEME_GIT_TIME_SINCE_COMMIT_LONG="%{$fg[red]%}" ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL="%{$fg[cyan]%}" -# Git sometimes goes into a detached head state. git_prompt_info doesn't -# return anything in this case. So wrap it in another function and check -# for an empty string. -function check_git_prompt_info() { - if git rev-parse --git-dir > /dev/null 2>&1; then - if [[ -z $(git_prompt_info) ]]; then - echo "%{$fg[magenta]%}detached-head%{$reset_color%})" - else - echo "$(git_prompt_info)" - fi - fi -} - # Determine if we are using a gemset. function rvm_gemset() { GEMSET=`rvm gemset list | grep '=>' | cut -b4-` if [[ -n $GEMSET ]]; then - echo "%{$fg[yellow]%}$GEMSET%{$reset_color%}|" - fi + echo "%{$fg[yellow]%}${GEMSET}$R|" + fi } @@ -53,12 +56,12 @@ function git_time_since_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 [[ -n $(git status -s 2> /dev/null) ]]; then if [ "$MINUTES" -gt 30 ]; then COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_LONG" @@ -72,15 +75,15 @@ function git_time_since_commit() { fi if [ "$HOURS" -gt 24 ]; then - echo "($(rvm_gemset)$COLOR${DAYS}d${SUB_HOURS}h${SUB_MINUTES}m%{$reset_color%}|" + echo "$COLOR${DAYS}d${SUB_HOURS}h${SUB_MINUTES}m$R|" elif [ "$MINUTES" -gt 60 ]; then - echo "($(rvm_gemset)$COLOR${HOURS}h${SUB_MINUTES}m%{$reset_color%}|" + echo "$COLOR${HOURS}h${SUB_MINUTES}m$R|" else - echo "($(rvm_gemset)$COLOR${MINUTES}m%{$reset_color%}|" + echo "$COLOR${MINUTES}m$R|" fi else COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL" - echo "($(rvm_gemset)$COLOR~|" + echo "$COLOR~|" fi fi } diff --git a/themes/afowler.zsh-theme b/themes/afowler.zsh-theme index 3a4753fc1..136286d71 100644 --- a/themes/afowler.zsh-theme +++ b/themes/afowler.zsh-theme @@ -2,7 +2,7 @@ if [ $UID -eq 0 ]; then CARETCOLOR="red"; else CARETCOLOR="blue"; fi local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})" -PROMPT='%m %{${fg_bold[blue]}%}:: %{$reset_color%}%{${fg[green]}%}%3~ $(git_prompt_info)%{${fg_bold[$CARETCOLOR]}%}»%{${reset_color}%} ' +PROMPT='%m %{${fg_bold[blue]}%}:: %{$reset_color%}%{${fg[green]}%}%3~ $GIT_PROMPT_INFO%{${fg_bold[$CARETCOLOR]}%}»%{${reset_color}%} ' RPS1="${return_code}" diff --git a/themes/arrow.zsh-theme b/themes/arrow.zsh-theme index d62dcdcb9..a2ef03a8f 100644 --- a/themes/arrow.zsh-theme +++ b/themes/arrow.zsh-theme @@ -1,7 +1,7 @@ if [ $UID -eq 0 ]; then NCOLOR="red"; else NCOLOR="yellow"; fi PROMPT='%{$fg[$NCOLOR]%}%c ➤ %{$reset_color%}' -RPROMPT='%{$fg[$NCOLOR]%}%p $(git_prompt_info)%{$reset_color%}' +RPROMPT='%{$fg[$NCOLOR]%}%p $GIT_PROMPT_INFO%{$reset_color%}' ZSH_THEME_GIT_PROMPT_PREFIX="git:" ZSH_THEME_GIT_PROMPT_SUFFIX="" diff --git a/themes/ashleydev.zsh-theme b/themes/ashleydev.zsh-theme index 15961b9c6..de9ba0133 100644 --- a/themes/ashleydev.zsh-theme +++ b/themes/ashleydev.zsh-theme @@ -1,24 +1,34 @@ +# ------------------------------------------------------------------------------ +# FILE: ashleydev.theme.zsh +# DESCRIPTION: oh-my-zsh prompt theme, shows vi mode, last shell return code, +# and verbose git info. +# AUTHOR: Ashley Dev (the.ashley.dev+zsh-theme@gmail.com) +# VERSION: 3.0 +# SCREENSHOT: http://i.imgur.com/Yw1KG.png +# http://i.imgur.com/wx6MU.png +# ------------------------------------------------------------------------------ + # NOTE: make sure to add 'git' to your list of oh-my-zsh plugins (in your # ~/.zshrc), otherwise the git prompt info will not be shown. #-------------------- Colors ---------------------- # Colors ('_C' for color): if [[ "$DISABLE_COLOR" != "true" ]]; then - # git prompt info colors: - local _Cerror_="%{$fg[yellow]%}" # bad (empty) .git/ directory - local _Cb_new_repo_="%{$fg_bold[default]%}" # branch color of new repo - local _Cb_clean_="%{$fg_no_bold[green]%}" # branch color when clean - local _Cb_dirty_="%{$fg_no_bold[red]%}" # branch color when dirty - local _Cr_="%{$bold_color$fg[yellow]%}" # rebase info - local _Ci_="%{$bold_color$fg[red]%}" # index info - local _Cu_clean_="" # untracked files state when clean - local _Cu_dirty_="%{$fg_bold[red]%}" # untracked files state when dirty - local _Cp_="%{${fg[cyan]}%}" # upstream info - local _Cs_="" # stash state - # Reset formating: local R="%{$terminfo[sgr0]%}" + # git prompt info colors: + local _Cerror_="%{$fg[yellow]%}" # bad (empty) .git/ directory + local _Cbranch_new_repo_="%{$fg_bold[default]%}" # branch color of new repo + local _Cbranch_clean_="%{$fg_no_bold[green]%}" # branch color when clean + local _Cbranch_dirty_="%{$fg_no_bold[red]%}" # branch color when dirty + local _Crebase_="%{$bold_color$fg[yellow]%}" # rebase info + local _Cindex_="%{$bold_color$fg[red]%}" # index info + local _Cuntracked_clean_="" # untracked files state when clean + local _Cuntracked_dirty_="%{$fg_bold[red]%}" # untracked files state when dirty + local _Cupstream_="%{${fg[cyan]}%}" # upstream info + local _Cstash_="" # stash state + # PROMPT colors: local _Cuser_root_="%{$fg_bold[yellow]$bg[red]%}" local _Chost_root_="%{$fg[red]%}" @@ -34,102 +44,15 @@ if [[ "$DISABLE_COLOR" != "true" ]]; then local _Cvi_mode_="%{$fg_bold[cyan]%}" fi -#----------------------------------------------------- -# git prompt info: - -# The git prompt plugin will cause $GIT_PROMPT_INFO_FUNC to be called -# when $__GIT_PROMPT_INFO needs to be updated. -GIT_PROMPT_INFO_FUNC="update__GIT_PROMPT_INFO" -GIT_PROMPT_SHOWUPSTREAM="verbose" -GIT_PROMPT_SHORTCIRCUIT='on' - -local __GIT_PROMPT_INFO='' -# will set __GIT_PROMPT_INFO -update__GIT_PROMPT_INFO () -{ - local g="$(_git_promt__git_dir)" - if [ -z "$g" ]; then - __GIT_PROMPT_INFO='' - return - fi - - _git_prompt__stash - local s=$GIT_PROMPT_STASH_STATE_DIRTY - - _git_prompt__upstream - local p=$GIT_PROMPT_UPSTREAM_STATE - - _git_prompt__branch - local b=$GIT_PROMPT_BRANCH - - _git_prompt__rebase_info - local r=$GIT_PROMPT_REBASE_INFO - - _git_prompt__dirty_state - local w=$GIT_PROMPT_DIRTY_STATE_WORKTREE_DIRTY - local i=$GIT_PROMPT_DIRTY_STATE_INDEX_DIRTY - local u=$GIT_PROMPT_DIRTY_STATE_WORKTREE_UNTRACKED - local f=$GIT_PROMPT_DIRTY_STATE_FRESH_REPO - - if [ -z "$b$i$w$u" ]; then - if [ -n "$g" ]; then - __GIT_PROMPT_INFO="$R$_Cerror_(Error: bad ./$g dir)$R" - return - fi - fi - - if [ "$s" = 'yes' ]; then - s="$_Cs_\$$R" - else - s="" - fi - - if [ -n "$p" ]; then - p="$_Cp_$p$R" - fi - - if [ "$i" = "yes" ]; then - i="$_Ci_+$R" - else - i="" - fi - - if [ -n "$b" ]; then - if [ "$f" = "yes" ]; then - # this is a fresh repo, nothing here... - b="$_Cb_new_repo_$b$R" - elif [ "$w" = 'yes' ]; then - b="$_Cb_dirty_$b$R" - elif [ "$w" = 'no' ]; then - b="$_Cb_clean_$b$R" - fi - fi - - if [ -n "$r" ]; then - r="$_Cr_$r$R" - fi - - local _prompt="$b$r$i$s$p" - # add ( ) around _prompt: - if [ "$u" = "yes" ]; then - _prompt="$_Cu_dirty_($_prompt$_Cu_dirty_)" - elif [ "$u" = "no" ]; then - _prompt="$_Cu_clean_($_prompt$_Cu_clean_)" - else - fi - - __GIT_PROMPT_INFO="$R$_prompt$R" -} - - #-------------------- PROMPT definition: ---------------------- # + local user_="%(!.$_Cuser_root_.$_Cuser_)%n$R" local host_="%(!.$_Chost_root_.$_Chost_)%m$R" local path_="%(!.$_Cpath_root_.$_Cpath_)%~$R" local jobs_="%(1j.$_Cjobs_%j$R.)" -PROMPT='$user_$host_$path_ $__GIT_PROMPT_INFO$jobs_# ' +PROMPT='$user_$host_$path_ $GIT_PROMPT_INFO$jobs_# ' local date_format_='%D{%a %b %d}, %*' local date_="${_Cdate_}[$date_format_]$R" @@ -140,3 +63,81 @@ RPROMPT='$return_code_$date_' # use the vi-mode oh-my-zsh plugin to get this: MODE_INDICATOR="${_Cvi_mode_}-- CMD MODE -- $R" + +#-------------------- Git prompt info format: ---------------------- +git_prompt_info () +{ + local dir_="$(git_prompt__git_dir)" + if [ -z "$dir_" ]; then + GIT_PROMPT_INFO='' + return + fi + + git_prompt__stash + local stash_=$GIT_PROMPT_STASH_STATE_DIRTY + + git_prompt__upstream + local upstream_=$GIT_PROMPT_UPSTREAM_STATE + + git_prompt__branch + local branch_=$GIT_PROMPT_BRANCH + + git_prompt__rebase_info + local rebase_=$GIT_PROMPT_REBASE_INFO + + git_prompt__dirty_state + local work_=$GIT_PROMPT_DIRTY_STATE_WORKTREE_DIRTY + local index_=$GIT_PROMPT_DIRTY_STATE_INDEX_DIRTY + local untracked_=$GIT_PROMPT_DIRTY_STATE_WORKTREE_UNTRACKED + local freshy_=$GIT_PROMPT_DIRTY_STATE_FRESH_REPO + + if [ -z "$branch_$index_$work_$untracked_" ]; then + if [ -n "$dir_" ]; then + GIT_PROMPT_INFO="$R$_Cerror_(Error: bad ./$dir_ dir)$R" + return + fi + fi + + if [ "$stash_" = 'yes' ]; then + stash_="$_Cstash_\$$R" + else + stash_="" + fi + + if [ -n "$upstream_" ]; then + upstream_="$_Cupstream_$upstream_$R" + fi + + if [ "$index_" = "yes" ]; then + index_="$_Cindex_+$R" + else + index_="" + fi + + if [ -n "$branch_" ]; then + if [ "$freshy_" = "yes" ]; then + # this is a fresh repo, nothing here... + branch_="$_Cbranch_new_repo_$branch_$R" + elif [ "$work_" = 'yes' ]; then + branch_="$_Cbranch_dirty_$branch_$R" + elif [ "$work_" = 'no' ]; then + branch_="$_Cbranch_clean_$branch_$R" + fi + fi + + if [ -n "$rebase_" ]; then + rebase_="$_Crebase_$rebase_$R" + fi + + local _prompt="$branch_$rebase_$index_$stash_$upstream_" + # add ( ) around _prompt: + if [ "$untracked_" = "yes" ]; then + _prompt="$_Cuntracked_dirty_($_prompt$_Cuntracked_dirty_)" + elif [ "$untracked_" = "no" ]; then + _prompt="$_Cuntracked_clean_($_prompt$_Cuntracked_clean_)" + else + _prompt="($_prompt)" + fi + + GIT_PROMPT_INFO="$R$_prompt$R" +} diff --git a/themes/aussiegeek.zsh-theme b/themes/aussiegeek.zsh-theme index c2c7f65b9..2bed46d7b 100644 --- a/themes/aussiegeek.zsh-theme +++ b/themes/aussiegeek.zsh-theme @@ -1,5 +1,5 @@ -PROMPT='$fg_bold[blue][ $fg[red]%t $fg_bold[blue]] $fg_bold[blue] [ $fg[red]%n@%m:%~$(git_prompt_info)$fg[yellow]$(rvm_prompt_info)$fg_bold[blue] ]$reset_color +PROMPT='$fg_bold[blue][ $fg[red]%t $fg_bold[blue]] $fg_bold[blue] [ $fg[red]%n@%m:%~$GIT_PROMPT_INFO$fg[yellow]$(rvm_prompt_info)$fg_bold[blue] ]$reset_color $ ' # git theming ZSH_THEME_GIT_PROMPT_PREFIX="$fg_bold[green](" diff --git a/themes/awesomepanda.zsh-theme b/themes/awesomepanda.zsh-theme index 411b89837..3e29ef553 100644 --- a/themes/awesomepanda.zsh-theme +++ b/themes/awesomepanda.zsh-theme @@ -1,6 +1,6 @@ # the svn plugin has to be activated for this to work. -PROMPT='%{$fg_bold[red]%}➜ %{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%}$(svn_prompt_info)%{$reset_color%}' +PROMPT='%{$fg_bold[red]%}➜ %{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$GIT_PROMPT_INFO%{$fg_bold[blue]%}$(svn_prompt_info)%{$reset_color%}' ZSH_THEME_GIT_PROMPT_PREFIX="git:(%{$fg[red]%}" ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" @@ -15,4 +15,4 @@ ZSH_THEME_REPO_NAME_COLOR="%{$fg_bold[red]%}" ZSH_THEME_SVN_PROMPT_PREFIX="svn:(" ZSH_THEME_SVN_PROMPT_SUFFIX=")" ZSH_THEME_SVN_PROMPT_DIRTY="%{$fg[red]%} ✘ %{$reset_color%}" -ZSH_THEME_SVN_PROMPT_CLEAN=" " \ No newline at end of file +ZSH_THEME_SVN_PROMPT_CLEAN=" " diff --git a/themes/bira.zsh-theme b/themes/bira.zsh-theme index 5642eaeb8..437c8c153 100644 --- a/themes/bira.zsh-theme +++ b/themes/bira.zsh-theme @@ -4,7 +4,7 @@ local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})" local user_host='%{$terminfo[bold]$fg[green]%}%n@%m%{$reset_color%}' local current_dir='%{$terminfo[bold]$fg[blue]%} %~%{$reset_color%}' local rvm_ruby='%{$fg[red]%}‹$(rvm-prompt i v g)›%{$reset_color%}' -local git_branch='$(git_prompt_info)%{$reset_color%}' +local git_branch='$GIT_PROMPT_INFO%{$reset_color%}' PROMPT="╭─${user_host} ${current_dir} ${rvm_ruby} ${git_branch} ╰─%B$%b " diff --git a/themes/candy.zsh-theme b/themes/candy.zsh-theme index bc125c5ce..28fb2c1ea 100644 --- a/themes/candy.zsh-theme +++ b/themes/candy.zsh-theme @@ -1,4 +1,4 @@ -PROMPT=$'%{$fg_bold[green]%}%n@%m %{$fg[blue]%}%D{[%I:%M:%S]} %{$reset_color%}%{$fg[white]%}[%~]%{$reset_color%} $(git_prompt_info)\ +PROMPT=$'%{$fg_bold[green]%}%n@%m %{$fg[blue]%}%D{[%I:%M:%S]} %{$reset_color%}%{$fg[white]%}[%~]%{$reset_color%} $GIT_PROMPT_INFO\ %{$fg[blue]%}->%{$fg_bold[blue]%} %#%{$reset_color%} ' ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[green]%}[" diff --git a/themes/clean.zsh-theme b/themes/clean.zsh-theme index 7ee29cb8c..7ae26bcf9 100644 --- a/themes/clean.zsh-theme +++ b/themes/clean.zsh-theme @@ -1,6 +1,6 @@ if [ $UID -eq 0 ]; then NCOLOR="red"; else NCOLOR="white"; fi -PROMPT='%{$fg[$NCOLOR]%}%B%n%b%{$reset_color%}:%{$fg[blue]%}%B%c/%b%{$reset_color%} $(git_prompt_info)%(!.#.$) ' +PROMPT='%{$fg[$NCOLOR]%}%B%n%b%{$reset_color%}:%{$fg[blue]%}%B%c/%b%{$reset_color%} $GIT_PROMPT_INFO%(!.#.$) ' RPROMPT='[%*]' # git theming diff --git a/themes/cloud.zsh-theme b/themes/cloud.zsh-theme index ad5e2834b..e4fbbfc6c 100644 --- a/themes/cloud.zsh-theme +++ b/themes/cloud.zsh-theme @@ -1,6 +1,6 @@ -PROMPT='%{$fg_bold[cyan]%}☁ %{$fg_bold[green]%}%p %{$fg[green]%}%c %{$fg_bold[cyan]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}' +PROMPT='%{$fg_bold[cyan]%}☁ %{$fg_bold[green]%}%p %{$fg[green]%}%c %{$fg_bold[cyan]%}$GIT_PROMPT_INFO%{$fg_bold[blue]%} % %{$reset_color%}' ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[green]%}[%{$fg[cyan]%}" ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[green]%}] %{$fg[yellow]%}⚡%{$reset_color%}" -ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[green]%}]" \ No newline at end of file +ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[green]%}]" diff --git a/themes/dallas.zsh-theme b/themes/dallas.zsh-theme index eef32e998..c62b92769 100644 --- a/themes/dallas.zsh-theme +++ b/themes/dallas.zsh-theme @@ -8,7 +8,7 @@ DALLAS_CURRENT_RUBY_="%{$fg[white]%}[%{$fg[magenta]%}\$(~/.rvm/bin/rvm-prompt i DALLAS_CURRENT_MACH_="%{$fg[green]%}%m%{$fg[white]%}:%{$reset_color%}" # Grab the current filepath, use shortcuts: ~/Desktop # Append the current git branch, if in a git repository: ~aw@master -DALLAS_CURRENT_LOCA_="%{$fg[cyan]%}%~\$(git_prompt_info)%{$reset_color%}" +DALLAS_CURRENT_LOCA_="%{$fg[cyan]%}%~\$GIT_PROMPT_INFO%{$reset_color%}" # Grab the current username: dallas DALLAS_CURRENT_USER_="%{$fg[red]%}%n%{$reset_color%}" # Use a % for normal users and a # for privelaged (root) users. diff --git a/themes/darkblood.zsh-theme b/themes/darkblood.zsh-theme index 33508fbd2..7c7d2485c 100644 --- a/themes/darkblood.zsh-theme +++ b/themes/darkblood.zsh-theme @@ -1,6 +1,6 @@ # meh. Dark Blood Rewind, a new beginning. -PROMPT=$'%{$fg[red]%}┌[%{$fg_bold[white]%}%n%{$reset_color%}%{$fg[red]%}@%{$fg_bold[white]%}%m%{$reset_color%}%{$fg[red]%}] [%{$fg_bold[white]%}/dev/%y%{$reset_color%}%{$fg[red]%}] %{$(git_prompt_info)%}%(?,,%{$fg[red]%}[%{$fg_bold[white]%}%?%{$reset_color%}%{$fg[red]%}]) +PROMPT=$'%{$fg[red]%}┌[%{$fg_bold[white]%}%n%{$reset_color%}%{$fg[red]%}@%{$fg_bold[white]%}%m%{$reset_color%}%{$fg[red]%}] [%{$fg_bold[white]%}/dev/%y%{$reset_color%}%{$fg[red]%}] %{$GIT_PROMPT_INFO%}%(?,,%{$fg[red]%}[%{$fg_bold[white]%}%?%{$reset_color%}%{$fg[red]%}]) %{$fg[red]%}└[%{$fg_bold[white]%}%~%{$reset_color%}%{$fg[red]%}]>%{$reset_color%} ' PS2=$' %{$fg[red]%}|>%{$reset_color%} ' diff --git a/themes/daveverwer.zsh-theme b/themes/daveverwer.zsh-theme index 89aef926e..d2cd2b46a 100644 --- a/themes/daveverwer.zsh-theme +++ b/themes/daveverwer.zsh-theme @@ -1,7 +1,7 @@ # Copied and modified from the oh-my-zsh theme from geoffgarside # Red server name, green cwd, blue git status -PROMPT='%{$fg[red]%}%m%{$reset_color%}:%{$fg[green]%}%c%{$reset_color%}$(git_prompt_info) %(!.#.$) ' +PROMPT='%{$fg[red]%}%m%{$reset_color%}:%{$fg[green]%}%c%{$reset_color%}$GIT_PROMPT_INFO %(!.#.$) ' ZSH_THEME_GIT_PROMPT_PREFIX=" %{$fg[blue]%}(" ZSH_THEME_GIT_PROMPT_SUFFIX=")%{$reset_color%}" diff --git a/themes/dieter.zsh-theme b/themes/dieter.zsh-theme index 0a5e9265b..d71a810c1 100644 --- a/themes/dieter.zsh-theme +++ b/themes/dieter.zsh-theme @@ -26,7 +26,7 @@ local host="@${host_repr[$(hostname)]:-$(hostname)}%{$reset_color%}" # Compacted $PWD local pwd="%{$fg[blue]%}%c%{$reset_color%}" -PROMPT='${time} ${user}${host} ${pwd} $(git_prompt_info)' +PROMPT='${time} ${user}${host} ${pwd} $GIT_PROMPT_INFO' # i would prefer 1 icon that shows the "most drastic" deviation from HEAD, # but lets see how this works out diff --git a/themes/dogenpunk.zsh-theme b/themes/dogenpunk.zsh-theme index f4d65ab74..85eec6f03 100644 --- a/themes/dogenpunk.zsh-theme +++ b/themes/dogenpunk.zsh-theme @@ -6,30 +6,70 @@ # SCREENSHOT: coming soon # ----------------------------------------------------------------------------- -MODE_INDICATOR="%{$fg_bold[red]%}❮%{$reset_color%}%{$fg[red]%}❮❮%{$reset_color%}" -local return_status="%{$fg[red]%}%(?..⏎)%{$reset_color%}" +local R="%{$terminfo[sgr0]%}" -PROMPT='%{$fg[blue]%}%m%{$reset_color%}%{$fg_bold[white]%} ओम् %{$reset_color%}%{$fg[cyan]%}%~:%{$reset_color%}$(git_time_since_commit)$(git_prompt_info) -%{$fg[red]%}%!%{$reset_color%} $(prompt_char) ' +MODE_INDICATOR="%{$fg_bold[red]%}❮$R%{$fg[red]%}❮❮$R" +local return_status="%{$fg[red]%}%(?..⏎)$R" -ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[green]%}git%{$reset_color%}@%{$bg[white]%}%{$fg[black]%}" -ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%})" -ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}!%{$reset_color%}" -ZSH_THEME_GIT_PROMPT_CLEAN="" +PROMPT='%{$fg[blue]%}%m$R%{$fg_bold[white]%} ओम् $R%{$fg[cyan]%}%~:$R$GIT_PROMPT_INFO +%{$fg[red]%}%!$R $(prompt_char) ' -RPROMPT='${return_status}$(git_prompt_status)%{$reset_color%}' +git_prompt_info () +{ + if [ -z "$(git_prompt__git_dir)" ]; then + GIT_PROMPT_INFO='' + GIT_RPROMPT_INFO='' + return + fi -ZSH_THEME_GIT_PROMPT_ADDED="%{$fg[green]%} ✚" -ZSH_THEME_GIT_PROMPT_MODIFIED="%{$fg[blue]%} ✹" -ZSH_THEME_GIT_PROMPT_DELETED="%{$fg[red]%} ✖" -ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg[magenta]%} ➜" -ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg[yellow]%} ═" -ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[cyan]%} ✭" + local prompt='' + + git_prompt__branch + prompt="%{$fg_bold[green]%}git$R@%{$bg[white]%}%{$fg[black]%}$GIT_PROMPT_BRANCH" + + git_prompt__rebase_info + prompt="${prompt}$GIT_PROMPT_REBASE_INFO" + + git_prompt__dirty_state + if [[ "$GIT_PROMPT_DIRTY_STATE_ANY_DIRTY" = 'yes' ]]; then + prompt="${prompt}%{$fg[red]%}!" + fi + GIT_PROMPT_INFO="($(git_time_since_commit)$prompt$R)" + + local rprompt='' + if [[ "$GIT_PROMPT_DIRTY_STATE_INDEX_ADDED" = 'yes' ]]; then + rprompt="%{$fg[green]%} ✚" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_INDEX_MODIFIED" = 'yes' ]]; then + rprompt="${rprompt}%{$fg[blue]%} ✹" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_WORKTREE_MODIFIED" = 'yes' ]]; then + rprompt="${rprompt}%{$fg[blue]%} ✹" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_INDEX_DELETED" = 'yes' ]]; then + rprompt="${rprompt}%{$fg[red]%} ✖" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_WORKTREE_DELETED" = 'yes' ]]; then + rprompt="${rprompt}%{$fg[red]%} ✖" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_INDEX_RENAMED" = 'yes' ]]; then + rprompt="${rprompt}%{$fg[magenta]%} ➜" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_INDEX_UNMERGED" = 'yes' ]]; then + rprompt="${rprompt}%{$fg[yellow]%} ═" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_WORKTREE_UNTRACKED" = 'yes' ]]; then + rprompt="${rprompt}%{$fg[cyan]%} ✭" + fi + GIT_RPROMPT_INFO=$rprompt +} + +RPROMPT='${return_status}$GIT_RPROMPT_INFO$R' function prompt_char() { - git branch >/dev/null 2>/dev/null && echo "%{$fg[green]%}±%{$reset_color%}" && return - hg root >/dev/null 2>/dev/null && echo "%{$fg_bold[red]%}☿%{$reset_color%}" && return - echo "%{$fg[cyan]%}◯ %{$reset_color%}" + git branch >/dev/null 2>/dev/null && echo "%{$fg[green]%}±$R" && return + hg root >/dev/null 2>/dev/null && echo "%{$fg_bold[red]%}☿$R" && return + echo "%{$fg[cyan]%}◯ $R" } # Colors vary depending on time lapsed. @@ -40,7 +80,8 @@ ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL="%{$fg[cyan]%}" # 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() { +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 @@ -71,15 +112,15 @@ function git_time_since_commit() { fi if [ "$HOURS" -gt 24 ]; then - echo "($COLOR${DAYS}d${SUB_HOURS}h${SUB_MINUTES}m%{$reset_color%}|" + echo "$COLOR${DAYS}d${SUB_HOURS}h${SUB_MINUTES}m$R|" elif [ "$MINUTES" -gt 60 ]; then - echo "($COLOR${HOURS}h${SUB_MINUTES}m%{$reset_color%}|" + echo "$COLOR${HOURS}h${SUB_MINUTES}m$R|" else - echo "($COLOR${MINUTES}m%{$reset_color%}|" + echo "$COLOR${MINUTES}m$R|" fi else COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL" - echo "($COLOR~|" + echo "$COLOR~|" fi fi } diff --git a/themes/dst.zsh-theme b/themes/dst.zsh-theme index 3e2539d57..d7fde7649 100644 --- a/themes/dst.zsh-theme +++ b/themes/dst.zsh-theme @@ -10,7 +10,7 @@ function prompt_char { PROMPT='%(?, ,%{$fg[red]%}FAIL%{$reset_color%} ) -%{$fg[magenta]%}%n%{$reset_color%}@%{$fg[yellow]%}%m%{$reset_color%}: %{$fg_bold[blue]%}%~%{$reset_color%}$(git_prompt_info) +%{$fg[magenta]%}%n%{$reset_color%}@%{$fg[yellow]%}%m%{$reset_color%}: %{$fg_bold[blue]%}%~%{$reset_color%}$GIT_PROMPT_INFO %_ $(prompt_char) ' RPROMPT='%{$fg[green]%}[%*]%{$reset_color%}' diff --git a/themes/dstufft.zsh-theme b/themes/dstufft.zsh-theme index 5a23fcea5..c0326da16 100644 --- a/themes/dstufft.zsh-theme +++ b/themes/dstufft.zsh-theme @@ -9,11 +9,32 @@ function virtualenv_info { } PROMPT=' -%{$fg[magenta]%}%n%{$reset_color%} at %{$fg[yellow]%}%m%{$reset_color%} in %{$fg_bold[green]%}${PWD/#$HOME/~}%{$reset_color%}$(git_prompt_info) +%{$fg[magenta]%}%n%{$reset_color%} at %{$fg[yellow]%}%m%{$reset_color%} in %{$fg_bold[green]%}${PWD/#$HOME/~}%{$reset_color%}$GIT_PROMPT_INFO $(virtualenv_info)$(prompt_char) ' -ZSH_THEME_GIT_PROMPT_PREFIX=" on %{$fg[magenta]%}" -ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" -ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[green]%}!" -ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[green]%}?" -ZSH_THEME_GIT_PROMPT_CLEAN="" +git_prompt_info () +{ + if [ -z "$(git_prompt__git_dir)" ]; then + GIT_PROMPT_INFO='' + return + fi + + local prompt="" + git_prompt__branch + prompt=$GIT_PROMPT_BRANCH + + git_prompt__rebase_info + prompt="${prompt}$GIT_PROMPT_REBASE_INFO" + + if [[ -n "$prompt" ]]; then + git_prompt__dirty_state + if [[ "$GIT_PROMPT_DIRTY_STATE_ANY_DIRTY" = 'yes' ]]; then + prompt="$prompt%{$fg[green]%}!" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_WORKTREE_UNTRACKED" = 'yes' ]]; then + prompt="$prompt%{$fg[green]%}?" + fi + + GIT_PROMPT_INFO=" on %{$fg[magenta]%}$prompt%{$reset_color%}" + fi +} diff --git a/themes/eastwood.zsh-theme b/themes/eastwood.zsh-theme index 83664515a..cd8a5dc72 100644 --- a/themes/eastwood.zsh-theme +++ b/themes/eastwood.zsh-theme @@ -1,19 +1,30 @@ #RVM settings -if [[ -s ~/.rvm/scripts/rvm ]] ; then +if [[ -s ~/.rvm/scripts/rvm ]] ; then RPS1="%{$fg[yellow]%}rvm:%{$reset_color%}%{$fg[red]%}\$(~/.rvm/bin/rvm-prompt)%{$reset_color%} $EPS1" fi -ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}%{$fg[green]%}[" -ZSH_THEME_GIT_PROMPT_SUFFIX="]%{$reset_color%}" -ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}*%{$reset_color%}" -ZSH_THEME_GIT_PROMPT_CLEAN="" +local R="%{$terminfo[sgr0]%}" -#Customized git status, oh-my-zsh currently does not allow render dirty status before branch -git_custom_status() { - local cb=$(current_branch) - if [ -n "$cb" ]; then - echo "$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_PREFIX$(current_branch)$ZSH_THEME_GIT_PROMPT_SUFFIX" - fi +git_prompt_info () +{ + if [ -z "$(git_prompt__git_dir)" ]; then + GIT_PROMPT_INFO='' + return + fi + + git_prompt__branch + local cb=$GIT_PROMPT_BRANCH + + git_prompt__rebase_info + cb="${cb}$GIT_PROMPT_REBASE_INFO" + + local dirty + git_prompt__dirty_state + if [[ "$GIT_PROMPT_DIRTY_STATE_ANY_DIRTY" = 'yes' ]]; then + dirty="%{$fg[red]%}*%{$reset_color%}" + fi + + GIT_PROMPT_INFO="$dirty$R%{$fg[green]%}[$cb]$R" } -PROMPT='$(git_custom_status)%{$fg[cyan]%}[%~% ]%{$reset_color%}%B$%b ' +PROMPT='$GIT_PROMPT_INFO%{$fg[cyan]%}[%~% ]%{$reset_color%}%B$%b ' diff --git a/themes/edvardm.zsh-theme b/themes/edvardm.zsh-theme index f9ca1a9e2..625517239 100644 --- a/themes/edvardm.zsh-theme +++ b/themes/edvardm.zsh-theme @@ -1,4 +1,4 @@ -PROMPT='%{$fg_bold[red]%}➜ %{$fg_bold[green]%}%p %{$fg_bold[white]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}' +PROMPT='%{$fg_bold[red]%}➜ %{$fg_bold[green]%}%p %{$fg_bold[white]%}%c %{$fg_bold[blue]%}$GIT_PROMPT_INFO%{$fg_bold[blue]%} % %{$reset_color%}' ZSH_THEME_GIT_PROMPT_PREFIX="git:(%{$fg[red]%}" ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" diff --git a/themes/evan.zsh-theme b/themes/evan.zsh-theme index 5ef1f40dd..2ebb27159 100644 --- a/themes/evan.zsh-theme +++ b/themes/evan.zsh-theme @@ -1,2 +1,2 @@ # Evan describes this sexy prompt as: "a skinny, topless prompt" -PROMPT='%m :: %2~ %B»%b ' \ No newline at end of file +PROMPT='%m :: %2~ %B»%b ' diff --git a/themes/example.zsh-theme b/themes/example.zsh-theme index dbd9dc9c9..4ad3b7cae 100644 --- a/themes/example.zsh-theme +++ b/themes/example.zsh-theme @@ -2,4 +2,4 @@ # http://zshwiki.org/home/config/prompt # -PROMPT="%{$fg[red]%}%n%{$reset_color%}@%{$fg[blue]%}%m %{$fg[yellow]%}%~ %{$reset_color%}%% " \ No newline at end of file +PROMPT="%{$fg[red]%}%n%{$reset_color%}@%{$fg[blue]%}%m %{$fg[yellow]%}%~ %{$reset_color%}%% " diff --git a/themes/fishy.zsh-theme b/themes/fishy.zsh-theme index f22eda868..6fe339bcf 100644 --- a/themes/fishy.zsh-theme +++ b/themes/fishy.zsh-theme @@ -3,7 +3,49 @@ local user_color='green'; [ $UID -eq 0 ] && user_color='red' PROMPT='%n@%m %{$fg[$user_color]%}%~%{$reset_color%}%(!.#.>) ' PROMPT2='%{$fg[red]%}\ %{$reset_color%}' -RPS1='%(?..%{$fg[red]%}%? ↵%{$reset_color%})$(git_prompt_info)' -ZSH_THEME_GIT_PROMPT_PREFIX=" %{$fg[cyan]%}" -ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" +local return_status="%{$fg_bold[red]%}%(?..%?)%{$reset_color%}" +RPROMPT='${return_status}$GIT_PROMPT_INFO%{$reset_color%}' + +git_prompt_info () +{ + if [ -z "$(git_prompt__git_dir)" ]; then + GIT_PROMPT_INFO='' + return + fi + + local prompt='' + + git_prompt__branch + prompt=" $GIT_PROMPT_BRANCH" + + git_prompt__rebase_info + prompt="${prompt}$GIT_PROMPT_REBASE_INFO" + + git_prompt__dirty_state + if [[ "$GIT_PROMPT_DIRTY_STATE_INDEX_ADDED" = 'yes' ]]; then + prompt="${prompt}%{$fg[green]%} +" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_INDEX_MODIFIED" = 'yes' ]]; then + prompt="${prompt}%{$fg[blue]%} !" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_WORKTREE_MODIFIED" = 'yes' ]]; then + prompt="${prompt}%{$fg[blue]%} !" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_INDEX_DELETED" = 'yes' ]]; then + prompt="${prompt}%{$fg[red]%} -" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_WORKTREE_DELETED" = 'yes' ]]; then + prompt="${prompt}%{$fg[red]%} -" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_INDEX_RENAMED" = 'yes' ]]; then + prompt="${prompt}%{$fg[magenta]%} >" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_INDEX_UNMERGED" = 'yes' ]]; then + prompt="${prompt}%{$fg[yellow]%} #" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_WORKTREE_UNTRACKED" = 'yes' ]]; then + prompt="${prompt}%{$fg[cyan]%} ?" + fi + GIT_PROMPT_INFO=$prompt +} diff --git a/themes/flazz.zsh-theme b/themes/flazz.zsh-theme index 280794f2b..d4233a40d 100644 --- a/themes/flazz.zsh-theme +++ b/themes/flazz.zsh-theme @@ -5,7 +5,7 @@ fi local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})" -PROMPT='%m%{${fg_bold[magenta]}%} :: %{$reset_color%}%{${fg[green]}%}%3~ $(git_prompt_info)%{${fg_bold[$CARETCOLOR]}%}%#%{${reset_color}%} ' +PROMPT='%m%{${fg_bold[magenta]}%} :: %{$reset_color%}%{${fg[green]}%}%3~ $GIT_PROMPT_INFO%{${fg_bold[$CARETCOLOR]}%}%#%{${reset_color}%} ' RPS1='$(vi_mode_prompt_info) ${return_code}' diff --git a/themes/fletcherm.zsh-theme b/themes/fletcherm.zsh-theme index e96188544..dfa6c444b 100644 --- a/themes/fletcherm.zsh-theme +++ b/themes/fletcherm.zsh-theme @@ -1,5 +1,5 @@ # Copied from old version of tonotdo's theme. LSCOLORS modified. -PROMPT='%{$fg_no_bold[cyan]%}%n%{$fg_no_bold[magenta]%}•%{$fg_no_bold[green]%}%3~$(git_prompt_info)%{$reset_color%}» ' +PROMPT='%{$fg_no_bold[cyan]%}%n%{$fg_no_bold[magenta]%}•%{$fg_no_bold[green]%}%3~$GIT_PROMPT_INFO%{$reset_color%}» ' RPROMPT='[%*]' # git theming diff --git a/themes/frisk.zsh-theme b/themes/frisk.zsh-theme index f181aec90..3d91c0052 100644 --- a/themes/frisk.zsh-theme +++ b/themes/frisk.zsh-theme @@ -1,5 +1,5 @@ PROMPT=$' -%{$fg[blue]%}%/%{$reset_color%} $(git_prompt_info)%{$fg[white]%}[%n@%m]%{$reset_color%} %{$fg[white]%}[%T]%{$reset_color%} +%{$fg[blue]%}%/%{$reset_color%} $GIT_PROMPT_INFO%{$fg[white]%}[%n@%m]%{$reset_color%} %{$fg[white]%}[%T]%{$reset_color%} %{$fg_bold[black]%}>%{$reset_color%} ' PROMPT2="%{$fg_blod[black]%}%_> %{$reset_color%}" diff --git a/themes/funky.zsh-theme b/themes/funky.zsh-theme index 2451296d9..503455485 100644 --- a/themes/funky.zsh-theme +++ b/themes/funky.zsh-theme @@ -11,4 +11,4 @@ local smiley="%(?,%{$fg[green]%}:%)%{$reset_color%},%{$fg[red]%}:(%{$reset_color PROMPT="╭─${path_p}─${user_host}─${ret_status}─${hist_no} ╰─${blue_op}${smiley}${blue_cp} %# " local cur_cmd="${blue_op}%_${blue_cp}" -PROMPT2="${cur_cmd}> " \ No newline at end of file +PROMPT2="${cur_cmd}> " diff --git a/themes/fwalch.zsh-theme b/themes/fwalch.zsh-theme new file mode 100644 index 000000000..0c9c936bd --- /dev/null +++ b/themes/fwalch.zsh-theme @@ -0,0 +1,6 @@ +PROMPT='%{$fg_bold[green]%}%p %{$fg[cyan]%}%c%{$fg_bold[blue]%}$GIT_PROMPT_INFO%{$fg_bold[blue]%} % %{$reset_color%}' + +ZSH_THEME_GIT_PROMPT_PREFIX=" (%{$fg[red]%}" +ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" +ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗%{$reset_color%}" +ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})" diff --git a/themes/gallifrey.zsh-theme b/themes/gallifrey.zsh-theme index fce7cb923..598e41510 100644 --- a/themes/gallifrey.zsh-theme +++ b/themes/gallifrey.zsh-theme @@ -1,7 +1,7 @@ # ZSH Theme - Preview: http://img.skitch.com/20091113-qqtd3j8xinysujg5ugrsbr7x1y.jpg local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})" -PROMPT='%{$fg[green]%}%m%{$reset_color%} %2~ $(git_prompt_info)%{$reset_color%}%B»%b ' +PROMPT='%{$fg[green]%}%m%{$reset_color%} %2~ $GIT_PROMPT_INFO%{$reset_color%}%B»%b ' RPS1="${return_code}" ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[yellow]%}‹" diff --git a/themes/gallois.zsh-theme b/themes/gallois.zsh-theme index 259640ba4..278435e83 100644 --- a/themes/gallois.zsh-theme +++ b/themes/gallois.zsh-theme @@ -1,19 +1,30 @@ -ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}%{$fg[green]%}[" -ZSH_THEME_GIT_PROMPT_SUFFIX="]%{$reset_color%}" -ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}*%{$reset_color%}" -ZSH_THEME_GIT_PROMPT_CLEAN="" +git_prompt_info () +{ + if [ -z "$(git_prompt__git_dir)" ]; then + GIT_PROMPT_INFO='' + return + fi -#Customized git status, oh-my-zsh currently does not allow render dirty status before branch -git_custom_status() { - local cb=$(current_branch) - if [ -n "$cb" ]; then - echo "$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_PREFIX$(current_branch)$ZSH_THEME_GIT_PROMPT_SUFFIX" - fi + git_prompt__branch + local cb=$GIT_PROMPT_BRANCH + + git_prompt__rebase_info + cb="${cb}$GIT_PROMPT_REBASE_INFO" + + local dirty + git_prompt__dirty_state + if [[ "$GIT_PROMPT_DIRTY_STATE_ANY_DIRTY" = 'yes' ]]; then + dirty="%{$fg[red]%}*%{$reset_color%}" + fi + + local R="%{$terminfo[sgr0]%}" + + GIT_PROMPT_INFO="$dirty$R%{$fg[green]%}[$cb]$R" } #RVM and git settings -if [[ -s ~/.rvm/scripts/rvm ]] ; then - RPS1='$(git_custom_status)%{$fg[red]%}[`~/.rvm/bin/rvm-prompt`]%{$reset_color%} $EPS1' +if [[ -s ~/.rvm/scripts/rvm ]] ; then + RPS1='$GIT_PROMPT_INFO%{$fg[red]%}[`~/.rvm/bin/rvm-prompt`]%{$reset_color%} $EPS1' fi PROMPT='%{$fg[cyan]%}[%~% ]%(?.%{$fg[green]%}.%{$fg[red]%})%B$%b ' diff --git a/themes/garyblessington.zsh-theme b/themes/garyblessington.zsh-theme index b4f84a71c..27a27e9b1 100644 --- a/themes/garyblessington.zsh-theme +++ b/themes/garyblessington.zsh-theme @@ -1,4 +1,4 @@ -PROMPT='%{$fg[cyan]%}%c%{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%}% %{$reset_color%}: ' +PROMPT='%{$fg[cyan]%}%c%{$fg_bold[blue]%}$GIT_PROMPT_INFO%{$fg_bold[blue]%}% %{$reset_color%}: ' ZSH_THEME_GIT_PROMPT_PREFIX="(%{$fg[blue]%}" ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" diff --git a/themes/gentoo.zsh-theme b/themes/gentoo.zsh-theme index cba143d42..be0a6cc0c 100644 --- a/themes/gentoo.zsh-theme +++ b/themes/gentoo.zsh-theme @@ -1,4 +1,4 @@ -PROMPT='%(!.%{$fg_bold[red]%}.%{$fg_bold[green]%}%n@)%m %{$fg_bold[blue]%}%(!.%1~.%~) $(git_prompt_info)%#%{$reset_color%} ' +PROMPT='%(!.%{$fg_bold[red]%}.%{$fg_bold[green]%}%n@)%m %{$fg_bold[blue]%}%(!.%1~.%~) $GIT_PROMPT_INFO%#%{$reset_color%} ' ZSH_THEME_GIT_PROMPT_PREFIX="(" ZSH_THEME_GIT_PROMPT_SUFFIX=") " diff --git a/themes/geoffgarside.zsh-theme b/themes/geoffgarside.zsh-theme index 675ec7206..20a85c1df 100644 --- a/themes/geoffgarside.zsh-theme +++ b/themes/geoffgarside.zsh-theme @@ -1,5 +1,5 @@ -# PROMPT="[%*] %n:%c $(git_prompt_info)%(!.#.$) " -PROMPT='[%*] %{$fg[cyan]%}%n%{$reset_color%}:%{$fg[green]%}%c%{$reset_color%}$(git_prompt_info) %(!.#.$) ' +# PROMPT="[%*] %n:%c $GIT_PROMPT_INFO%(!.#.$) " +PROMPT='[%*] %{$fg[cyan]%}%n%{$reset_color%}:%{$fg[green]%}%c%{$reset_color%}$GIT_PROMPT_INFO %(!.#.$) ' ZSH_THEME_GIT_PROMPT_PREFIX=" %{$fg[yellow]%}git:(" ZSH_THEME_GIT_PROMPT_SUFFIX=")%{$reset_color%}" diff --git a/themes/gozilla.zsh-theme b/themes/gozilla.zsh-theme index c6b752e9b..ace15be24 100644 --- a/themes/gozilla.zsh-theme +++ b/themes/gozilla.zsh-theme @@ -1,15 +1,51 @@ -PROMPT='%{$fg_bold[red]%}➜ %{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}' +local R="%{$terminfo[sgr0]%}" -ZSH_THEME_GIT_PROMPT_PREFIX="(" -ZSH_THEME_GIT_PROMPT_SUFFIX=")" -ZSH_THEME_GIT_PROMPT_DIRTY="" -ZSH_THEME_GIT_PROMPT_CLEAN="" +PROMPT='%{$fg_bold[red]%}➜ %{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$GIT_PROMPT_INFO % $R' +RPROMPT='$GIT_RPROMPT_INFO$R' -RPROMPT='$(git_prompt_status)%{$reset_color%}' +git_prompt_info () +{ + if [ -z "$(git_prompt__git_dir)" ]; then + GIT_PROMPT_INFO='' + GIT_RPROMPT_INFO='' + return + fi -ZSH_THEME_GIT_PROMPT_ADDED="%{$fg[cyan]%} ✈" -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[magenta]%} ✂" -ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[grey]%} ✱" + local prompt='' + + git_prompt__branch + prompt="$GIT_PROMPT_BRANCH" + + git_prompt__rebase_info + prompt="${prompt}$GIT_PROMPT_REBASE_INFO" + + GIT_PROMPT_INFO="($prompt)" + + local rprompt='' + git_prompt__dirty_state + if [[ "$GIT_PROMPT_DIRTY_STATE_INDEX_ADDED" = 'yes' ]]; then + rprompt="%{$fg[cyan]%} ✈" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_INDEX_MODIFIED" = 'yes' ]]; then + rprompt="${rprompt}%{$fg[yellow]%} ✭" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_WORKTREE_MODIFIED" = 'yes' ]]; then + rprompt="${rprompt}%{$fg[yellow]%} ✭" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_INDEX_DELETED" = 'yes' ]]; then + rprompt="${rprompt}%{$fg[red]%} ✗" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_WORKTREE_DELETED" = 'yes' ]]; then + rprompt="${rprompt}%{$fg[red]%} ✗" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_INDEX_RENAMED" = 'yes' ]]; then + rprompt="${rprompt}%{$fg[blue]%} ➦" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_INDEX_UNMERGED" = 'yes' ]]; then + rprompt="${rprompt}%{$fg[magenta]%} ✂" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_WORKTREE_UNTRACKED" = 'yes' ]]; then + rprompt="${rprompt}%{$fg[grey]%} ✱" + fi + GIT_RPROMPT_INFO=$rprompt +} diff --git a/themes/imajes.zsh-theme b/themes/imajes.zsh-theme index 88c35b6d9..918cd8081 100644 --- a/themes/imajes.zsh-theme +++ b/themes/imajes.zsh-theme @@ -2,4 +2,4 @@ # http://zshwiki.org/home/config/prompt # -PROMPT="%{$fg[red]%}%%%{$reset_color%} " \ No newline at end of file +PROMPT="%{$fg[red]%}%%%{$reset_color%} " diff --git a/themes/jbergantine.zsh-theme b/themes/jbergantine.zsh-theme index d84247cff..0232fdb10 100644 --- a/themes/jbergantine.zsh-theme +++ b/themes/jbergantine.zsh-theme @@ -1,4 +1,4 @@ -PROMPT='%{$fg_bold[red]%}➜ %{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[white]%}$(git_prompt_info)%{$fg_bold[white]%} % %{$reset_color%}' +PROMPT='%{$fg_bold[red]%}➜ %{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[white]%}$GIT_PROMPT_INFO%{$fg_bold[white]%} % %{$reset_color%}' ZSH_THEME_GIT_PROMPT_PREFIX="git:(%{$fg[red]%}" ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" diff --git a/themes/jonathan.zsh-theme b/themes/jonathan.zsh-theme index add485279..491dbd49e 100644 --- a/themes/jonathan.zsh-theme +++ b/themes/jonathan.zsh-theme @@ -5,15 +5,15 @@ function precmd { ### # Truncate the path if it's too long. - + PR_FILLBAR="" PR_PWDLEN="" - + local promptsize=${#${(%):---(%n@%m:%l)---()--}} local rubyprompt=`rvm_prompt_info` local rubypromptsize=${#${rubyprompt}} local pwdsize=${#${(%):-%~}} - + if [[ "$promptsize + $rubypromptsize + $pwdsize" -gt $TERMWIDTH ]]; then ((PR_PWDLEN=$TERMWIDTH - $promptsize)) else @@ -32,7 +32,51 @@ preexec () { } -setprompt () { +git_prompt_info () +{ + if [ -z "$(git_prompt__git_dir)" ]; then + GIT_PROMPT_INFO='' + return + fi + + local prompt='' + + git_prompt__branch + prompt=" on %{$fg[green]%}$GIT_PROMPT_BRANCH" + + git_prompt__rebase_info + prompt="${prompt}$GIT_PROMPT_REBASE_INFO%{$terminfo[sgr0]%}" + + git_prompt__dirty_state + if [[ "$GIT_PROMPT_DIRTY_STATE_INDEX_ADDED" = 'yes' ]]; then + prompt="${prompt}%{$fg[green]%} ✚" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_INDEX_MODIFIED" = 'yes' ]]; then + prompt="${prompt}%{$fg[blue]%} ✹" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_WORKTREE_MODIFIED" = 'yes' ]]; then + prompt="${prompt}%{$fg[blue]%} ✹" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_INDEX_DELETED" = 'yes' ]]; then + prompt="${prompt}%{$fg[red]%} ✖" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_WORKTREE_DELETED" = 'yes' ]]; then + prompt="${prompt}%{$fg[red]%} ✖" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_INDEX_RENAMED" = 'yes' ]]; then + prompt="${prompt}%{$fg[magenta]%} ➜" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_INDEX_UNMERGED" = 'yes' ]]; then + prompt="${prompt}%{$fg[yellow]%} ═" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_WORKTREE_UNTRACKED" = 'yes' ]]; then + prompt="${prompt}%{$fg[cyan]%} ✭" + fi + GIT_PROMPT_INFO=$prompt +} + +setprompt () +{ ### # Need this so the prompt will work. @@ -53,23 +97,9 @@ setprompt () { done PR_NO_COLOUR="%{$terminfo[sgr0]%}" - ### - # Modify Git prompt - ZSH_THEME_GIT_PROMPT_PREFIX=" on %{$fg[green]%}" - ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" - ZSH_THEME_GIT_PROMPT_DIRTY="" - ZSH_THEME_GIT_PROMPT_CLEAN="" - - ZSH_THEME_GIT_PROMPT_ADDED="%{$fg[green]%} ✚" - ZSH_THEME_GIT_PROMPT_MODIFIED="%{$fg[blue]%} ✹" - ZSH_THEME_GIT_PROMPT_DELETED="%{$fg[red]%} ✖" - ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg[magenta]%} ➜" - ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg[yellow]%} ═" - ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[cyan]%} ✭" - ### # See if we can use extended characters to look nicer. - + typeset -A altchar set -A altchar ${(s..)terminfo[acsc]} PR_SET_CHARSET="%{$terminfo[enacs]%}" @@ -81,10 +111,10 @@ setprompt () { PR_LRCORNER=${altchar[j]:--} PR_URCORNER=${altchar[k]:--} - + ### # Decide if we need to set titlebar text. - + case $TERM in xterm*) PR_TITLEBAR=$'%{\e]0;%(!.-=*[ROOT]*=- | .)%n@%m:%~ | ${COLUMNS}x${LINES} | %y\a%}' @@ -96,8 +126,8 @@ setprompt () { PR_TITLEBAR='' ;; esac - - + + ### # Decide whether to set a screen title if [[ "$TERM" == "screen" ]]; then @@ -105,8 +135,8 @@ setprompt () { else PR_STITLE='' fi - - + + ### # Finally, the prompt. @@ -119,7 +149,7 @@ $PR_GREY)$PR_CYAN$PR_SHIFT_IN$PR_HBAR$PR_URCORNER$PR_SHIFT_OUT\ $PR_CYAN$PR_SHIFT_IN$PR_LLCORNER$PR_BLUE$PR_HBAR$PR_SHIFT_OUT(\ $PR_YELLOW%D{%H:%M:%S}\ -$PR_LIGHT_BLUE%{$reset_color%}`git_prompt_info``git_prompt_status`$PR_BLUE)$PR_CYAN$PR_SHIFT_IN$PR_HBAR\ +$PR_LIGHT_BLUE%{$reset_color%}$GIT_PROMPT_INFO$PR_BLUE)$PR_CYAN$PR_SHIFT_IN$PR_HBAR\ $PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT\ >$PR_NO_COLOUR ' diff --git a/themes/josh.zsh-theme b/themes/josh.zsh-theme index 6bed1a70e..b3ed027ed 100644 --- a/themes/josh.zsh-theme +++ b/themes/josh.zsh-theme @@ -15,7 +15,7 @@ function josh_prompt { branch_size=${#branch} ruby_size=${#ruby_version} user_machine_size=${#${(%):-%n@%m-}} - + if [[ ${#branch} -eq 0 ]] then (( ruby_size = ruby_size + 1 )) else @@ -24,15 +24,15 @@ function josh_prompt { (( branch_size = branch_size + 2 )) fi fi - + (( spare_width = ${spare_width} - (${user_machine_size} + ${path_size} + ${branch_size} + ${ruby_size}) )) while [ ${#prompt} -lt $spare_width ]; do prompt=" $prompt" done - - prompt="%{%F{green}%}$PWD$prompt%{%F{red}%}$(rvm_prompt_info)%{$reset_color%} $(git_prompt_info)" - + + prompt="%{%F{green}%}$PWD$prompt%{%F{red}%}$(rvm_prompt_info)%{$reset_color%} $GIT_PROMPT_INFO" + echo $prompt } diff --git a/themes/jreese.zsh-theme b/themes/jreese.zsh-theme index 0fa6b4ecd..339509239 100644 --- a/themes/jreese.zsh-theme +++ b/themes/jreese.zsh-theme @@ -4,7 +4,7 @@ if [ $UID -eq 0 ]; then NCOLOR="red"; else NCOLOR="green"; fi local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})" PROMPT='%{$fg[$NCOLOR]%}%n%{$fg[green]%}@%m%{$reset_color%} %~ \ -$(git_prompt_info)\ +$GIT_PROMPT_INFO\ %{$fg[red]%}%(!.#.»)%{$reset_color%} ' PROMPT2='%{$fg[red]%}\ %{$reset_color%}' RPS1='${return_code}' diff --git a/themes/jtriley.zsh-theme b/themes/jtriley.zsh-theme index 15d77ed23..aad8af24a 100644 --- a/themes/jtriley.zsh-theme +++ b/themes/jtriley.zsh-theme @@ -1,4 +1,4 @@ -#PROMPT='%{$fg_bold[red]%}➜ %{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}' +#PROMPT='%{$fg_bold[red]%}➜ %{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$GIT_PROMPT_INFO%{$fg_bold[blue]%} % %{$reset_color%}' PROMPT="%{$fg_bold[cyan]%}%T%{$fg_bold[green]%} %{$fg_bold[white]%}%n%{$fg[magenta]%}@%{$fg_bold[white]%}%m %{$fg_bold[green]%}%d %{$fg_bold[yellow]%}%% %{$reset_color%}" diff --git a/themes/juanghurtado.zsh-theme b/themes/juanghurtado.zsh-theme index 2f715cc9e..4dff6255e 100644 --- a/themes/juanghurtado.zsh-theme +++ b/themes/juanghurtado.zsh-theme @@ -1,6 +1,5 @@ # ------------------------------------------------------------------------ # Juan G. Hurtado oh-my-zsh theme -# (Needs Git plugin for current_branch method) # ------------------------------------------------------------------------ # Color shortcuts @@ -16,31 +15,68 @@ WHITE_BOLD=$fg_bold[white] BLUE_BOLD=$fg_bold[blue] RESET_COLOR=$reset_color -# Format for git_prompt_info() -ZSH_THEME_GIT_PROMPT_PREFIX="" -ZSH_THEME_GIT_PROMPT_SUFFIX="" - -# Format for parse_git_dirty() -ZSH_THEME_GIT_PROMPT_DIRTY=" %{$RED%}(*)" -ZSH_THEME_GIT_PROMPT_CLEAN="" - -# Format for git_prompt_status() -ZSH_THEME_GIT_PROMPT_UNMERGED=" %{$RED%}unmerged" -ZSH_THEME_GIT_PROMPT_DELETED=" %{$RED%}deleted" -ZSH_THEME_GIT_PROMPT_RENAMED=" %{$YELLOW%}renamed" -ZSH_THEME_GIT_PROMPT_MODIFIED=" %{$YELLOW%}modified" -ZSH_THEME_GIT_PROMPT_ADDED=" %{$GREEN%}added" -ZSH_THEME_GIT_PROMPT_UNTRACKED=" %{$WHITE%}untracked" - -# Format for git_prompt_ahead() -ZSH_THEME_GIT_PROMPT_AHEAD=" %{$RED%}(!)" - -# Format for git_prompt_long_sha() and git_prompt_short_sha() -ZSH_THEME_GIT_PROMPT_SHA_BEFORE=" %{$WHITE%}[%{$YELLOW%}" -ZSH_THEME_GIT_PROMPT_SHA_AFTER="%{$WHITE%}]" # Prompt format PROMPT=' -%{$GREEN_BOLD%}%n@%m%{$WHITE%}:%{$YELLOW%}%~%u$(parse_git_dirty)$(git_prompt_ahead)%{$RESET_COLOR%} +%{$GREEN_BOLD%}%n@%m%{$WHITE%}:%{$YELLOW%}%~%u$GIT_PROMPT_INFO%{$RESET_COLOR%} %{$BLUE%}>%{$RESET_COLOR%} ' -RPROMPT='%{$GREEN_BOLD%}$(current_branch)$(git_prompt_short_sha)$(git_prompt_status)%{$RESET_COLOR%}' \ No newline at end of file +RPROMPT='%{$GREEN_BOLD%}$GIT_RPROMPT_INFO%{$RESET_COLOR%}' + +git_prompt_info () +{ + if [ -z "$(git_prompt__git_dir)" ]; then + GIT_PROMPT_INFO='' + GIT_RPROMPT_INFO='' + return + fi + + local dirty='' + git_prompt__dirty_state + if [[ "$GIT_PROMPT_DIRTY_STATE_ANY_DIRTY" = 'yes' ]]; then + dirty=" %{$RED%}(*)" + fi + git_prompt__upstream + if [[ "$GIT_PROMPT_UPSTREAM_STATE" != "=" ]]; then + local upstream=" %{$RED%}($GIT_PROMPT_UPSTREAM_STATE)" + fi + + GIT_PROMPT_INFO="$dirty$upstream" + + git_prompt__branch + local current_branch="$GIT_PROMPT_BRANCH" + + git_prompt__rebase_info + current_branch="${current_branch}$GIT_PROMPT_REBASE_INFO" + + local sha=$(git rev-parse --short HEAD 2> /dev/null) + if [[ -n "$sha" ]]; then + sha=" %{$WHITE%}[%{$YELLOW%}$sha%{$WHITE%}]" + fi + + local git_status='' + if [[ "$GIT_PROMPT_DIRTY_STATE_INDEX_ADDED" = 'yes' ]]; then + git_status="%{$GREEN%} added" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_INDEX_MODIFIED" = 'yes' ]]; then + git_status="${git_status}%{$YELLOW%} modified" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_WORKTREE_MODIFIED" = 'yes' ]]; then + git_status="${git_status}%{$YELLOW%} modified" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_INDEX_DELETED" = 'yes' ]]; then + git_status="${git_status}%{$RED%} deleted" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_WORKTREE_DELETED" = 'yes' ]]; then + git_status="${git_status}%{$RED%} deleted" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_INDEX_RENAMED" = 'yes' ]]; then + git_status="${git_status}%{$YELLOW%} renamed" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_INDEX_UNMERGED" = 'yes' ]]; then + git_status="${git_status}%{$RED%} unmerged" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_WORKTREE_UNTRACKED" = 'yes' ]]; then + git_status="${git_status}%{$WHITE%} untracked" + fi + GIT_RPROMPT_INFO="$current_branch$sha$git_status" +} diff --git a/themes/kardan.zsh-theme b/themes/kardan.zsh-theme index fd6586a9d..33002a8e1 100644 --- a/themes/kardan.zsh-theme +++ b/themes/kardan.zsh-theme @@ -5,8 +5,8 @@ function get_host { } PROMPT='> ' -RPROMPT='%~$(git_prompt_info)$(get_host)' +RPROMPT='%~$GIT_PROMPT_INFO$(get_host)' ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[yellow]%}✗%{$reset_color%}" ZSH_THEME_GIT_PROMPT_PREFIX="(" -ZSH_THEME_GIT_PROMPT_SUFFIX=")" \ No newline at end of file +ZSH_THEME_GIT_PROMPT_SUFFIX=")" diff --git a/themes/kennethreitz.zsh-theme b/themes/kennethreitz.zsh-theme index 109be0c22..897e243d2 100644 --- a/themes/kennethreitz.zsh-theme +++ b/themes/kennethreitz.zsh-theme @@ -1,7 +1,7 @@ local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})" PROMPT='%{$fg[green]%}%c \ -$(git_prompt_info)\ +$GIT_PROMPT_INFO\ %{$fg[red]%}%(!.#.»)%{$reset_color%} ' PROMPT2='%{$fg[red]%}\ %{$reset_color%}' RPS1='%{$fg[blue]%}%~%{$reset_color%} ${return_code} ' diff --git a/themes/kphoen.zsh-theme b/themes/kphoen.zsh-theme index 0e9b5e73c..f0f0cbd27 100644 --- a/themes/kphoen.zsh-theme +++ b/themes/kphoen.zsh-theme @@ -6,45 +6,66 @@ # SCREENSHOT: # ------------------------------------------------------------------------------ - -if [[ "$TERM" != "dumb" ]] && [[ "$DISABLE_LS_COLORS" != "true" ]]; then - PROMPT='[%{$fg[red]%}%n%{$reset_color%}@%{$fg[magenta]%}%m%{$reset_color%}:%{$fg[blue]%}%~%{$reset_color%}$(git_prompt_info)] -%# ' - - ZSH_THEME_GIT_PROMPT_PREFIX=" on %{$fg[green]%}" - ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" - ZSH_THEME_GIT_PROMPT_DIRTY="" - ZSH_THEME_GIT_PROMPT_CLEAN="" - - # display exitcode on the right when >0 - return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})" - - RPROMPT='${return_code}$(git_prompt_status)%{$reset_color%}' - - ZSH_THEME_GIT_PROMPT_ADDED="%{$fg[green]%} ✚" - ZSH_THEME_GIT_PROMPT_MODIFIED="%{$fg[blue]%} ✹" - ZSH_THEME_GIT_PROMPT_DELETED="%{$fg[red]%} ✖" - ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg[magenta]%} ➜" - ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg[yellow]%} ═" - ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[cyan]%} ✭" -else - PROMPT='[%n@%m:%~$(git_prompt_info)] -%# ' - - ZSH_THEME_GIT_PROMPT_PREFIX=" on" - ZSH_THEME_GIT_PROMPT_SUFFIX="" - ZSH_THEME_GIT_PROMPT_DIRTY="" - ZSH_THEME_GIT_PROMPT_CLEAN="" - - # display exitcode on the right when >0 - return_code="%(?..%? ↵)" - - RPROMPT='${return_code}$(git_prompt_status)' - - ZSH_THEME_GIT_PROMPT_ADDED=" ✚" - ZSH_THEME_GIT_PROMPT_MODIFIED=" ✹" - ZSH_THEME_GIT_PROMPT_DELETED=" ✖" - ZSH_THEME_GIT_PROMPT_RENAMED=" ➜" - ZSH_THEME_GIT_PROMPT_UNMERGED=" ═" - ZSH_THEME_GIT_PROMPT_UNTRACKED=" ✭" +if [[ "$TERM" != "dumb" ]] && [[ "$DISABLE_COLORS" != "true" ]]; then + local R="%{$terminfo[sgr0]%}" + local MAGENTA="%{$fg[magenta]%}" + local YELLOW="%{$fg[yellow]%}" + local GREEN="%{$fg[green]%}" + local BLUE="%{$fg[blue]%}" + local CYAN="%{$fg[cyan]%}" + local RED="%{$fg[red]%}" fi + +PROMPT='[$RED%n$R@$MAGENTA%m$R:$BLUE%~$R$GIT_PROMPT_INFO] +%# ' + +# display exitcode on the right when >0 +return_code="%(?..$RED%? ↵$R)" +RPROMPT='${return_code}$GIT_RPROMPT_INFO$R' + +git_prompt_info () +{ + if [ -z "$(git_prompt__git_dir)" ]; then + GIT_PROMPT_INFO='' + GIT_RPROMPT_INFO='' + return + fi + + local branch='' + + git_prompt__branch + branch="$GIT_PROMPT_BRANCH" + + git_prompt__rebase_info + branch="${branch}$GIT_PROMPT_REBASE_INFO" + + GIT_PROMPT_INFO=" on $GREEN${branch}$R" + + local rprompt='' + git_prompt__dirty_state + if [[ "$GIT_PROMPT_DIRTY_STATE_INDEX_ADDED" = 'yes' ]]; then + rprompt="$GREEN ✚" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_INDEX_MODIFIED" = 'yes' ]]; then + rprompt="${rprompt}$BLUE ✹" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_WORKTREE_MODIFIED" = 'yes' ]]; then + rprompt="${rprompt}$BLUE ✹" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_INDEX_DELETED" = 'yes' ]]; then + rprompt="${rprompt}$RED ✖" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_WORKTREE_DELETED" = 'yes' ]]; then + rprompt="${rprompt}$RED ✖" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_INDEX_RENAMED" = 'yes' ]]; then + rprompt="${rprompt}$MAGENTA ➜" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_INDEX_UNMERGED" = 'yes' ]]; then + rprompt="${rprompt}$YELLOW ═" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_WORKTREE_UNTRACKED" = 'yes' ]]; then + rprompt="${rprompt}$CYAN ✭" + fi + GIT_RPROMPT_INFO=$rprompt +} diff --git a/themes/lambda.zsh-theme b/themes/lambda.zsh-theme index 63292d331..56f1ab5b8 100644 --- a/themes/lambda.zsh-theme +++ b/themes/lambda.zsh-theme @@ -1,6 +1,6 @@ # ZSH Theme - Preview: http://cl.ly/350F0F0k1M2y3A2i3p1S -PROMPT='λ %~/ $(git_prompt_info)%{$reset_color%}' +PROMPT='λ %~/ $GIT_PROMPT_INFO%{$reset_color%}' ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[green]%}" ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} " diff --git a/themes/linuxonly b/themes/linuxonly index a11b80d7f..335b2c4a7 100644 --- a/themes/linuxonly +++ b/themes/linuxonly @@ -47,7 +47,7 @@ prompt_jnrowe_precmd () { #dir_status="$c1%n%F{7}@%F{9}%m%F{7}:%F{12}%/" dir_status="%{$c1%}%n%{$c4%}@%{$c2%}%m%{$c0%}:%{$c3%}%l%{$c6%}->%{$c4%}%/ %{$c0%}(%{$c5%}%?%{$c0%})" #dir_status="%{$c1%}%n%{$c4%}@%{$c2%}%m%{$c0%}:%{$c3%}%l%{$c6%}->%{$foopath%} %{$c0%}(%{$c5%}%?%{$c0%})" - + PROMPT='%{$fg_bold[green]%}%p%{$reset_color%}${vcs_info_msg_0_}${dir_status} ${ret_status}%{$reset_color%} > ' elif [[ $(git diff --cached --name-status 2>/dev/null ) != "" ]]; then @@ -55,7 +55,7 @@ prompt_jnrowe_precmd () { PROMPT='${vcs_info_msg_0_} %{$fg_bold[green]%}%p%{$reset_color%}${dir_status} ${vcs_info_msg_0_}%{$reset_color%} > ' - + elif [[ $(git diff --name-status 2>/dev/null ) != "" ]]; then dir_status="%{$c1%}%n%{$c4%}@%{$c2%}%m%{$c0%}:%{$c3%}%l%{$c6%}->%{$c4%}%/ %{$c0%}(%{$c5%}%?%{$c0%})" @@ -67,7 +67,7 @@ prompt_jnrowe_precmd () { PROMPT='${vcs_info_msg_0_} %{$fg_bold[green]%}%p%{$reset_color%}${dir_status} ${vcs_info_msg_0_}%{$reset_color%} > ' - + fi } diff --git a/themes/lukerandall.zsh-theme b/themes/lukerandall.zsh-theme index 24a0612b7..54007aa79 100644 --- a/themes/lukerandall.zsh-theme +++ b/themes/lukerandall.zsh-theme @@ -3,7 +3,7 @@ local return_code="%(?..%{$fg_bold[red]%}%? ↵%{$reset_color%})" -PROMPT='%{$fg_bold[green]%}%n@%m%{$reset_color%} %{$fg_bold[blue]%}%2~%{$reset_color%} $(git_prompt_info)%{$reset_color%}%B»%b ' +PROMPT='%{$fg_bold[green]%}%n@%m%{$reset_color%} %{$fg_bold[blue]%}%2~%{$reset_color%} $GIT_PROMPT_INFO%{$reset_color%}%B»%b ' RPS1="${return_code}" ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[yellow]%}(" diff --git a/themes/macovsky-ruby.zsh-theme b/themes/macovsky-ruby.zsh-theme index 4eb410233..be4e8d512 100644 --- a/themes/macovsky-ruby.zsh-theme +++ b/themes/macovsky-ruby.zsh-theme @@ -1,7 +1,7 @@ # ZSH Theme - Preview: http://gyazo.com/8becc8a7ed5ab54a0262a470555c3eed.png local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})" -PROMPT='%{$fg[green]%}%~%{$reset_color%} %{$fg[red]%}‹$(~/.rvm/bin/rvm-prompt i v)› %{$reset_color%} $(git_prompt_info)%{$reset_color%}%B$%b ' +PROMPT='%{$fg[green]%}%~%{$reset_color%} %{$fg[red]%}‹$(~/.rvm/bin/rvm-prompt i v)› %{$reset_color%} $GIT_PROMPT_INFO%{$reset_color%}%B$%b ' RPS1="${return_code}" ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[yellow]%}‹" diff --git a/themes/macovsky.zsh-theme b/themes/macovsky.zsh-theme index 4eb410233..be4e8d512 100644 --- a/themes/macovsky.zsh-theme +++ b/themes/macovsky.zsh-theme @@ -1,7 +1,7 @@ # ZSH Theme - Preview: http://gyazo.com/8becc8a7ed5ab54a0262a470555c3eed.png local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})" -PROMPT='%{$fg[green]%}%~%{$reset_color%} %{$fg[red]%}‹$(~/.rvm/bin/rvm-prompt i v)› %{$reset_color%} $(git_prompt_info)%{$reset_color%}%B$%b ' +PROMPT='%{$fg[green]%}%~%{$reset_color%} %{$fg[red]%}‹$(~/.rvm/bin/rvm-prompt i v)› %{$reset_color%} $GIT_PROMPT_INFO%{$reset_color%}%B$%b ' RPS1="${return_code}" ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[yellow]%}‹" diff --git a/themes/maran.zsh-theme b/themes/maran.zsh-theme index 6fba04688..e196cd8d6 100644 --- a/themes/maran.zsh-theme +++ b/themes/maran.zsh-theme @@ -1,6 +1,6 @@ # Theme with full path names and hostname # Handy if you work on different servers all the time; -PROMPT='%{$fg[cyan]%}%n%{$reset_color%}@%{$fg[yellow]%}%M:%{$fg[green]%}%/%{$reset_color%} $(git_prompt_info) %(!.#.$) ' +PROMPT='%{$fg[cyan]%}%n%{$reset_color%}@%{$fg[yellow]%}%M:%{$fg[green]%}%/%{$reset_color%} $GIT_PROMPT_INFO %(!.#.$) ' ZSH_THEME_GIT_PROMPT_PREFIX=" %{$fg[cyan]%}git:(" ZSH_THEME_GIT_PROMPT_SUFFIX=")%{$reset_color%}" diff --git a/themes/mgutz.zsh-theme b/themes/mgutz.zsh-theme index dcf327041..b3fb8767e 100644 --- a/themes/mgutz.zsh-theme +++ b/themes/mgutz.zsh-theme @@ -1,4 +1,4 @@ -PROMPT='%{$fg_bold[magenta]%}%1~$(git_prompt_info) %{$fg_bold[magenta]%}%# %{$reset_color%}' +PROMPT='%{$fg_bold[magenta]%}%1~$GIT_PROMPT_INFO %{$fg_bold[magenta]%}%# %{$reset_color%}' ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[yellow]%}[" ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" diff --git a/themes/mikeh.zsh-theme b/themes/mikeh.zsh-theme index 943f04d38..e611b6832 100644 --- a/themes/mikeh.zsh-theme +++ b/themes/mikeh.zsh-theme @@ -20,4 +20,4 @@ mikeh_precmd() { # 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{"%a %b %d, %I:%M"}%b$'%{\e[0;34m%}%B]%b%{\e[0m%} %{\e[0;34m%}%B..%B[%{\e[1;35m%}$%{\e[0;34m%}%B] <($vcs_info_msg_0_)>%{\e[0m%}%b ' -PS2=$' \e[0;34m%}%B>%{\e[0m%}%b ' \ No newline at end of file +PS2=$' \e[0;34m%}%B>%{\e[0m%}%b ' diff --git a/themes/minimal.zsh-theme b/themes/minimal.zsh-theme new file mode 100644 index 000000000..eb999d3cf --- /dev/null +++ b/themes/minimal.zsh-theme @@ -0,0 +1,7 @@ +ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}%{$fg[white]%}[" +ZSH_THEME_GIT_PROMPT_SUFFIX="]%{$reset_color%}" +ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}●%{$reset_color%}" +ZSH_THEME_GIT_PROMPT_CLEAN="" + + +PROMPT='%2~ $GIT_PROMPT_INFO »%b ' diff --git a/themes/mrtazz.zsh-theme b/themes/mrtazz.zsh-theme index 214ba5a47..d73e1ad7e 100644 --- a/themes/mrtazz.zsh-theme +++ b/themes/mrtazz.zsh-theme @@ -1,5 +1,5 @@ PROMPT='%{$fg_bold[red]%}%m%{$reset_color%}:%{$fg[cyan]%}%c%{$reset_color%}:%# ' -RPROMPT='%{$fg_bold[green]%}$(git_prompt_info)%{$reset_color%}% ' +RPROMPT='%{$fg_bold[green]%}$GIT_PROMPT_INFO%{$reset_color%}% ' ZSH_THEME_GIT_PROMPT_PREFIX="<%{$fg[red]%}" ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" diff --git a/themes/murilasso.zsh-theme b/themes/murilasso.zsh-theme index 310357b45..9bf5e0b24 100644 --- a/themes/murilasso.zsh-theme +++ b/themes/murilasso.zsh-theme @@ -2,7 +2,7 @@ local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})" local user_host='%{$terminfo[bold]$fg[green]%}%n@%m%{$reset_color%}' local current_dir='%{$terminfo[bold]$fg[blue]%}%~%{$reset_color%}' local rvm_ruby='%{$fg[red]%}$(rvm_prompt_info)%{$reset_color%}' -local git_branch='%{$fg[blue]%}$(git_prompt_info)%{$reset_color%}' +local git_branch='%{$fg[blue]%}$GIT_PROMPT_INFO%{$reset_color%}' PROMPT="${user_host}:${current_dir} ${rvm_ruby} ${git_branch} %B$%b " diff --git a/themes/muse.zsh-theme b/themes/muse.zsh-theme index 4bd8fb825..452a6bb05 100644 --- a/themes/muse.zsh-theme +++ b/themes/muse.zsh-theme @@ -1,30 +1,71 @@ #!/usr/bin/env zsh -#local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})" +local R="%{$terminfo[sgr0]%}" +#local return_code="%(?..%{$fg[red]%}%? ↵$R)" setopt promptsubst autoload -U add-zsh-hook -PROMPT_SUCCESS_COLOR=$FG[117] PROMPT_FAILURE_COLOR=$FG[124] PROMPT_VCS_INFO_COLOR=$FG[242] PROMPT_PROMPT=$FG[077] GIT_DIRTY_COLOR=$FG[133] GIT_CLEAN_COLOR=$FG[118] -GIT_PROMPT_INFO=$FG[012] +GIT_PROMPT_DEFAULT=$FG[012] -PROMPT='%{$PROMPT_SUCCESS_COLOR%}%~%{$reset_color%} %{$GIT_PROMPT_INFO%}$(git_prompt_info)%{$GIT_DIRTY_COLOR%}$(git_prompt_status) %{$reset_color%}%{$PROMPT_PROMPT%}ᐅ%{$reset_color%} ' +PROMPT='%{$FG[117]%}%~ $GIT_PROMPT_INFO $R%{$PROMPT_PROMPT%}ᐅ$R ' #RPS1="${return_code}" -ZSH_THEME_GIT_PROMPT_PREFIX="(" -ZSH_THEME_GIT_PROMPT_SUFFIX="%{$GIT_PROMPT_INFO%})" -ZSH_THEME_GIT_PROMPT_DIRTY=" %{$GIT_DIRTY_COLOR%}✘" -ZSH_THEME_GIT_PROMPT_CLEAN=" %{$GIT_CLEAN_COLOR%}✔" +git_prompt_info () +{ + if [ -z "$(git_prompt__git_dir)" ]; then + GIT_PROMPT_INFO='' + GIT_RPROMPT_INFO='' + return + fi -ZSH_THEME_GIT_PROMPT_ADDED="%{$FG[082]%}✚%{$reset_color%}" -ZSH_THEME_GIT_PROMPT_MODIFIED="%{$FG[166]%}✹%{$reset_color%}" -ZSH_THEME_GIT_PROMPT_DELETED="%{$FG[160]%}✖%{$reset_color%}" -ZSH_THEME_GIT_PROMPT_RENAMED="%{$FG[220]%}➜%{$reset_color%}" -ZSH_THEME_GIT_PROMPT_UNMERGED="%{$FG[082]%}═%{$reset_color%}" -ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$FG[190]%}✭%{$reset_color%}" + local branch='' + + git_prompt__branch + branch="$GIT_PROMPT_BRANCH" + + git_prompt__rebase_info + branch="${branch}$GIT_PROMPT_REBASE_INFO" + + local dirty='' + git_prompt__dirty_state + if [[ "$GIT_PROMPT_DIRTY_STATE_ANY_DIRTY" = 'yes' ]]; then + dirty=" %{$GIT_DIRTY_COLOR%}✘" + else + dirty=" %{$GIT_CLEAN_COLOR%}✔" + fi + + local prompt="($R%{${branch}${dirty}${FG[012]})" + + if [[ "$GIT_PROMPT_DIRTY_STATE_INDEX_ADDED" = 'yes' ]]; then + prompt="${prompt}${FG[082]}✚" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_INDEX_MODIFIED" = 'yes' ]]; then + prompt="${prompt}${FG[166]}✹" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_WORKTREE_MODIFIED" = 'yes' ]]; then + prompt="${prompt}${FG[166]}✹" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_INDEX_DELETED" = 'yes' ]]; then + prompt="${prompt}${FG[160]}✖" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_WORKTREE_DELETED" = 'yes' ]]; then + prompt="${prompt}${FG[160]}✖" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_INDEX_RENAMED" = 'yes' ]]; then + prompt="${prompt}${FG[220]}➜" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_INDEX_UNMERGED" = 'yes' ]]; then + prompt="${prompt}${FG[082]}═" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_WORKTREE_UNTRACKED" = 'yes' ]]; then + prompt="${prompt}${FG[90]}✭" + fi + GIT_PROMPT_INFO="$prompt$R" +} diff --git a/themes/nanotech.zsh-theme b/themes/nanotech.zsh-theme index 5d3331639..4bd1e876a 100644 --- a/themes/nanotech.zsh-theme +++ b/themes/nanotech.zsh-theme @@ -1,5 +1,5 @@ PROMPT='%F{green}%2c%F{blue} [%f ' -RPROMPT='$(git_prompt_info) %F{blue}] %F{green}%D{%L:%M} %F{yellow}%D{%p}%f' +RPROMPT='$GIT_PROMPT_INFO %F{blue}] %F{green}%D{%L:%M} %F{yellow}%D{%p}%f' ZSH_THEME_GIT_PROMPT_PREFIX="%F{yellow}" ZSH_THEME_GIT_PROMPT_SUFFIX="%f" diff --git a/themes/obraun.zsh-theme b/themes/obraun.zsh-theme new file mode 100644 index 000000000..096fc470e --- /dev/null +++ b/themes/obraun.zsh-theme @@ -0,0 +1,11 @@ +if [ "$(whoami)" = "root" ]; then CARETCOLOR="red"; else CARETCOLOR="blue"; fi + +local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})" + +PROMPT='%{$fg[green]%}[%*]%{$reset_color%} %{$fg_no_bold[cyan]%}%n %{${fg_bold[blue]}%}::%{$reset_color%} %{$fg[yellow]%}%m%{$reset_color%} %{$fg_no_bold[magenta]%} ➜ %{$reset_color%} %{${fg[green]}%}%3~ $GIT_PROMPT_INFO%{${fg_bold[$CARETCOLOR]}%}»%{${reset_color}%} ' + +RPS1="${return_code}" + +ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[red]%}‹" +ZSH_THEME_GIT_PROMPT_SUFFIX="› %{$reset_color%}" + diff --git a/themes/philips.zsh-theme b/themes/philips.zsh-theme index e7ea51a2f..86c682e81 100644 --- a/themes/philips.zsh-theme +++ b/themes/philips.zsh-theme @@ -1,6 +1,6 @@ if [ $UID -eq 0 ]; then NCOLOR="red"; else NCOLOR="green"; fi -PROMPT='%{$fg[$NCOLOR]%}%B%n%b%{$reset_color%}:%{$fg[blue]%}%B%c/%b%{$reset_color%} $(git_prompt_info)%(!.#.$) ' +PROMPT='%{$fg[$NCOLOR]%}%B%n%b%{$reset_color%}:%{$fg[blue]%}%B%c/%b%{$reset_color%} $GIT_PROMPT_INFO%(!.#.$) ' RPROMPT='[%*]' # git theming diff --git a/themes/pmcgee.zsh-theme b/themes/pmcgee.zsh-theme index e4e45c71a..ded6c2fc8 100644 --- a/themes/pmcgee.zsh-theme +++ b/themes/pmcgee.zsh-theme @@ -2,7 +2,7 @@ if [ $UID -eq 0 ]; then NCOLOR="red"; else NCOLOR="green"; fi PROMPT=' %{$fg[$NCOLOR]%}%B%n@%m%b%{$reset_color%} %{$fg[white]%}%B${PWD/#$HOME/~}%b%{$reset_color%} -$(git_prompt_info)%(!.#.$) ' +$GIT_PROMPT_INFO%(!.#.$) ' RPROMPT='[%*]' # git theming diff --git a/themes/re5et.zsh-theme b/themes/re5et.zsh-theme new file mode 100644 index 000000000..36b98a28a --- /dev/null +++ b/themes/re5et.zsh-theme @@ -0,0 +1,45 @@ +if [ "$(whoami)" = "root" ]; then CARETCOLOR="red"; else CARETCOLOR="magenta"; fi + +local return_code="%(?..%{$fg_bold[red]%}:( %?%{$reset_color%})" + +PROMPT=' +%{$fg_bold[cyan]%}%n%{$reset_color%}%{$fg[yellow]%}@%{$reset_color%}%{$fg_bold[blue]%}%m%{$reset_color%}:%{${fg_bold[green]}%}%~%{$reset_color%}$GIT_PROMPT_INFO +%{${fg[$CARETCOLOR]}%}%# %{${reset_color}%}' + +RPS1='${return_code} %D - %*' + +ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[magenta]%}^%{$reset_color%}%{$fg_bold[yellow]%}" +ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" +ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg_bold[red]%} ±" +ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[cyan]%} ?" +ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg_bold[red]%} ♥" + +git_prompt_info () +{ + if [ -z "$(git_prompt__git_dir)" ]; then + GIT_PROMPT_INFO='' + return + fi + + local prompt="" + git_prompt__branch + prompt=$GIT_PROMPT_BRANCH + + git_prompt__rebase_info + prompt="${prompt}$GIT_PROMPT_REBASE_INFO" + + if [[ -n "$prompt" ]]; then + git_prompt__dirty_state + if [[ "$GIT_PROMPT_DIRTY_STATE_ANY_DIRTY" = 'yes' ]]; then + prompt="$prompt%{$fg_bold[red]%}±" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_WORKTREE_UNTRACKED" = 'yes' ]]; then + prompt="$prompt%{$fg[cyan]%}?" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_ANY_DIRTY" = 'no' ]]; then + prompt="$prompt%{$fg_bold[red]%}♥" + fi + + GIT_PROMPT_INFO="%{$fg_bold[magenta]%}^%{$reset_color%}%{$fg_bold[yellow]%}$prompt%{$reset_color%}" + fi +} diff --git a/themes/rgm.zsh-theme b/themes/rgm.zsh-theme index 9452a8b0d..7a50c2386 100644 --- a/themes/rgm.zsh-theme +++ b/themes/rgm.zsh-theme @@ -1,6 +1,6 @@ PROMPT=' %n@%m %{$fg[cyan]%}%~ -%? $(git_prompt_info)%{$fg_bold[blue]%}%% %{$reset_color%}' +%? $GIT_PROMPT_INFO%{$fg_bold[blue]%}%% %{$reset_color%}' ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[red]%}" ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} " diff --git a/themes/risto.zsh-theme b/themes/risto.zsh-theme index cb773a64e..480899f1e 100644 --- a/themes/risto.zsh-theme +++ b/themes/risto.zsh-theme @@ -1,6 +1,6 @@ # -*- sh -*- vim:set ft=sh ai et sw=4 sts=4: # It might be bash like, but I can't have my co-workers knowing I use zsh -PROMPT='%{$fg[green]%}%n@%m:%{$fg_bold[blue]%}%2~ $(git_prompt_info)%{$reset_color%}%(!.#.$) ' +PROMPT='%{$fg[green]%}%n@%m:%{$fg_bold[blue]%}%2~ $GIT_PROMPT_INFO%{$reset_color%}%(!.#.$) ' ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[red]%}‹" ZSH_THEME_GIT_PROMPT_SUFFIX="›%{$reset_color%}" diff --git a/themes/rixius.zsh-theme b/themes/rixius.zsh-theme index c0c5c9c71..78b54c6dd 100644 --- a/themes/rixius.zsh-theme +++ b/themes/rixius.zsh-theme @@ -1,6 +1,6 @@ # /|/ Code by Stephen # /|/ "Rixius" Middleton -# +# # name in folder (github) # ± if in github repo, or ≥ if otherwise Time in 24-hour format is on right. function collapse_pwd { @@ -14,7 +14,7 @@ function prompt_char { RIXIUS_PRE="%{$bg[white]%}%{$fg[red]%}" PROMPT=' -%{$RIXIUS_PRE%}%n%{$reset_color%} in %{$fg_bold[green]%}$(collapse_pwd)%{$reset_color%}$(git_prompt_info) +%{$RIXIUS_PRE%}%n%{$reset_color%} in %{$fg_bold[green]%}$(collapse_pwd)%{$reset_color%}$GIT_PROMPT_INFO $(prompt_char) ' RPROMPT='%{$RIXIUS_PRE%}%T%{$reset_color%}' diff --git a/themes/robbyrussell.zsh-theme b/themes/robbyrussell.zsh-theme index 7b524e82d..4dcb77026 100644 --- a/themes/robbyrussell.zsh-theme +++ b/themes/robbyrussell.zsh-theme @@ -1,4 +1,4 @@ -PROMPT='%{$fg_bold[red]%}➜ %{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}' +PROMPT='%{$fg_bold[red]%}➜ %{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$GIT_PROMPT_INFO%{$fg_bold[blue]%} % %{$reset_color%}' ZSH_THEME_GIT_PROMPT_PREFIX="git:(%{$fg[red]%}" ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" diff --git a/themes/simple.zsh-theme b/themes/simple.zsh-theme new file mode 100644 index 000000000..d345a9f9b --- /dev/null +++ b/themes/simple.zsh-theme @@ -0,0 +1,6 @@ +PROMPT='%{$fg[green]%}%~%{$fg_bold[blue]%}$GIT_PROMPT_INFO%{$reset_color%} ' + +ZSH_THEME_GIT_PROMPT_PREFIX="(" +ZSH_THEME_GIT_PROMPT_SUFFIX=")" +ZSH_THEME_GIT_PROMPT_DIRTY=" ✗" +ZSH_THEME_GIT_PROMPT_CLEAN=" ✔" diff --git a/themes/skaro.zsh-theme b/themes/skaro.zsh-theme index 84b7b11b0..9d8dd151d 100644 --- a/themes/skaro.zsh-theme +++ b/themes/skaro.zsh-theme @@ -1,4 +1,4 @@ -PROMPT='%{$fg_bold[green]%}%h %{$fg[cyan]%}%2~ %{$fg_bold[blue]%}$(git_prompt_info) %{$reset_color%}» ' +PROMPT='%{$fg_bold[green]%}%h %{$fg[cyan]%}%2~ %{$fg_bold[blue]%}$GIT_PROMPT_INFO %{$reset_color%}» ' ZSH_THEME_GIT_PROMPT_PREFIX="git:(%{$fg[red]%}" ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" diff --git a/themes/sorin.zsh-theme b/themes/sorin.zsh-theme index 33ca9c1e2..bd64866c6 100644 --- a/themes/sorin.zsh-theme +++ b/themes/sorin.zsh-theme @@ -2,47 +2,72 @@ # FILE: sorin.zsh-theme # DESCRIPTION: oh-my-zsh theme file. # AUTHOR: Sorin Ionescu (sorin.ionescu@gmail.com) -# VERSION: 1.0.3 +# VERSION: 1.0.4 # SCREENSHOT: http://i.imgur.com/aipDQ.png # ------------------------------------------------------------------------------ -if [[ "$DISABLE_COLOR" != "true" ]]; then - MODE_INDICATOR="%{$fg_bold[red]%}❮%{$reset_color%}%{$fg[red]%}❮❮%{$reset_color%}" - local return_status="%{$fg[red]%}%(?..⏎)%{$reset_color%}" - - PROMPT='%{$fg[cyan]%}%c$(git_prompt_info) %(!.%{$fg_bold[red]%}#.%{$fg_bold[green]%}❯)%{$reset_color%} ' - - ZSH_THEME_GIT_PROMPT_PREFIX=" %{$fg[blue]%}git%{$reset_color%}:%{$fg[red]%}" - ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" - ZSH_THEME_GIT_PROMPT_DIRTY="" - ZSH_THEME_GIT_PROMPT_CLEAN="" - - RPROMPT='${return_status}$(git_prompt_status)%{$reset_color%}' - - ZSH_THEME_GIT_PROMPT_ADDED="%{$fg[green]%} ✚" - ZSH_THEME_GIT_PROMPT_MODIFIED="%{$fg[blue]%} ✹" - ZSH_THEME_GIT_PROMPT_DELETED="%{$fg[red]%} ✖" - ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg[magenta]%} ➜" - ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg[yellow]%} ═" - ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[cyan]%} ✭" -else - MODE_INDICATOR="❮❮❮" - local return_status="%(?::⏎)" - - PROMPT='%c$(git_prompt_info) %(!.#.❯) ' - - ZSH_THEME_GIT_PROMPT_PREFIX=" git:" - ZSH_THEME_GIT_PROMPT_SUFFIX="" - ZSH_THEME_GIT_PROMPT_DIRTY="" - ZSH_THEME_GIT_PROMPT_CLEAN="" - - RPROMPT='${return_status}$(git_prompt_status)' - - ZSH_THEME_GIT_PROMPT_ADDED=" ✚" - ZSH_THEME_GIT_PROMPT_MODIFIED=" ✹" - ZSH_THEME_GIT_PROMPT_DELETED=" ✖" - ZSH_THEME_GIT_PROMPT_RENAMED=" ➜" - ZSH_THEME_GIT_PROMPT_UNMERGED=" ═" - ZSH_THEME_GIT_PROMPT_UNTRACKED=" ✭" +if [[ "$DISABLE_COLORS" != "true" ]]; then + local R="%{$terminfo[sgr0]%}" + local MAGENTA="%{$fg[magenta]%}" + local YELLOW="%{$fg[yellow]%}" + local GREEN="%{$fg[green]%}" + local B_GREEN="%{$fg_bold[green]%}" + local BLUE="%{$fg[blue]%}" + local CYAN="%{$fg[cyan]%}" + local RED="%{$fg[red]%}" + local B_RED="%{$fg_bold[red]%}" fi + +MODE_INDICATOR="$B_RED❮$R$RED❮❮$R" +local return_status="$RED%(?..⏎)$R" + +PROMPT='$CYAN%c$GIT_PROMPT_INFO %(!.$B_RED#.$B_GREEN❯)$R ' +RPROMPT='${return_status}$GIT_RPROMPT_INFO$R' + +git_prompt_info () +{ + if [ -z "$(git_prompt__git_dir)" ]; then + GIT_PROMPT_INFO='' + GIT_RPROMPT_INFO='' + return + fi + + local branch='' + + git_prompt__branch + branch="$GIT_PROMPT_BRANCH" + + git_prompt__rebase_info + branch="${branch}$GIT_PROMPT_REBASE_INFO" + + GIT_PROMPT_INFO=" ${BLUE}git$R:$RED${branch}$R" + + local rprompt='' + git_prompt__dirty_state + if [[ "$GIT_PROMPT_DIRTY_STATE_INDEX_ADDED" = 'yes' ]]; then + rprompt="$GREEN ✚" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_INDEX_MODIFIED" = 'yes' ]]; then + rprompt="${rprompt}$BLUE ✹" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_WORKTREE_MODIFIED" = 'yes' ]]; then + rprompt="${rprompt}$BLUE ✹" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_INDEX_DELETED" = 'yes' ]]; then + rprompt="${rprompt}$RED ✖" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_WORKTREE_DELETED" = 'yes' ]]; then + rprompt="${rprompt}$RED ✖" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_INDEX_RENAMED" = 'yes' ]]; then + rprompt="${rprompt}$MAGENTA ➜" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_INDEX_UNMERGED" = 'yes' ]]; then + rprompt="${rprompt}$YELLOW ═" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_WORKTREE_UNTRACKED" = 'yes' ]]; then + rprompt="${rprompt}$CYAN ✭" + fi + GIT_RPROMPT_INFO=$rprompt +} diff --git a/themes/sporty_256.zsh-theme b/themes/sporty_256.zsh-theme index db0fc4277..368c96139 100644 --- a/themes/sporty_256.zsh-theme +++ b/themes/sporty_256.zsh-theme @@ -3,7 +3,7 @@ # Preview - http://www.flickr.com/photos/adelcampo/4556482563/sizes/o/ # based on robbyrussell's shell but louder! -PROMPT='%{$fg_bold[blue]%}$(git_prompt_info) %F{208}%c%f +PROMPT='%{$fg_bold[blue]%}$GIT_PROMPT_INFO %F{208}%c%f %{$fg_bold[white]%}%# %{$reset_color%}' RPROMPT='%B%F{208}%n%f%{$fg_bold[white]%}@%F{039}%m%f%{$reset_color%}' diff --git a/themes/steeef.zsh-theme b/themes/steeef.zsh-theme new file mode 100644 index 000000000..a2583b028 --- /dev/null +++ b/themes/steeef.zsh-theme @@ -0,0 +1,100 @@ +# 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="(%{$turquoise%}%b%u%c${PR_RST})" +FMT_ACTION="(%{$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="(%{$turquoise%}%b%u%c%{$hotpink%}●${PR_RST})" + else + FMT_BRANCH="(%{$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%} at %{$orange%}%m%{$reset_color%} in %{$limegreen%}%~%{$reset_color%} $vcs_info_msg_0_ +$(virtualenv_info)$ ' diff --git a/themes/takashiyoshida.zsh-theme b/themes/takashiyoshida.zsh-theme index 419a8cf3f..d2ab18907 100644 --- a/themes/takashiyoshida.zsh-theme +++ b/themes/takashiyoshida.zsh-theme @@ -10,8 +10,6 @@ PROMPT_BRACKET_END='%{$fg_bold[white]%}]' PROMPT_USER='%{$fg_bold[white]%}%n' PROMPT_SIGN='%{$reset_color%}%#' -GIT_PROMPT_INFO='$(git_prompt_info)' - # My current prompt looks like: # [host:current_dir] (git_prompt_info) # [username]% diff --git a/themes/theunraveler.zsh-theme b/themes/theunraveler.zsh-theme index e4bfb79c5..765086376 100644 --- a/themes/theunraveler.zsh-theme +++ b/themes/theunraveler.zsh-theme @@ -1,16 +1,49 @@ -# Comment - PROMPT='%{$fg[magenta]%}[%c] %{$reset_color%}' +RPROMPT='%{$fg[magenta]%}$GIT_PROMPT_INFO%{$reset_color%} $GIT_RPROMPT_INFO%{$reset_color%}' -RPROMPT='%{$fg[magenta]%}$(git_prompt_info)%{$reset_color%} $(git_prompt_status)%{$reset_color%}' +git_prompt_info () +{ + if [ -z "$(git_prompt__git_dir)" ]; then + GIT_PROMPT_INFO='' + GIT_RPROMPT_INFO='' + return + fi -ZSH_THEME_GIT_PROMPT_PREFIX="" -ZSH_THEME_GIT_PROMPT_SUFFIX="" -ZSH_THEME_GIT_PROMPT_DIRTY="" -ZSH_THEME_GIT_PROMPT_CLEAN="" -ZSH_THEME_GIT_PROMPT_ADDED="%{$fg[cyan]%} ✈" -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[magenta]%} ✂" -ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[grey]%} ✱" \ No newline at end of file + local prompt='' + + git_prompt__branch + prompt="$GIT_PROMPT_BRANCH" + + git_prompt__rebase_info + prompt="${prompt}$GIT_PROMPT_REBASE_INFO" + + GIT_PROMPT_INFO="$prompt" + + local rprompt='' + git_prompt__dirty_state + if [[ "$GIT_PROMPT_DIRTY_STATE_INDEX_ADDED" = 'yes' ]]; then + rprompt="%{$fg[cyan]%} ✈" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_INDEX_MODIFIED" = 'yes' ]]; then + rprompt="${rprompt}%{$fg[yellow]%} ✭" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_WORKTREE_MODIFIED" = 'yes' ]]; then + rprompt="${rprompt}%{$fg[yellow]%} ✭" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_INDEX_DELETED" = 'yes' ]]; then + rprompt="${rprompt}%{$fg[red]%} ✗" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_WORKTREE_DELETED" = 'yes' ]]; then + rprompt="${rprompt}%{$fg[red]%} ✗" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_INDEX_RENAMED" = 'yes' ]]; then + rprompt="${rprompt}%{$fg[blue]%} ➦" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_INDEX_UNMERGED" = 'yes' ]]; then + rprompt="${rprompt}%{$fg[magenta]%} ✂" + fi + if [[ "$GIT_PROMPT_DIRTY_STATE_WORKTREE_UNTRACKED" = 'yes' ]]; then + rprompt="${rprompt}%{$fg[grey]%} ✱" + fi + GIT_RPROMPT_INFO=$rprompt +} diff --git a/themes/thomasjbradley.zsh-theme b/themes/thomasjbradley.zsh-theme index 857301d19..a2c6a25c6 100644 --- a/themes/thomasjbradley.zsh-theme +++ b/themes/thomasjbradley.zsh-theme @@ -17,7 +17,7 @@ patches: +# +# This theme needs a terminal supporting 256 colors as well as unicode. It also +# needs the script that splits up the current path and makes it fancy as located +# here: https://github.com/trapd00r/utils/blob/master/zsh_path +# +# By default it spans over two lines like so: +# +# scp1@shiva:pts/9-> /home » scp1 (0) +# > +# +# that's user@host:pts/-> splitted path (return status) +# +# If the current directory is a git repository, we span 3 lines; +# +# git❨ master ❩ DIRTY +# scp1@shiva:pts/4-> /home » scp1 » dev » utils (0) +# > + +autoload -U add-zsh-hook +autoload -Uz vcs_info + +local c0=$( printf "\e[m") +local c1=$( printf "\e[38;5;245m") +local c2=$( printf "\e[38;5;250m") +local c3=$( printf "\e[38;5;242m") +local c4=$( printf "\e[38;5;197m") +local c5=$( printf "\e[38;5;225m") +local c6=$( printf "\e[38;5;240m") +local c7=$( printf "\e[38;5;242m") +local c8=$( printf "\e[38;5;244m") +local c9=$( printf "\e[38;5;162m") +local c10=$(printf "\e[1m") +local c11=$(printf "\e[38;5;208m\e[1m") +local c12=$(printf "\e[38;5;142m\e[1m") +local c13=$(printf "\e[38;5;196m\e[1m") + + +# We dont want to use the extended colorset in the TTY / VC. +if [ "$TERM" = "linux" ]; then + c1=$( printf "\e[34;1m") + c2=$( printf "\e[35m") + c3=$( printf "\e[31m") + c4=$( printf "\e[31;1m") + c5=$( printf "\e[32m") + c6=$( printf "\e[32;1m") + c7=$( printf "\e[33m") + c8=$( printf "\e[33;1m") + c9=$( printf "\e[34m") + + c11=$(printf "\e[35;1m") + c12=$(printf "\e[36m") + c13=$(printf "\e[31;1m") +fi + +zstyle ':vcs_info:*' actionformats \ + '%{$c8%}(%f%s)%{$c7%}-%F{5}[%F{2}%b%F{3}|%F{1}%a%F{5}]%f ' + +zstyle ':vcs_info:*' formats \ + "%{$c8%}%s%%{$c7%}❨ %{$c9%}%{$c11%}%b%{$c7%} ❩%{$reset_color%}%f " + +zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b%F{1}:%F{3}%r' +zstyle ':vcs_info:*' enable git + +add-zsh-hook precmd prompt_jnrowe_precmd + +prompt_jnrowe_precmd () { + vcs_info + if [ "${vcs_info_msg_0_}" = "" ]; then + dir_status="%{$c1%}%n%{$c4%}@%{$c2%}%m%{$c0%}:%{$c3%}%l%{$c6%}->%{$(zsh_path)%} %{$c0%}(%{$c5%}%?%{$c0%})" + PROMPT='%{$fg_bold[green]%}%p%{$reset_color%}${vcs_info_msg_0_}${dir_status} ${ret_status}%{$reset_color%} +> ' + +# modified, to be commited + elif [[ $(git diff --cached --name-status 2>/dev/null ) != "" ]]; then + dir_status="%{$c1%}%n%{$c4%}@%{$c2%}%m%{$c0%}:%{$c3%}%l%{$c6%}->%{$(zsh_path)%} %{$c0%}(%{$c5%}%?%{$c0%})" + PROMPT='${vcs_info_msg_0_}%{$30%} %{$bg_bold[red]%}%{$fg_bold[cyan]%}C%{$fg_bold[black]%}OMMIT%{$reset_color%} +%{$fg_bold[green]%}%p%{$reset_color%}${dir_status}%{$reset_color%} +> ' + + elif [[ $(git diff --name-status 2>/dev/null ) != "" ]]; then + dir_status="%{$c1%}%n%{$c4%}@%{$c2%}%m%{$c0%}:%{$c3%}%l%{$c6%}->%{$(zsh_path)%} %{$c0%}(%{$c5%}%?%{$c0%})" + PROMPT='${vcs_info_msg_0_}%{$bg_bold[red]%}%{$fg_bold[blue]%}D%{$fg_bold[black]%}IRTY%{$reset_color%} +%{$fg_bold[green]%}%p%{$reset_color%}${dir_status}%{$reset_color%} +%{$c13%}>%{$c0%} ' + else + dir_status="%{$c1%}%n%{$c4%}@%{$c2%}%m%{$c0%}:%{$c3%}%l%{$c6%}->%{$(zsh_path)%} %{$c0%}(%{$c5%}%?%{$c0%})" + PROMPT='${vcs_info_msg_0_} +%{$fg_bold[green]%}%p%{$reset_color%}${dir_status} ${vcs_info_msg_0_}%{$reset_color%} +> ' +fi +} + +# vim: set ft=zsh sw=2 et tw=0: diff --git a/themes/wezm+.zsh-theme b/themes/wezm+.zsh-theme index fee3eb08e..2bc7159bc 100644 --- a/themes/wezm+.zsh-theme +++ b/themes/wezm+.zsh-theme @@ -1,4 +1,4 @@ -PROMPT='%{${fg_bold[yellow]}%}%n%{$reset_color%}%{${fg[yellow]}%}@%m%{$reset_color%} $(git_prompt_info)%(?,,%{${fg_bold[white]}%}[%?]%{$reset_color%} )%{$fg[yellow]%}%#%{$reset_color%} ' +PROMPT='%{${fg_bold[yellow]}%}%n%{$reset_color%}%{${fg[yellow]}%}@%m%{$reset_color%} $GIT_PROMPT_INFO%(?,,%{${fg_bold[white]}%}[%?]%{$reset_color%} )%{$fg[yellow]%}%#%{$reset_color%} ' RPROMPT='%{$fg[green]%}%~%{$reset_color%}' ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[blue]%}(" diff --git a/themes/wezm.zsh-theme b/themes/wezm.zsh-theme index 1881343b0..57573fe71 100644 --- a/themes/wezm.zsh-theme +++ b/themes/wezm.zsh-theme @@ -1,4 +1,4 @@ -PROMPT='$(git_prompt_info)%(?,,%{${fg_bold[white]}%}[%?]%{$reset_color%} )%{$fg[yellow]%}%#%{$reset_color%} ' +PROMPT='$GIT_PROMPT_INFO%(?,,%{${fg_bold[white]}%}[%?]%{$reset_color%} )%{$fg[yellow]%}%#%{$reset_color%} ' RPROMPT='%{$fg[green]%}%~%{$reset_color%}' ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[blue]%}(" diff --git a/themes/xiong-chiamiov-plus.zsh-theme b/themes/xiong-chiamiov-plus.zsh-theme index 095dae290..53e5d01f5 100644 --- a/themes/xiong-chiamiov-plus.zsh-theme +++ b/themes/xiong-chiamiov-plus.zsh-theme @@ -2,5 +2,5 @@ # on two lines for easier vgrepping # 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{"%a %b %d, %I:%M"}%b$'%{\e[0;34m%}%B]%b%{\e[0m%} -%{\e[0;34m%}%B└─%B[%{\e[1;35m%}$%{\e[0;34m%}%B] <$(git_prompt_info)>%{\e[0m%}%b ' +%{\e[0;34m%}%B└─%B[%{\e[1;35m%}$%{\e[0;34m%}%B] <$GIT_PROMPT_INFO>%{\e[0m%}%b ' PS2=$' \e[0;34m%}%B>%{\e[0m%}%b ' diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh deleted file mode 100644 index e1e4eb99f..000000000 --- a/tools/check_for_upgrade.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh - -function _current_epoch() { - echo $(($(date +%s) / 60 / 60 / 24)) -} - -function _update_zsh_update() { - echo "LAST_EPOCH=$(_current_epoch)" > ~/.zsh-update -} - -if [ -f ~/.zsh-update ] -then - . ~/.zsh-update - - if [[ -z "$LAST_EPOCH" ]]; then - _update_zsh_update && return 0; - fi - - epoch_diff=$(($(_current_epoch) - $LAST_EPOCH)) - if [ $epoch_diff -gt 6 ] - then - echo "[Oh My Zsh] Would you like to check for updates?" - echo "Type Y to update oh-my-zsh: \c" - read line - if [ "$line" = Y ] || [ "$line" = y ] - then - /bin/sh $ZSH/tools/upgrade.sh - # update the zsh file - _update_zsh_update - fi - fi -else - # create the zsh file - _update_zsh_update -fi diff --git a/tools/install.sh b/tools/install.sh deleted file mode 100755 index 8ed1403af..000000000 --- a/tools/install.sh +++ /dev/null @@ -1,36 +0,0 @@ -if [ -d ~/.oh-my-zsh ] -then - echo "You already have Oh My Zsh installed. You'll need to remove ~/.oh-my-zsh if you want to install" - exit -fi - -echo "Cloning Oh My Zsh..." -/usr/bin/env git clone https://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh - -echo "Looking for an existing zsh config..." -if [ -f ~/.zshrc ] || [ -h ~/.zshrc ] -then - echo "Found ~/.zshrc. Backing up to ~/.zshrc.pre-oh-my-zsh"; - cp ~/.zshrc ~/.zshrc.pre-oh-my-zsh; - rm ~/.zshrc; -fi - -echo "Using the Oh My Zsh template file and adding it to ~/.zshrc" -cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc - -echo "Copying your current PATH and adding it to the end of ~/.zshrc for you." -echo "export PATH=$PATH" >> ~/.zshrc - -echo "Time to change your default shell to zsh!" -chsh -s `which zsh` - -echo ' __ __ ' -echo ' ____ / /_ ____ ___ __ __ ____ _____/ /_ ' -echo ' / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ ' -echo '/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / ' -echo '\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ ' -echo ' /____/' - -echo "\n\n ....is now installed." -/usr/bin/env zsh -source ~/.zshrc diff --git a/tools/uninstall.sh b/tools/uninstall.sh deleted file mode 100644 index 8ff583322..000000000 --- a/tools/uninstall.sh +++ /dev/null @@ -1,20 +0,0 @@ -echo "Removing ~/.oh-my-zsh" -if [[ -d ~/.oh-my-zsh ]] -then - rm -rf ~/.oh-my-zsh -fi - -echo "Looking for an existing zsh config..." -if [ -f ~/.zshrc.pre-oh-my-zsh ] || [ -h ~/.zshrc.pre-oh-my-zsh ] -then - echo "Found ~/.zshrc. Backing up to ~/.zshrc.pre-oh-my-zsh"; - rm ~/.zshrc; - cp ~/.zshrc.pre-oh-my-zsh ~/.zshrc; - source ~/.zshrc; -else - echo "Switching back to bash" - chsh -s /bin/bash - source /etc/profile -fi - -echo "Thanks for trying out Oh My Zsh. It's been uninstalled." \ No newline at end of file diff --git a/tools/upgrade.sh b/tools/upgrade.sh deleted file mode 100644 index 6bdd02e38..000000000 --- a/tools/upgrade.sh +++ /dev/null @@ -1,12 +0,0 @@ -current_path=`pwd` -echo "Upgrading Oh My Zsh" -( cd $ZSH && git pull origin master ) -echo ' __ __ ' -echo ' ____ / /_ ____ ___ __ __ ____ _____/ /_ ' -echo ' / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ ' -echo '/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / ' -echo '\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ ' -echo ' /____/' -echo "Hooray! Oh My Zsh has been updated and/or is at the current version. \nAny new updates will be reflected when you start your next terminal session." -echo "To keep up on the latest, be sure to follow Oh My Zsh on twitter: http://twitter.com/ohmyzsh" -cd $current_path \ No newline at end of file