0

I don't know what I did, but somehow I made it so that when I change directories it shows up on the very top of the Terminal. Here is a screenshot of what I am talking about:

enter image description here

I am happy it's still working, probably a setting issue somehow. How do you change it so that when you change directories the information is found inside the terminal, not on top?

Zanna
  • 70,465
BJsgoodlife
  • 1,160
  • 5
  • 31
  • 59

1 Answers1

3

I assume you want the current working directory to show in your prompt.

According to your screenshot, your prompt is showing only your machine name. The output you gave for echo $PS1 doesn't even give me that... I can't replicate your prompt without a bit of tinkering: maybe you have: \[\e]0;\u@\h: \w\a\]\H\$ or... you're using a different shell maybe??

Here is the code for a really simple prompt that shows the username, computer name, and current working directory (enter this in a terminal to test):

PS1="\u@\h:\w$ "

But probably you want the working directory in your prompt AND in the window title... the normal prompt in Ubuntu is this:

\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w\$

which is set in ~/.bashrc by:

# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
    xterm-color|*-256color) color_prompt=yes;;
esac

# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes

if [ -n "$force_color_prompt" ]; then
    if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
        # We have color support; assume it's compliant with Ecma-48
        # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
        # a case would tend to support setf rather than setaf.)
        color_prompt=yes
    else
        color_prompt=
    fi
fi

if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt

# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
    ;;
*)
    ;;
esac

So maybe you put something in your .bashrc to override that. Have a look at the end of it for lines like

export PS1="some code here"

or

PS1="some code here"
export PS1

To see if it has been overridden, and comment out those lines if they are there (put # at the start of the line) or just remove them.

You can also check that the section I pasted above (line 38-73 in my .bashrc) exists and hasn't been changed, if you just want to restore the normal prompt.

To get a completely clean .bashrc

mv ~/.bashrc{,.bak} && cp /etc/skel/.bashrc ~/.bashrc

If you want to customise your prompt, you can keep playing around until you get what you want... this site is helpful for reference.

When you have what you want add to .bashrc

export PS1="your code here "

Also see one of my favourite AU questions

Zanna
  • 70,465
  • The default .bashrc has three sections about the PS1: (1) Color prompt (not relevant in this case). (2) The normal prompt: PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '. (3) The window title: PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1". The third part is the reason that there are square brackets in his PS1. – wjandrea Aug 13 '16 at 16:39
  • yes... but what happened to their prompt? Maybe I should ask for more clarification before answering... thanks for commenting... I will edit – Zanna Aug 13 '16 at 16:51
  • Yeah, I have no idea. I'm just trying to explain the part inside square brackets. – wjandrea Aug 13 '16 at 16:56
  • sorry I forgot to @ you @wjandrea but you came back anyway... I edited shrug but too many assumptions maybe – Zanna Aug 13 '16 at 17:03
  • I'd like to place a bet that this is due to copying dotfiles from the Interwebs. – Abhinav Das Aug 13 '16 at 19:45
  • 1
    sounds likely @0x23212f :) – Zanna Aug 13 '16 at 19:48