update PS1

This commit is contained in:
Alexander Popov 2024-06-22 03:08:34 +03:00
parent 83f7d9224f
commit de00c0e03e
Signed by: iiiypuk
GPG Key ID: E47FE0AB36CD5ED6
2 changed files with 32 additions and 1 deletions

View File

@ -8,7 +8,8 @@ HISTSIZE=1000
HISTFILESIZE=2000 HISTFILESIZE=2000
########################################################### ###########################################################
export PS1='\[\e[0;33m\][\t] \[\e[0;32m\][\W]\[\e[0m\] \[\e[0;31m\]> \[\e[0m\]' #export PS1='\[\e[0;33m\][\t] \[\e[0;32m\][\W]\[\e[0m\] \[\e[0;31m\]> \[\e[0m\]'
source ${HOME}/PS1.bash
export GPG_TTY=$(tty) export GPG_TTY=$(tty)
export PATH="$PATH:$HOME/.local/bin" export PATH="$PATH:$HOME/.local/bin"

30
~/Bash/PS1.bash Normal file
View File

@ -0,0 +1,30 @@
RST='\e[0m'
PS1_LINE=`printf -- '- %.0s' {1..200}` # Background lines
update() {
# Exit code
# [ $? == 0 ] && PS1_STATUS="" || PS1_STATUS=""
# [ $? == 0 ] && PS1_STATUS="\e[38;5;113m${RST}" || PS1_STATUS="\e[38;5;167m${RST}"
PS1_FILL=${PS1_LINE:0:$COLUMNS} # Background fill
FREE_RAM=$(free | awk '/Mem/{printf("%2d%"), $3/$2*100}')
# Git branch
GIT_BRANCH=''
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
GIT_BRANCH="[git ${ref#refs/heads/}] "
}
PROMPT_COMMAND=update
PS1_HOST="\e[38;5;159m \h${RST}" # Host
PS1_CLOCK="\e[38;5;227m \t${RST}" # Clock
PS1_USER="\e[38;5;218m \u${RST}" # User
PS1_RAM="\e[38;5;113m \$FREE_RAM${RST}" # RAM
PS1_FOLDER="\e[38;5;215m \W${RST}" # Folder
PS1_GIT="\e[38;5;215m\$GIT_BRANCH${RST}" # Git branch (if exist)
PS1="\e[0;90m\${PS1_FILL}\[\033[0G\]${PS1_HOST} ${PS1_USER} ${PS1_FOLDER} \
\[\033[\$((COLUMNS-17))G\] ${PS1_RAM} ${PS1_CLOCK}${RST}\n${PS1_GIT}\
(\e[38;5;113m\$(if [ \$? == 0 ]; then echo ''; else echo ''; fi)${RST})> "