История изменений
Исправление bryak, (текущая версия) :
Немного не получается. Посмотри как оно по факту
# # подставь свой путь к git-prompt.sh
# . /usr/share/git/git-prompt.sh
# https://en.wikipedia.org/wiki/ANSI_escape_code
reset='\e[0m'
bold='\e[1m'
normal='\e[22m'
black='\e[30m'
red='\e[31m'
green='\e[32m'
yellow='\e[33m'
blue='\e[34m'
magenta='\e[35m'
cyan='\e[36m'
white='\e[37m'
# escape non-printing
e() {
printf "\[%s\]" "$1"
}
# собираем код возврата
exitcode(){
printf "%s" "\$([[ \$? != 0 ]] && printf \""
printf "%s" "$(e $white)[$(e $red)x$(e $white)]"
printf "%s" "\")"
}
user() {
printf "%s" "\u$1"
}
host() {
printf "%s" "\h$1"
}
workdir(){
printf "%s" "[\w]" "$1"
}
git_branch(){
printf "%s" "\$(__git_ps1 \"─[%s]\")"
}
# наглядно и редактируемо собираем PS1
PS1=
PS1+="$(e $white)┌─$(exitcode)─[$(user $blue)@$(host $red)]─$(workdir $cyan)$(git_branch $yellow)\n"
PS1+="$(e $white)└──╼ $(e $reset)"
Исправление bryak, :
Немного не получается. Посмотри как оно по факту
# # подставь свой путь к git-prompt.sh
# . /usr/share/git/git-prompt.sh
# https://en.wikipedia.org/wiki/ANSI_escape_code
reset='\e[0m'
bold='\e[1m'
normal='\e[22m'
black='\e[30m'
red='\e[31m'
green='\e[32m'
yellow='\e[33m'
blue='\e[34m'
magenta='\e[35m'
cyan='\e[36m'
white='\e[37m'
# escape non-printing
e() {
printf "\[%s\]" "$1"
}
# собираем код возврата
exitcode(){
printf "%s" "\$([[ \$? != 0 ]] && printf \""
printf "%s" "$(e $white)[$(e $red)x$(e $white)]"
printf "%s" "\")"
}
user() {
printf "%s" "\u$1"
}
host() {
printf "%s" "\h$1"
}
workdir(){
printf "%s" "[\w]" "$1"
}
git_branch(){
printf "%s" "\$(__git_ps1 \"─[%s]\")"
}
# наглядно и редактируемо собираем PS1
PS1=
PS1+="$(e $white)┌─$(exitcode)─[$(user $blue)@$(host $red)]─$(workdir $red)$(git_branch $yellow)\n"
PS1+="$(e $white)└──╼ $(e $reset)"
Исходная версия bryak, :
Немного не получается. Посмотри как оно по факту
# # подставь свой путь к git-prompt.sh
# . /usr/share/git/git-prompt.sh
# https://en.wikipedia.org/wiki/ANSI_escape_code
reset='\e[0m'
bold='\e[1m'
normal='\e[22m'
black='\e[30m'
red='\e[31m'
green='\e[32m'
yellow='\e[33m'
blue='\e[34m'
magenta='\e[35m'
cyan='\e[36m'
white='\e[37m'
# escape non-printing
e() {
printf "\[%s\]" "$1"
}
# собираем код возврата
exitcode(){
printf "%s" "\$([[ \$? != 0 ]] && printf \""
printf "%s" "$(e $white)[$(e $red)x$(e $white)]"
printf "%s" "\")"
}
user() {
printf "%s" "\u$1"
}
host() {
printf "%s" "\h$1"
}
workdir(){
printf "%s" "[\w]" "$1"
}
git_branch(){
printf "%s" "\$(__git_ps1 \"─[%s]\")"
}
# наглядно и редактируемо собираем PS1
PS1=
PS1+="$(e $white)┌─$(exitcode)─[$(user $blue)@$(host $red)]─$(workdir $red)$(git_branch $yellow)\n"
PS1+="$(e $white)└──╼ $(e $reset)"