You are not logged in.
Yesterday I edited my prompt and everything was working fine. After booting up today though I can barely type commands after about 20 characters since they'll overlap into my prompt (in the same line) and if I press backlash when overlapped they make the prompt disappear.
I have proper monospace fonts installed and have checked for unscaped characters in my .bashrc prompt, but I can't see any. I'm quite new to bash in general though so it's possible that unscaped characters might be the problem.
My .bashrc:
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
system_info(){
uname -r
}
light_Orange="tput setaf 216"
dark_Blue="tput setaf 33"
light_Green="tput setaf 76"
reset="tput sgr0"
PS1='`$light_Orange` ($('system_info')) `$dark_Blue`\u:`$light_Green`/\W`${reset}`$'
alias ls='ls --color=auto'
shopt -s autocd #no need to type cd bruh
alias grep='grep --color=auto'
alias ..='cd ..'
alias mv='mv -i'
export PATH
export HISTCONTROL=ignoreboth
export EDITOR=nano
export BROWSER=firefox-developer
unclutter &Any help would be appreciated!
Edit: I don't know if it matters but I'm using KDE plasma for my DE and Terminator for my terminal.
Last edited by polgesteirg (2020-12-07 05:11:39)
Offline
You need to put "\[" and "\]" around your color codes. Bash needs those "\[ \]" to count how far the cursor moves.
I'd recommend to put the "\[ \]" directly into your color variables:
light_Orange="\[$(tput setaf 216)\]"
...
PS1='$light_Orange ...'In this example I also removed the "`" backticks you were using. I instead put "$(...)" into the variable.
Offline
You need to put "\[" and "\]" around your color codes. Bash needs those "\[ \]" to count how far the cursor moves.
I'd recommend to put the "\[ \]" directly into your color variables:
light_Orange="\[$(tput setaf 216)\]" ... PS1='$light_Orange ...'In this example I also removed the "`" backticks you were using. I instead put "$(...)" into the variable.
Thank you very much! I did read about the bash characters, but somehow managed to forget everything about them.
I also switched to using double quotes ("") since it makes everything easier. This made that much clearer:
https://stackoverflow.com/questions/669 … es-in-bash
Here's the updated bash if anyone's interested:
system_info(){
uname -r
}
light_Orange="\[$(tput setaf 216)\]"
dark_Blue="\[$(tput setaf 33)\]"
light_Green="\$(tput setaf 76)\]"
reset="\[(tput sgr0)\]"
PS1="${light_Orange} ($(system_info)) ${dark_Blue}\u: ${light_Green}/\W${reset}"Offline
You still have a typo (missing the opening square bracket) in light_Green.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline