pull/945/merge
Andrew Miller 2017-05-29 07:03:41 +00:00 committed by GitHub
commit 1e56d9489b
13 changed files with 60 additions and 52 deletions

View File

@ -534,12 +534,12 @@ _docker_compose() {
case "${words[$counter]}" in case "${words[$counter]}" in
$(__docker_compose_to_extglob "$daemon_boolean_options") ) $(__docker_compose_to_extglob "$daemon_boolean_options") )
local opt=${words[counter]} local opt=${words[counter]}
daemon_options+=($opt) daemon_options=(${daemon_options[@]} $opt)
;; ;;
$(__docker_compose_to_extglob "$daemon_options_with_args") ) $(__docker_compose_to_extglob "$daemon_options_with_args") )
local opt=${words[counter]} local opt=${words[counter]}
local arg=${words[++counter]} local arg=${words[++counter]}
daemon_options+=($opt $arg) daemon_options=(${daemon_options[@]} $opt $arg)
;; ;;
-*) -*)
;; ;;

View File

@ -147,7 +147,7 @@ __docker_complete_containers_and_images() {
__docker_complete_containers_all __docker_complete_containers_all
local containers=( "${COMPREPLY[@]}" ) local containers=( "${COMPREPLY[@]}" )
__docker_complete_images __docker_complete_images
COMPREPLY+=( "${containers[@]}" ) COMPREPLY=( "${COMPREPLY[@]}" "${containers[@]}" )
} }
# Returns the names and optionally IDs of networks. # Returns the names and optionally IDs of networks.
@ -235,7 +235,7 @@ __docker_complete_nodes() {
__docker_complete_nodes_plus_self() { __docker_complete_nodes_plus_self() {
__docker_complete_nodes "$@" __docker_complete_nodes "$@"
COMPREPLY+=( self ) COMPREPLY=( ${COMPREPLY[@]} self )
} }
# Returns a list of all services. Additional arguments to `docker service ls` # Returns a list of all services. Additional arguments to `docker service ls`
@ -2375,7 +2375,7 @@ _docker_run() {
seccomp) seccomp)
local cur=${cur##*=} local cur=${cur##*=}
_filedir _filedir
COMPREPLY+=( $( compgen -W "unconfined" -- "$cur" ) ) COMPREPLY=( ${COMPREPLY[@]} $( compgen -W "unconfined" -- "$cur" ) )
return return
;; ;;
esac esac

View File

@ -86,7 +86,7 @@ _go()
0) 0)
_filedir go _filedir go
_go_importpath_cache _go_importpath_cache
COMPREPLY+=(`_go_importpath "$cur"`) COMPREPLY=(${COMPREPLY[@]} `_go_importpath "$cur"`)
;; ;;
1) 1)
_filedir go _filedir go

View File

@ -437,7 +437,8 @@ then
example 'pathmunge /path/to/dir is equivalent to PATH=/path/to/dir:$PATH' example 'pathmunge /path/to/dir is equivalent to PATH=/path/to/dir:$PATH'
example 'pathmunge /path/to/dir after is equivalent to PATH=$PATH:/path/to/dir' example 'pathmunge /path/to/dir after is equivalent to PATH=$PATH:/path/to/dir'
if ! [[ $PATH =~ (^|:)$1($|:) ]] ; then local re="(^|:)$1($|:)"
if ! [[ $PATH =~ $re ]] ; then
if [ "$2" = "after" ] ; then if [ "$2" = "after" ] ; then
export PATH=$PATH:$1 export PATH=$PATH:$1
else else

View File

@ -16,20 +16,27 @@ about-plugin 'Automatic completion of aliases'
function alias_completion { function alias_completion {
local namespace="alias_completion" local namespace="alias_completion"
# sed switch -E is BSD specific and only added to UNIX sed after v4.2
# fallback to -r if -E does not work
local sed_regex_switch='E'
if ! sed -${sed_regex_switch} '' /dev/null > /dev/null 2>&1; then
sed_regex_switch='r'
fi
# parse function based completion definitions, where capture group 2 => function and 3 => trigger # parse function based completion definitions, where capture group 2 => function and 3 => trigger
local compl_regex='complete( +[^ ]+)* -F ([^ ]+) ("[^"]+"|[^ ]+)' local compl_regex='complete( +[^ ]+)* -F ([^ ]+) ("[^"]+"|[^ ]+)'
# parse alias definitions, where capture group 1 => trigger, 2 => command, 3 => command arguments # parse alias definitions, where capture group 1 => trigger, 2 => command, 3 => command arguments
local alias_regex="alias( -- | )([^=]+)='(\"[^\"]+\"|[^ ]+)(( +[^ ]+)*)'" local alias_regex="alias( -- | )([^=]+)='(\"[^\"]+\"|[^ ]+)(( +[^ ]+)*)'"
# create array of function completion triggers, keeping multi-word triggers together # create array of function completion triggers, keeping multi-word triggers together
eval "local completions=($(complete -p | sed -Ene "/$compl_regex/s//'\3'/p"))" eval "local completions=($(complete -p | sed -${sed_regex_switch}ne "/$compl_regex/s//'\3'/p"))"
(( ${#completions[@]} == 0 )) && return 0 (( ${#completions[@]} == 0 )) && return 0
# create temporary file for wrapper functions and completions # create temporary file for wrapper functions and completions
rm -f "/tmp/${namespace}-*.tmp" # preliminary cleanup rm -f "/tmp/${namespace}-*.tmp" # preliminary cleanup
local tmp_file; tmp_file="$(mktemp "/tmp/${namespace}-${RANDOM}XXX.tmp")" || return 1 local tmp_file; tmp_file="$(mktemp "/tmp/${namespace}-${RANDOM}XXX.tmp")" || return 1
local completion_loader; completion_loader="$(complete -p -D 2>/dev/null | sed -Ene 's/.* -F ([^ ]*).*/\1/p')" local completion_loader; completion_loader="$(complete -p -D 2>/dev/null | sed -${sed_regex_switch}ne 's/.* -F ([^ ]*).*/\1/p')"
# read in "<alias> '<aliased command>' '<command args>'" lines from defined aliases # read in "<alias> '<aliased command>' '<command args>'" lines from defined aliases
local line; while read line; do local line; while read line; do
@ -49,7 +56,7 @@ function alias_completion {
eval "$completion_loader $alias_cmd" eval "$completion_loader $alias_cmd"
# 124 means completion loader was successful # 124 means completion loader was successful
[[ $? -eq 124 ]] || continue [[ $? -eq 124 ]] || continue
completions+=($alias_cmd) completions=(${completions[@]} $alias_cmd)
else else
continue continue
fi fi
@ -77,6 +84,6 @@ function alias_completion {
# replace completion trigger by alias # replace completion trigger by alias
new_completion="${new_completion% *} $alias_name" new_completion="${new_completion% *} $alias_name"
echo "$new_completion" >> "$tmp_file" echo "$new_completion" >> "$tmp_file"
done < <(alias -p | sed -Ene "s/$alias_regex/\2 '\3' '\4'/p") done < <(alias -p | sed -${sed_regex_switch}ne "s/$alias_regex/\2 '\3' '\4'/p")
source "$tmp_file" && rm -f "$tmp_file" source "$tmp_file" && rm -f "$tmp_file"
}; alias_completion }; alias_completion

View File

@ -34,7 +34,7 @@ fi
# with the same name in project directories # with the same name in project directories
for i in ${PROJECT_PATHS//:/$'\n'}; do for i in ${PROJECT_PATHS//:/$'\n'}; do
if [ -d "$i"/"$1" ]; then if [ -d "$i"/"$1" ]; then
dests+=("$i/$1") dests=(${dests[@]} "$i/$1")
fi fi
done done
@ -49,7 +49,7 @@ elif [ ${#dests[@]} -eq 1 ]; then
elif [ ${#dests[@]} -gt 1 ]; then elif [ ${#dests[@]} -gt 1 ]; then
PS3="Multiple project directories found. Please select one: " PS3="Multiple project directories found. Please select one: "
dests+=("cancel") dests=(${dests[@]} "cancel")
select d in "${dests[@]}"; do select d in "${dests[@]}"; do
case $d in case $d in
"cancel") "cancel")

View File

@ -149,7 +149,7 @@ function git_prompt_minimal_info {
SCM_BRANCH=${SCM_THEME_BRANCH_PREFIX}${ref} SCM_BRANCH=${SCM_THEME_BRANCH_PREFIX}${ref}
# Get the status # Get the status
[[ "${SCM_GIT_IGNORE_UNTRACKED}" = "true" ]] && git_status_flags+='-untracked-files=no' [[ "${SCM_GIT_IGNORE_UNTRACKED}" = "true" ]] && git_status_flags="${git_status_flags} -untracked-files=no"
status=$(command git status ${git_status_flags} 2> /dev/null | tail -n1) status=$(command git status ${git_status_flags} 2> /dev/null | tail -n1)
if [[ -n ${status} ]]; then if [[ -n ${status} ]]; then
@ -208,15 +208,15 @@ function git_prompt_vars {
if [[ "${untracked_count}" -gt 0 || "${unstaged_count}" -gt 0 || "${staged_count}" -gt 0 ]]; then if [[ "${untracked_count}" -gt 0 || "${unstaged_count}" -gt 0 || "${staged_count}" -gt 0 ]]; then
SCM_DIRTY=1 SCM_DIRTY=1
if [[ "${SCM_GIT_SHOW_DETAILS}" = "true" ]]; then if [[ "${SCM_GIT_SHOW_DETAILS}" = "true" ]]; then
[[ "${staged_count}" -gt 0 ]] && details+=" ${SCM_GIT_STAGED_CHAR}${staged_count}" && SCM_DIRTY=3 [[ "${staged_count}" -gt 0 ]] && details="${details} ${SCM_GIT_STAGED_CHAR}${staged_count}" && SCM_DIRTY=3
[[ "${unstaged_count}" -gt 0 ]] && details+=" ${SCM_GIT_UNSTAGED_CHAR}${unstaged_count}" && SCM_DIRTY=2 [[ "${unstaged_count}" -gt 0 ]] && details="${details} ${SCM_GIT_UNSTAGED_CHAR}${unstaged_count}" && SCM_DIRTY=2
[[ "${untracked_count}" -gt 0 ]] && details+=" ${SCM_GIT_UNTRACKED_CHAR}${untracked_count}" && SCM_DIRTY=1 [[ "${untracked_count}" -gt 0 ]] && details="${details} ${SCM_GIT_UNTRACKED_CHAR}${untracked_count}" && SCM_DIRTY=1
fi fi
SCM_STATE=${GIT_THEME_PROMPT_DIRTY:-$SCM_THEME_PROMPT_DIRTY} SCM_STATE=${GIT_THEME_PROMPT_DIRTY:-$SCM_THEME_PROMPT_DIRTY}
fi fi
fi fi
[[ "${SCM_GIT_SHOW_CURRENT_USER}" == "true" ]] && details+="$(git_user_info)" [[ "${SCM_GIT_SHOW_CURRENT_USER}" == "true" ]] && details="${details}$(git_user_info)"
SCM_CHANGE=$(git rev-parse --short HEAD 2>/dev/null) SCM_CHANGE=$(git rev-parse --short HEAD 2>/dev/null)
@ -237,15 +237,15 @@ function git_prompt_vars {
if ([[ "${SCM_GIT_SHOW_REMOTE_INFO}" = "auto" ]] && [[ "${num_remotes}" -ge 2 ]]) || if ([[ "${SCM_GIT_SHOW_REMOTE_INFO}" = "auto" ]] && [[ "${num_remotes}" -ge 2 ]]) ||
[[ "${SCM_GIT_SHOW_REMOTE_INFO}" = "true" ]]; then [[ "${SCM_GIT_SHOW_REMOTE_INFO}" = "true" ]]; then
remote_info="${remote_name}" remote_info="${remote_name}"
[[ "${same_branch_name}" != "true" ]] && remote_info+="/${remote_branch}" [[ "${same_branch_name}" != "true" ]] && remote_info="${remote_info}/${remote_branch}"
elif [[ ${same_branch_name} != "true" ]]; then elif [[ ${same_branch_name} != "true" ]]; then
remote_info="${remote_branch}" remote_info="${remote_branch}"
fi fi
if [[ -n "${remote_info}" ]];then if [[ -n "${remote_info}" ]];then
if [[ "${branch_gone}" = "true" ]]; then if [[ "${branch_gone}" = "true" ]]; then
SCM_BRANCH+="${SCM_THEME_BRANCH_GONE_PREFIX}${remote_info}" SCM_BRANCH="${SCM_BRANCH}${SCM_THEME_BRANCH_GONE_PREFIX}${remote_info}"
else else
SCM_BRANCH+="${SCM_THEME_BRANCH_TRACK_PREFIX}${remote_info}" SCM_BRANCH="${SCM_BRANCH}${SCM_THEME_BRANCH_TRACK_PREFIX}${remote_info}"
fi fi
fi fi
fi fi
@ -267,13 +267,13 @@ function git_prompt_vars {
local ahead_re='.+ahead ([0-9]+).+' local ahead_re='.+ahead ([0-9]+).+'
local behind_re='.+behind ([0-9]+).+' local behind_re='.+behind ([0-9]+).+'
[[ "${status}" =~ ${ahead_re} ]] && SCM_BRANCH+=" ${SCM_GIT_AHEAD_CHAR}${BASH_REMATCH[1]}" [[ "${status}" =~ ${ahead_re} ]] && SCM_BRANCH="${SCM_BRANCH} ${SCM_GIT_AHEAD_CHAR}${BASH_REMATCH[1]}"
[[ "${status}" =~ ${behind_re} ]] && SCM_BRANCH+=" ${SCM_GIT_BEHIND_CHAR}${BASH_REMATCH[1]}" [[ "${status}" =~ ${behind_re} ]] && SCM_BRANCH="${SCM_BRANCH} ${SCM_GIT_BEHIND_CHAR}${BASH_REMATCH[1]}"
local stash_count="$(git stash list 2> /dev/null | wc -l | tr -d ' ')" local stash_count="$(git stash list 2> /dev/null | wc -l | tr -d ' ')"
[[ "${stash_count}" -gt 0 ]] && SCM_BRANCH+=" {${stash_count}}" [[ "${stash_count}" -gt 0 ]] && SCM_BRANCH="${SCM_BRANCH} {${stash_count}}"
SCM_BRANCH+=${details} SCM_BRANCH="${SCM_BRANCH}${details}"
SCM_PREFIX=${GIT_THEME_PROMPT_PREFIX:-$SCM_THEME_PROMPT_PREFIX} SCM_PREFIX=${GIT_THEME_PROMPT_PREFIX:-$SCM_THEME_PROMPT_PREFIX}
SCM_SUFFIX=${GIT_THEME_PROMPT_SUFFIX:-$SCM_THEME_PROMPT_SUFFIX} SCM_SUFFIX=${GIT_THEME_PROMPT_SUFFIX:-$SCM_THEME_PROMPT_SUFFIX}

View File

@ -13,13 +13,13 @@ ____brainy_top_left_parse() {
args=( $1 ) args=( $1 )
IFS="${ifs_old}" IFS="${ifs_old}"
if [ -n "${args[3]}" ]; then if [ -n "${args[3]}" ]; then
_TOP_LEFT+="${args[2]}${args[3]}" _TOP_LEFT="${_TOP_LEFT}${args[2]}${args[3]}"
fi fi
_TOP_LEFT+="${args[0]}${args[1]}" _TOP_LEFT="${_TOP_LEFT}${args[0]}${args[1]}"
if [ -n "${args[4]}" ]; then if [ -n "${args[4]}" ]; then
_TOP_LEFT+="${args[2]}${args[4]}" _TOP_LEFT="${_TOP_LEFT}${args[2]}${args[4]}"
fi fi
_TOP_LEFT+=" " _TOP_LEFT="${_TOP_LEFT} "
} }
____brainy_top_right_parse() { ____brainy_top_right_parse() {
@ -27,13 +27,13 @@ ____brainy_top_right_parse() {
IFS="|" IFS="|"
args=( $1 ) args=( $1 )
IFS="${ifs_old}" IFS="${ifs_old}"
_TOP_RIGHT+=" " _TOP_RIGHT="${_TOP_RIGHT} "
if [ -n "${args[3]}" ]; then if [ -n "${args[3]}" ]; then
_TOP_RIGHT+="${args[2]}${args[3]}" _TOP_RIGHT="${_TOP_RIGHT}${args[2]}${args[3]}"
fi fi
_TOP_RIGHT+="${args[0]}${args[1]}" _TOP_RIGHT="${_TOP_RIGHT}${args[0]}${args[1]}"
if [ -n "${args[4]}" ]; then if [ -n "${args[4]}" ]; then
_TOP_RIGHT+="${args[2]}${args[4]}" _TOP_RIGHT="${_TOP_RIGHT}${args[2]}${args[4]}"
fi fi
__TOP_RIGHT_LEN=$(( __TOP_RIGHT_LEN + ${#args[1]} + ${#args[3]} + ${#args[4]} + 1 )) __TOP_RIGHT_LEN=$(( __TOP_RIGHT_LEN + ${#args[1]} + ${#args[3]} + ${#args[4]} + 1 ))
(( __SEG_AT_RIGHT += 1 )) (( __SEG_AT_RIGHT += 1 ))
@ -44,8 +44,8 @@ ____brainy_bottom_parse() {
IFS="|" IFS="|"
args=( $1 ) args=( $1 )
IFS="${ifs_old}" IFS="${ifs_old}"
_BOTTOM+="${args[0]}${args[1]}" _BOTTOM="${_BOTTOM}${args[0]}${args[1]}"
[ ${#args[1]} -gt 0 ] && _BOTTOM+=" " [ ${#args[1]} -gt 0 ] && _BOTTOM="${_BOTTOM} "
} }
____brainy_top() { ____brainy_top() {
@ -60,7 +60,7 @@ ____brainy_top() {
done done
___cursor_right="\033[500C" ___cursor_right="\033[500C"
_TOP_LEFT+="${___cursor_right}" _TOP_LEFT="${_TOP_LEFT}${___cursor_right}"
for seg in ${___BRAINY_TOP_RIGHT}; do for seg in ${___BRAINY_TOP_RIGHT}; do
info="$(___brainy_prompt_"${seg}")" info="$(___brainy_prompt_"${seg}")"
@ -69,7 +69,7 @@ ____brainy_top() {
[ $__TOP_RIGHT_LEN -gt 0 ] && __TOP_RIGHT_LEN=$(( __TOP_RIGHT_LEN - 1 )) [ $__TOP_RIGHT_LEN -gt 0 ] && __TOP_RIGHT_LEN=$(( __TOP_RIGHT_LEN - 1 ))
___cursor_adjust="\033[${__TOP_RIGHT_LEN}D" ___cursor_adjust="\033[${__TOP_RIGHT_LEN}D"
_TOP_LEFT+="${___cursor_adjust}" _TOP_LEFT="${_TOP_LEFT}${___cursor_adjust}"
printf "%s%s" "${_TOP_LEFT}" "${_TOP_RIGHT}" printf "%s%s" "${_TOP_LEFT}" "${_TOP_RIGHT}"
} }
@ -162,7 +162,7 @@ ___brainy_prompt_battery() {
color=$bold_red color=$bold_red
fi fi
box="[|]" box="[|]"
ac_adapter_connected && info+="+" ac_adapter_connected && info="${info}+"
[ "$info" == "100+" ] && info="AC" [ "$info" == "100+" ] && info="AC"
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white}" "${box}" printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white}" "${box}"
} }

View File

@ -18,7 +18,7 @@ function __powerline_right_segment {
separator_color="$(set_color ${params[1]} ${LAST_SEGMENT_COLOR})" separator_color="$(set_color ${params[1]} ${LAST_SEGMENT_COLOR})"
(( padding += 1 )) (( padding += 1 ))
fi fi
RIGHT_PROMPT+="${separator_color}${separator_char}${normal}$(set_color - ${params[1]}) ${params[0]} ${normal}$(set_color - ${COLOR})${normal}" RIGHT_PROMPT="${RIGHT_PROMPT}${separator_color}${separator_char}${normal}$(set_color - ${params[1]}) ${params[0]} ${normal}$(set_color - ${COLOR})${normal}"
RIGHT_PROMPT_LENGTH=$(( ${#params[0]} + RIGHT_PROMPT_LENGTH + padding )) RIGHT_PROMPT_LENGTH=$(( ${#params[0]} + RIGHT_PROMPT_LENGTH + padding ))
LAST_SEGMENT_COLOR="${params[1]}" LAST_SEGMENT_COLOR="${params[1]}"
(( SEGMENTS_AT_RIGHT += 1 )) (( SEGMENTS_AT_RIGHT += 1 ))
@ -41,16 +41,16 @@ function __powerline_prompt_command {
local info="$(__powerline_${segment}_prompt)" local info="$(__powerline_${segment}_prompt)"
[[ -n "${info}" ]] && __powerline_left_segment "${info}" [[ -n "${info}" ]] && __powerline_left_segment "${info}"
done done
[[ -n "${LEFT_PROMPT}" ]] && LEFT_PROMPT+="$(set_color ${LAST_SEGMENT_COLOR} -)${separator_char}${normal}" [[ -n "${LEFT_PROMPT}" ]] && LEFT_PROMPT="${LEFT_PROMPT}$(set_color ${LAST_SEGMENT_COLOR} -)${separator_char}${normal}"
## right prompt ## ## right prompt ##
if [[ -n "${POWERLINE_RIGHT_PROMPT}" ]]; then if [[ -n "${POWERLINE_RIGHT_PROMPT}" ]]; then
LEFT_PROMPT+="${move_cursor_rightmost}" LEFT_PROMPT="${LEFT_PROMPT}${move_cursor_rightmost}"
for segment in $POWERLINE_RIGHT_PROMPT; do for segment in $POWERLINE_RIGHT_PROMPT; do
local info="$(__powerline_${segment}_prompt)" local info="$(__powerline_${segment}_prompt)"
[[ -n "${info}" ]] && __powerline_right_segment "${info}" [[ -n "${info}" ]] && __powerline_right_segment "${info}"
done done
LEFT_PROMPT+="\033[${RIGHT_PROMPT_LENGTH}D" LEFT_PROMPT="${LEFT_PROMPT}\033[${RIGHT_PROMPT_LENGTH}D"
fi fi
PS1="${LEFT_PROMPT}${RIGHT_PROMPT}\n$(__powerline_last_status_prompt ${last_status})${PROMPT_CHAR} " PS1="${LEFT_PROMPT}${RIGHT_PROMPT}\n$(__powerline_last_status_prompt ${last_status})${PROMPT_CHAR} "

View File

@ -10,6 +10,6 @@ function __powerline_left_segment {
if [[ "${SEGMENTS_AT_LEFT}" -gt 0 ]]; then if [[ "${SEGMENTS_AT_LEFT}" -gt 0 ]]; then
separator="${separator_char}" separator="${separator_char}"
fi fi
LEFT_PROMPT+="${separator}$(set_color ${params[1]} -) ${params[0]} ${normal}" LEFT_PROMPT="${LEFT_PROMPT}${separator}$(set_color ${params[1]} -) ${params[0]} ${normal}"
(( SEGMENTS_AT_LEFT += 1 )) (( SEGMENTS_AT_LEFT += 1 ))
} }

View File

@ -5,7 +5,7 @@ function __powerline_left_segment {
local params=( $1 ) local params=( $1 )
IFS="${OLD_IFS}" IFS="${OLD_IFS}"
LEFT_PROMPT+="${separator}$(set_color - ${params[1]}) ${params[0]} ${normal}" LEFT_PROMPT="${LEFT_PROMPT}${separator}$(set_color - ${params[1]}) ${params[0]} ${normal}"
LAST_SEGMENT_COLOR=${params[1]} LAST_SEGMENT_COLOR=${params[1]}
} }
@ -20,7 +20,7 @@ function __powerline_prompt_command {
[[ -n "${info}" ]] && __powerline_left_segment "${info}" [[ -n "${info}" ]] && __powerline_left_segment "${info}"
done done
[[ "${last_status}" -ne 0 ]] && __powerline_left_segment $(__powerline_last_status_prompt ${last_status}) [[ "${last_status}" -ne 0 ]] && __powerline_left_segment $(__powerline_last_status_prompt ${last_status})
[[ -n "${LEFT_PROMPT}" ]] && LEFT_PROMPT+="$(set_color ${LAST_SEGMENT_COLOR} -) ${normal}" [[ -n "${LEFT_PROMPT}" ]] && LEFT_PROMPT="${LEFT_PROMPT}$(set_color ${LAST_SEGMENT_COLOR} -) ${normal}"
PS1="${LEFT_PROMPT} " PS1="${LEFT_PROMPT} "

View File

@ -83,7 +83,7 @@ function __powerline_scm_prompt {
color=${SCM_THEME_PROMPT_CLEAN_COLOR} color=${SCM_THEME_PROMPT_CLEAN_COLOR}
fi fi
if [[ "${SCM_GIT_CHAR}" == "${SCM_CHAR}" ]]; then if [[ "${SCM_GIT_CHAR}" == "${SCM_CHAR}" ]]; then
scm_prompt+="${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}" scm_prompt="${scm_prompt}${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}"
fi fi
echo "${scm_prompt}${scm}|${color}" echo "${scm_prompt}${scm}|${color}"
fi fi
@ -132,7 +132,7 @@ function __powerline_left_segment {
if [[ "${SEGMENTS_AT_LEFT}" -gt 0 ]]; then if [[ "${SEGMENTS_AT_LEFT}" -gt 0 ]]; then
separator="$(set_color ${LAST_SEGMENT_COLOR} ${params[1]})${separator_char}${normal}" separator="$(set_color ${LAST_SEGMENT_COLOR} ${params[1]})${separator_char}${normal}"
fi fi
LEFT_PROMPT+="${separator}$(set_color - ${params[1]}) ${params[0]} ${normal}" LEFT_PROMPT="${LEFT_PROMPT}${separator}$(set_color - ${params[1]}) ${params[0]} ${normal}"
LAST_SEGMENT_COLOR=${params[1]} LAST_SEGMENT_COLOR=${params[1]}
(( SEGMENTS_AT_LEFT += 1 )) (( SEGMENTS_AT_LEFT += 1 ))
} }
@ -155,7 +155,7 @@ function __powerline_prompt_command {
[[ -n "${info}" ]] && __powerline_left_segment "${info}" [[ -n "${info}" ]] && __powerline_left_segment "${info}"
done done
[[ "${last_status}" -ne 0 ]] && __powerline_left_segment $(__powerline_last_status_prompt ${last_status}) [[ "${last_status}" -ne 0 ]] && __powerline_left_segment $(__powerline_last_status_prompt ${last_status})
[[ -n "${LEFT_PROMPT}" ]] && LEFT_PROMPT+="$(set_color ${LAST_SEGMENT_COLOR} -)${separator_char}${normal}" [[ -n "${LEFT_PROMPT}" ]] && LEFT_PROMPT="${LEFT_PROMPT}$(set_color ${LAST_SEGMENT_COLOR} -)${separator_char}${normal}"
PS1="${LEFT_PROMPT} " PS1="${LEFT_PROMPT} "

View File

@ -138,22 +138,22 @@ prompt_git() {
# Check for uncommitted changes in the index. # Check for uncommitted changes in the index.
if ! $(git diff --quiet --ignore-submodules --cached); then if ! $(git diff --quiet --ignore-submodules --cached); then
s+='+'; s=${s}'+';
fi; fi;
# Check for unstaged changes. # Check for unstaged changes.
if ! $(git diff-files --quiet --ignore-submodules --); then if ! $(git diff-files --quiet --ignore-submodules --); then
s+='!'; s=${s}'!';
fi; fi;
# Check for untracked files. # Check for untracked files.
if [ -n "$(git ls-files --others --exclude-standard)" ]; then if [ -n "$(git ls-files --others --exclude-standard)" ]; then
s+='?'; s=${s}'?';
fi; fi;
# Check for stashed files. # Check for stashed files.
if $(git rev-parse --verify refs/stash &>/dev/null); then if $(git rev-parse --verify refs/stash &>/dev/null); then
s+='$'; s=${s}'$';
fi; fi;
fi; fi;