From 3dede74c0bafdfdb7a2bba37ad5a7f9d3842a6f5 Mon Sep 17 00:00:00 2001 From: Taylor Bockman Date: Mon, 31 May 2021 10:29:38 -0700 Subject: [PATCH] tput probs --- dotfiles/bash/bashrc | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/dotfiles/bash/bashrc b/dotfiles/bash/bashrc index 86abed5..c7ba011 100644 --- a/dotfiles/bash/bashrc +++ b/dotfiles/bash/bashrc @@ -157,26 +157,30 @@ fi # ------------------------------------------ FORMATTING ------------------------------------------ # -# Better color handling so scrolling doesn't get broken. -# Note for Cygwin you need ncurses for this to work. -reset=$(tput sgr0) -green=$(tput setaf 2) -blue=$(tput setaf 4) -white=$(tput setaf 7) - -bold=$(tput bold || tput md) - -export PROMPT_DIRTRIM=2 - -# Important note for PS1 modification - everything non-printable must be escaped with `\[` and `\]`. Otherwise readline -# fails to track the prompt right and things get messed up when you input long strings. - -if [[ "$OSTYPE" == "linux-gnu" ]]; then - # I had some rendering issues running in XFCE unless I added an extra space at the end. - export PS1='\[$bold\]\[$white\]\u@\h\[$reset\]: \[$bold\]\[$blue\]\w\[$reset\] \[$green\]$(parse_git_branch)\[$reset\]\[$bold\]\[$white\]⇨\[$reset\] ' -else - export PS1='\[$bold\]\[$white\]\u@\h\[$reset\]: \[$bold\]\[$blue\]\w\[$reset\] \[$green\]$(parse_git_branch)\[$reset\]\[$bold\]\[$white\]⇨\[$reset\] ' +if [[ $- == *i* ]] +then + # Better color handling so scrolling doesn't get broken. + # Note for Cygwin you need ncurses for this to work. + reset=$(tput sgr0) + green=$(tput setaf 2) + blue=$(tput setaf 4) + white=$(tput setaf 7) + + bold=$(tput bold || tput md) + + export PROMPT_DIRTRIM=2 + + # Important note for PS1 modification - everything non-printable must be escaped with `\[` and `\]`. Otherwise readline + # fails to track the prompt right and things get messed up when you input long strings. + + if [[ "$OSTYPE" == "linux-gnu" ]]; then + # I had some rendering issues running in XFCE unless I added an extra space at the end. + export PS1='\[$bold\]\[$white\]\u@\h\[$reset\]: \[$bold\]\[$blue\]\w\[$reset\] \[$green\]$(parse_git_branch)\[$reset\]\[$bold\]\[$white\]⇨\[$reset\] ' + else + export PS1='\[$bold\]\[$white\]\u@\h\[$reset\]: \[$bold\]\[$blue\]\w\[$reset\] \[$green\]$(parse_git_branch)\[$reset\]\[$bold\]\[$white\]⇨\[$reset\] ' + fi fi + # Add RVM to PATH for scripting. Make sure this is the last PATH variable change. export PATH="$PATH:$HOME/.rvm/bin"