fix _git_ps1 command not found situation

This commit is contained in:
NAME
2022-07-25 17:11:14 -04:00
parent 2b71206d42
commit 9576996ffb
2 changed files with 22 additions and 0 deletions
+14
View File
@@ -3,6 +3,20 @@
export GIT_PS1_SHOWDIRTYSTATE=1
if [[ $(type -t foo) != function ]]; then
__git_ps1(){
local branch=`git branch 2>/dev/null | grep '*' | sed 's/* \(.*\)/\1/'`
if [ $? ]; then
status=`git status 2>/dev/null`
local stage_info="not staged for commit"
local commit_info="Changes to be committed"
local stage_sign=''
local commit_sign=''
[[ "$status" == *"$stage_info"* ]] && stage_sign=" *"
[[ "$status" == *"$commit_info"* ]] && commit_sign=" +"
echo "(${branch}${stage_sign}${commit_sign})"
fi
}
fi
export PS1=' \[\e[0;32m\]\w\[\e[01;31m\]$(__git_ps1 "(%s)")\[\e[00m\]$ '
Executable
+8
View File
@@ -0,0 +1,8 @@
#!/bin/sh
a="asfsdfs
dfdfd
fdfff
ggg"
grep ggg $a