#!/bin/bash _ps1__refresh_history() { history -n history -w history -c history -r tac "$HISTFILE" \ | awk '!x[$0]++' \ > /tmp/refreshprompt \ && tac /tmp/refreshprompt \ > "$HISTFILE" rm /tmp/refreshprompt } # Adding new blank line for readability _ps1__pre_prompt_blankline() { IFS=';' read -sdR -p $'\E[6n' ROW COL if ! [[ `echo "${ROW#*[}"` == 1 ]];then if [[ $_ps1_verylight ]];then _ps1_Hline="" else if [[ $_ps1_color ]];then _ps1_Hline=`echo;printf "\e[2m🭻\e[0m%.0b" {1..26}` else _ps1_Hline=`echo;printf '🭻%.0b' {1..26}` fi fi printf "%b\n" "${_ps1_Hline}" fi } # Preparing infos _ps1__pre_prompt_set() { _ps1_user="$USER" _ps1_host="$HOSTNAME" _ps1_file=`\ /bin/ls -1Ap \ | /bin/grep -v / \ | /usr/bin/wc -l \ | /bin/sed 's: ::g'` _ps1_dirs=`\ /bin/ls -1Ap \ | /bin/grep / \ | /usr/bin/wc -l \ | /bin/sed 's: ::g'` _ps1_size=`\ /bin/ls -lah \ | /bin/grep -m 1 total \ | /bin/sed 's/total //'` _ps1_time=`date +%H:%M` _ps1_hist=$(( `cat $HISTFILE | wc -l` + 1 )) _ps1_h=$PWD [[ $_ps1_h/ = "$HOME"/* ]] \ && _ps1_h=\~${_ps1_h#$HOME} _ps1__pre_prompt_blankline } # 1. echolib Colored _ps1__prompt_echolib() { local _ps1_Exit="$?" [[ ${_ps1_Exit} == 0 ]] \ && _ps1_Exit=`echo -e "\e[32m${_ps1_Exit}\e[0m"` \ || _ps1_Exit=`echo -e "\e[31m${_ps1_Exit}\e[0m"` _ps1__refresh_history _ps1_color=true _ps1__pre_prompt_set unset _ps1_color # Line 1 printf "%b %b %b %b\n" \ " $_ps1_Exit" \ "$_ps1_time" \ "${C_Grey}!$_ps1_hist${NC}" \ "${C_Green}$_ps1_user${NC}${C_Grey}@${NC}$_ps1_host" # Line 2 printf "%b %b %b %b %b\n" \ " ${C_Grey}f:${NC}${C_Cyan}$_ps1_file${NC}" \ "${C_Grey}D:${NC}${C_Yellow}$_ps1_dirs${NC}" \ "${C_Grey}S=${NC}$_ps1_size" \ "${C_Grey}>${NC}" \ "${C_Yellow}$_ps1_h${NC}" # Line 3 PS1='$ ' } shopt -s histappend export HISTCONTROL=ignoreboth:erasedups PROMPT_COMMAND=_ps1__prompt_echolib export PS1=$PROMPT_COMMAND