prompt: Replace tput with escape codes

This commit is contained in:
2020-05-27 16:09:43 +02:00
parent 1e5594721c
commit 6e9996f0de

View File

@@ -1,10 +1,10 @@
#!/bin/bash #!/bin/bash
format_modified_detailed() { format_modified_detailed() {
local txtrst='$(tput sgr0)' local txtrst='\e[m'
local txtred='\e[0;31m' local txtred='\e[0;31m'
local txtgrn='$(tput setaf 2)' local txtgrn='\e[0;32m'
local txtyel='$(tput setaf 3)' local txtyel='\e[0;33m'
# Modified, staged and untracked # Modified, staged and untracked
# A added (new file) M modified, D deleted, R renamed, T typechange # A added (new file) M modified, D deleted, R renamed, T typechange
@@ -27,10 +27,10 @@ format_modified_detailed() {
} }
format_modified() { format_modified() {
local txtrst='$(tput sgr0)' local txtrst='\e[m'
local txtred='\e[0;31m' local txtred='\e[0;31m'
local txtgrn='$(tput setaf 2)' local txtgrn='\e[0;32m'
local txtyel='$(tput setaf 3)' local txtyel='\e[0;33m'
# Modified, staged and untracked # Modified, staged and untracked
# A added (new file) M modified, D deleted, R renamed, T typechange # A added (new file) M modified, D deleted, R renamed, T typechange
@@ -51,16 +51,16 @@ set_prompt_fancy()
local is_git="$(git rev-parse --is-inside-work-tree 2>/dev/null)" local is_git="$(git rev-parse --is-inside-work-tree 2>/dev/null)"
local last_cmd=$? local last_cmd=$?
local txtrst='$(tput sgr0)' local txtrst='\e[m'
local txtbold='$(tput bold)' local txtbold='\e[1m'
local txtblk='$(tput setaf 0)' local txtblk='\e[30m'
local txtred='$(tput setaf 1)' local txtred='\e[31m'
local txtgrn='$(tput setaf 2)' local txtgrn='\e[32m'
local txtyel='$(tput setaf 3)' local txtyel='\e[33m'
local txtblu='$(tput setaf 4)' local txtblu='\e[34m'
local txtpur='$(tput setaf 5)' local txtpur='\e[35m'
local txtcyn='$(tput setaf 6)' local txtcyn='\e[36m'
local txtwht='$(tput setaf 7)' local txtwht='\e[37m'
# unicode "✗" # unicode "✗"
local fancyx='\342\234\227' local fancyx='\342\234\227'
# unicode "✓" # unicode "✓"
@@ -99,16 +99,16 @@ set_prompt()
{ {
local is_git="$(git rev-parse --is-inside-work-tree 2>/dev/null)" local is_git="$(git rev-parse --is-inside-work-tree 2>/dev/null)"
local txtrst='$(tput sgr0)' local txtrst='\e[m'
local txtbold='$(tput bold)' local txtbold='\e[1m'
local txtblk='$(tput setaf 0)' local txtblk='\e[30m'
local txtred='$(tput setaf 1)' local txtred='\e[31m'
local txtgrn='$(tput setaf 2)' local txtgrn='\e[32m'
local txtyel='$(tput setaf 3)' local txtyel='\e[33m'
local txtblu='$(tput setaf 4)' local txtblu='\e[34m'
local txtpur='$(tput setaf 5)' local txtpur='\e[35m'
local txtcyn='$(tput setaf 6)' local txtcyn='\e[36m'
local txtwht='$(tput setaf 7)' local txtwht='\e[37m'
# User color: red for root, yel for others # User color: red for root, yel for others
if [[ $EUID == 0 ]]; then if [[ $EUID == 0 ]]; then