I use a custom PS1 to display more relevant information in my terminal, such as if I'm in a git directory and if it's clean or needs to commit changes. However, sometimes when I'm arrowing through commands, part of the terminal line disappears:
@ ~/tests/testing [tests] > grunt
# up arrow, down arrow
@ ~/tests/testing [t
Essentially, the ests] > gets cut off and I'm left with just the [t.
Is there any particular reason why part of the line is getting cut off with this PS1 config?
Here's some additional info:
My TERM env var is xterm-256color. Here's my .bash_profile:
red='\033[0;31m'
yellow='\033[0;32m'
orange='\033[0;33m'
blue='\033[0;34m'
pink='\033[0;35m'
NC='\033[0m'
function is_git {
if git rev-parse --is-inside-work-tree 2>/dev/null; then
return 1
else
return 0
fi
}
function stuff {
if [ $(is_git) ]; then
git_dir="$(git rev-parse --git-dir 2>/dev/null)"
if [ -z "$(ls -A ${git_dir}/refs/heads )" ]; then
echo -en " [${orange}init${NC}]"
return
fi
echo -n " ["
if [ $(git status --porcelain 2>/dev/null| wc -l | tr -d ' ') -ne 0 ]; then
echo -en "${red}"
else
echo -en "${blue}"
fi
echo -en "$(git rev-parse --abbrev-ref HEAD)${NC}]"
fi
}
export PS1="@ \w\[\$(stuff)\]\[\$(tput sgr0)\] > "