Optimized theme reading to not use external commands, but only bash

master
oGre 10 years ago
parent 1952c2c86c
commit 09fcaf22fc
  1. 15
      gitprompt.sh

@ -49,8 +49,9 @@ function get_theme() {
local theme="" local theme=""
# use default theme, if theme was not found # use default theme, if theme was not found
for themefile in $(cd "$__GIT_PROMPT_DIR/themes" && echo *); do for themefile in ${__GIT_PROMPT_DIR}/themes/*.bgptheme; do
if [[ "${themefile}" = "${GIT_PROMPT_THEME}.bgptheme" ]]; then local basename=${themefile##*/}
if [[ "${basename%.bgptheme}" = "${GIT_PROMPT_THEME}" ]]; then
theme=$GIT_PROMPT_THEME theme=$GIT_PROMPT_THEME
fi fi
done done
@ -78,9 +79,9 @@ function git_prompt_list_themes() {
git_prompt_dir git_prompt_dir
get_theme get_theme
for themefile in `ls "$__GIT_PROMPT_DIR/themes"`; do for themefile in ${__GIT_PROMPT_DIR}/themes/*.bgptheme; do
local theme="$(basename $themefile .bgptheme)" local basename=${themefile##*/}
local theme="${basename%.bgptheme}"
if [[ "${GIT_PROMPT_THEME}" = "${theme}" ]]; then if [[ "${GIT_PROMPT_THEME}" = "${theme}" ]]; then
echoc ${Red} "*${theme}" echoc ${Red} "*${theme}"
else else
@ -319,7 +320,7 @@ function update_old_git_prompt() {
function setGitPrompt() { function setGitPrompt() {
update_old_git_prompt update_old_git_prompt
local repo=`git rev-parse --show-toplevel 2> /dev/null` local repo=$(git rev-parse --show-toplevel 2> /dev/null)
if [[ ! -e "$repo" ]] && [[ "$GIT_PROMPT_ONLY_IN_REPO" = 1 ]]; then if [[ ! -e "$repo" ]] && [[ "$GIT_PROMPT_ONLY_IN_REPO" = 1 ]]; then
# we do not permit bash-git-prompt outside git repos, so nothing to do # we do not permit bash-git-prompt outside git repos, so nothing to do
PS1="$OLD_GITPROMPT" PS1="$OLD_GITPROMPT"
@ -375,7 +376,7 @@ function olderThanMinutes() {
fi fi
if [[ "$_have_find_mmin" = 1 ]]; then if [[ "$_have_find_mmin" = 1 ]]; then
matches=`"$_find_command" "$1" -mmin +"$2" 2> /dev/null` matches=$("$_find_command" "$1" -mmin +"$2" 2> /dev/null)
find_exit_code="$?" find_exit_code="$?"
if [[ -n "$matches" ]]; then if [[ -n "$matches" ]]; then
return 0 return 0

Loading…
Cancel
Save