3

I have tried to echo $PS1 on my terminal to find out the [u@h W] this is the error I get.

echo $PS1
%{$fg_bold[green]%}%n@%m %{$fg[blue]%}%D{[%X]} %{$reset_color%}%{$fg[white]%}[%~]%{$reset_color%} $(git_prompt_info)
%{$fg[blue]%}->%{$fg_bold[blue]%} %#%{$reset_color%}

I have tried to change it back to default by issuing the command $PS1=[u@h] in the terminal but no changes are made. How can I fix this?

  • 2
    I don't see an error. Do you have a stuck Caps Lock? – muru Nov 6 '17 at 14:00
  • That is not an error, that is what your environment variable (PS1) is set to. – John Anderson Nov 6 '17 at 15:26
  • I have tried to change it back to default by issuing the command $PS1=[u@h] in the terminal but no changes are made. how can i fix this? – dwayne Nov 6 '17 at 15:40
  • PS1=[u@h], without the initial "$". Also, echo "$PS1" | od -bc is more interesting. – waltinator Nov 7 '17 at 1:58
  • What shell are you using? – wjandrea Nov 7 '17 at 16:47
3

The output you see there is no error at all its simply the actual contents of your command prompt.

Coming to the point you pointed out in comments. You nearly had it right. You should use PS1= to set the input prompt and not $PS1. To get it to show the user name and the hosts name your approach was as well slightly wrong the full line for that would be:

PS1='[\u@\h]'

Or if you want the simple Ubuntu style prompt:

# For use with force_color_prompt=true
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '

# The normal one
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '

On top of this saying, as long you not changed the lines in your .bashrc file or in /etc/bash.bashrc you can simply close your terminal and reopen it again, if you're on a GUI that is. This as well will reload the .bashrc file and restore your command prompt.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.