changing bash output format results in strange behaviour | pressku.com

Trending 1 month ago

I already changed my bash output format to thing for illustration this:

enter image explanation here

which I americium very happy with. I achieved this by adding this codification to nan .bashrc:

set_PS1() { section RESET=$(tput sgr0 ) section BOLD=$(tput bold ) section RED=$(tput setaf 1 ) section GREEN=$(tput setaf 2 ) section YELLOW=$(tput setaf 3 ) section BLUE=$(tput setaf 4 ) section CYAN=$(tput setaf 6 ) section WHOAMI='\u' section WHERE='\w' section HOSTNAME='\h' section TIME='\D{%H:%M:%S}' exit_code_prompt() { section EXIT_CODE=$? section RED=$(tput setaf 1 ) section GREEN=$(tput setaf 2 ) if [ $EXIT_CODE -ne 0 ]; then echo -e "$RED$BOLD\xE2\x9C\x98 $EXIT_CODE \xE2\x86\x92" # Red transverse people symbol else echo -e "$GREEN$BOLD\xE2\x9C\x93 \xE2\x86\x92" # Green checkmark symbol fi } section LINE_1="$BOLD$YELLOW$TIME $CYAN$WHOAMI$BLUE@$CYAN$HOSTNAME$RESET$BOLD":" $BLUE$WHERE$RESET" section LINE_2="$BOLD\$(exit_code_prompt) "$RESET$BOLD' \$: '$RESET PS1="$LINE_1\n$LINE_2" unset -f set_PS1 } set_PS1

My problem is now that if I person a comand that is longer than 1 statement it doesnt do a linebreak but alternatively it overwrites nan contented from nan aforesaid statement (only successful ocular practice ofc):

enter image explanation here

Now erstwhile I delete nan complete command, it deletes a portion of nan bash punctual arsenic well:

enter image explanation here

now really tin I resoluteness this? I deliberation it mightiness person to do thing pinch nan usage of LINE_1 and LINE_2 but I really don't cognize really I person to alteration nan usability to get to my desired output.

I already looked into utilizing zsh but I didn't want to loose nan bash functionality for illustration keyboard shortcuts that I already sewage utilized to...

More
close