Skip to content

Commit a9e2700

Browse files
committed
simplify refactory
1 parent 3b055c8 commit a9e2700

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

actions/chce_git_status_PS1.sh

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -183,18 +183,18 @@ then
183183
unset ch_shell
184184
unset installation_type
185185
unset install_path
186-
exit 0
186+
exit -1
187187
fi
188188

189189
# Wykorzystuje "features" z globalnego kontekstu
190190
choose_ps1_format() {
191-
echo "Możliwe formaty, \[\033... to oznaczenia kolory" 1>&2
191+
echo "Możliwe formaty, \\e... to escape dla oznaczenia koloru" 1>&2
192192
FORMATS=$'
193-
1.(<GIT-BRANCH-NAME> <GIT-STATUS>)[<USER>@<HOST>] <PWD><ONL>\$
194-
2.(<GIT-BRANCH-NAME> <GIT-STATUS>) [<USER>@<HOST>] <PWD><ONL>\$
195-
3.<USER>@<HOST> <PWD> (<GIT-BRANCH-NAME> <GIT-STATUS>)<ONL>\$
196-
4.<USER>@<HOST> \\[\\033[33m\\]<PWD>\\[\\033[00m\\] (<GIT-BRANCH-NAME> <GIT-STATUS>)<ONL>\$
197-
5.<USER>@<HOST> \\[\\033[33m\\]<PWD>\\[\\033[00m\\] <GIT-BRANCH-NAME> <GIT-STATUS><ONL>\$
193+
1.(<GIT-STATUS>)[<USER>@<HOST>] <PWD><ONL>$
194+
2.(<GIT-STATUS>) [<USER>@<HOST>] <PWD><ONL>$
195+
3.<USER>@<HOST> <PWD> (<GIT-STATUS>)<ONL>$
196+
4.<USER>@<HOST> \\e[33m<PWD>\\e[00m (<GIT-STATUS>)<ONL>$
197+
5.<USER>@<HOST> \\e[33m<PWD>\\e[00m <GIT-STATUS><ONL>$
198198
'
199199
echo "$FORMATS" 1>&2
200200
read -p "Wybierz format: " format_nr
@@ -219,17 +219,9 @@ choose_ps1_format() {
219219
format=${format/"<USER>"/\\u}
220220
format=${format/"<HOST>"/\\h}
221221
format=${format/"<PWD>"/\\w}
222-
format=${format/"<GIT-BRANCH-NAME>"/'$(__git_ps1 '}
223-
# funkcja __git_ps1 polega na ilości przekazanych do niej parametrów.
224-
# kolor chyba działa tylko przy jednym parametrze...
225-
IS_GIT_DIRTYSTATE=$(echo $1 | grep 'GIT_PS1_SHOWDIRTYSTATE=y')
226-
if test -n "$IS_GIT_DIRTYSTATE";
227-
then format=${format/"<GIT-STATUS>"/'%s%s)'}
228-
else format=${format/"<GIT-STATUS>"/'%s)'}
229-
fi
222+
format=${format/"<GIT-STATUS>"/'$(__git_ps1 %s)'}
230223

231224
echo $format
232-
unset IS_GIT_DIRTYSTATE
233225
unset format
234226

235227
return 0
@@ -254,7 +246,7 @@ echo 'fi' >> $install_path
254246
case $ch_shell in
255247
bash|csh)
256248
echo $"export PS1='$new_ps1 '" >> $install_path
257-
# echo $'export PS1=\'$(__git_ps1 \(%s%s\))[\u@\h \w]\n\$ \'' >> $install_path
249+
# echo $'export PS1=\'$(__git_ps1 \(%s%s\))[\u@\h \w]\n$ \'' >> $install_path
258250
;;
259251
zsh)
260252
echo $'setopt PROMPT_SUBST; PS1=\'[%n@%m %c$(__git_ps1 \" (%s)\")]\$ \'' >> $install_path

0 commit comments

Comments
 (0)