12

I carelessly entered a command in the terminal that should have been in a shell script:

export PS1=$PATH:~/drush23/drush/

now in my terminal instead of this:

ubuntu@ip-10-16-134-18:/home/ubuntu$

I see this:

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/ubuntu/drush23/drush/

and when I change directories this line always stays... I don't know what to do

I have byobu...

3 Answers 3

14

$PS1 is an environment variable that tells yours shell how to format the prompt. Changing the value with export, as you did, only applies to that session; so you can just open up a new shell (not a sub-shell) and see a familiar prompt.

Otherwise, if you really want your prompt back in this session itself, just rerun your shell's preferences file. For Bash users, that is:

. ~/.bashrc

I don't know if that will work (at least, without causing other issues) for Byobu; but you can just set the prompt to a sane value like this:

export PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '

Or, if you don't want to or can't have a colour prompt, a simpler one would be:

export PS1='\u@\h:\w\$ '

where \u is your username, \h is your hostname, and \w is the full (logical) path of your current working directory.

7
  • i wasn't aware the $PS1 controlled that... thanks! Apr 23, 2014 at 12:23
  • just hit in terminal . ~/.bashrc. It will reset PS1 variable and you should get back your prompt.
    – sourav c.
    Apr 23, 2014 at 18:33
  • @souravc Are you sure that wouldn't cause problems for the OP? he's using Byobu. Apr 24, 2014 at 9:45
  • @YatharthROCK I don't think it would cause any problem. What are you expecting as possible problem?
    – sourav c.
    Apr 25, 2014 at 4:16
  • @souravc Sorry, wasn't thinking straight. Apr 25, 2014 at 6:07
1

You can set PS1 to a reasonable value for this Terminal session using:

export PS1=$'\h:\w\$'

The old value should also be restored after closing and restarting Terminal, a reboot, etc.

0

I had this same issue. I used PS1 to set the prompt to "Test"..

Later I was unable to go back to the default colored prompt.

however i was checking some answer in this website & i had to check which shell i'm running.

I tried $SHELL & it got reset to it's default colored prompt value.

"$SHELL"

I'm not a pro in this. This is purely accidental, I don't know if this will work for you or not.

But it's worth a try.

3
  • 1
    Can you explain what you you did to SHELL? Jun 18, 2018 at 13:12
  • I really have no idea how it worked.. I didn't edit anything related to shell either. Do check out the screenshot link : imgur.com/a/l4SGtBK
    – Kurk
    Jun 19, 2018 at 18:43
  • 3
    FYI, this simply runs a new shell. If you run exit, you'll be back to the messed up prompt. Oct 31, 2018 at 20:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .