diff --git a/~/Bash/.bashrc b/~/Bash/.bashrc index 7cfe0ed..1650402 100644 --- a/~/Bash/.bashrc +++ b/~/Bash/.bashrc @@ -8,7 +8,8 @@ HISTSIZE=1000 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 PATH="$PATH:$HOME/.local/bin" diff --git a/~/Bash/PS1.bash b/~/Bash/PS1.bash new file mode 100644 index 0000000..8bb352f --- /dev/null +++ b/~/Bash/PS1.bash @@ -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})> "