2

My server is a Debian distro. I am currently configuring this bad boy up.

In my Bash, I'm used to having the input to the command line being in one line, i.e.:

root@my-server:~    $  cd ..

However, in this server:

root@my-server:~#
cd ..

My question is - what configuration do I need to change to have my input in the same line?

EDIT:

This is one of the relevant things in my .profile:

force_color_prompt=yes                                                    

if [ -e /usr/share/terminfo/x/xterm-256color ]; then                      
        export TERM='xterm-256color'                                      
else                                                                      
        export TERM='xterm-color'                                         
fi 

export LS_OPTIONS='--color=auto'                                          
eval "`dircolors`"        
  • Whats the output of echo "$PS1" ? – heemayl Jun 1 '15 at 23:42
  • 1
    ${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ – faroskalin Jun 1 '15 at 23:47
  • Are you logged in on the console or over the network? What terminal are you using? What is the output of printf '%s\n' "$PS1" | hexdump and of `echo "$TERM"? – Gilles Jun 1 '15 at 23:57
  • Please show root's PS1. The PS1 that you claim is for a normal user. – John1024 Jun 1 '15 at 23:57
  • Hi @John1024 - how do I show root's PS1? – faroskalin Jun 2 '15 at 4:44
1

Your PS1 variable most likely has a newline character in it. The variable is set whenever a new terminal is opened, when the bashrc is executed. So, to change it:

Open up the bashrc file:

sudo gedit ~/.bashrc

Find the part where the PS1 variable is set. It should look something like this:

PS1="\\u@\\h:\\w#\n"

And remove the unwanted newline. In the case that you don't see a newline, your best bet is to replace the PS1 variable by putting this at the bottom of the bashrc file:

export PS1="\u@\h: \W\\#"
  • Hi therre. This is my PS1 var: ${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\u@\h\[\033[00m\]:\[\033[01;34‌​m\]\w\[\033[00m\]\$ I do not see a \n in that. – faroskalin Jun 1 '15 at 23:54
  • Hmm, either there is some obfuscation, or a \n is being appended later in the file. See what happens if you put this at the end of the bashrc file: export PS1="[\u@\h \W]\\$ " – Matthew D. Scholefield Jun 2 '15 at 1:44
  • @RandomPerson323 Note that the prompt that is causing the OP difficulty, as documented in the question, ends in #. It, therefore, has nothing to do with the PS1 prompt string that is being quoted in the comments which would display a $. – John1024 Jun 2 '15 at 2:15
  • @RandomPerson323 that seemed to work! Now my input is [root@bump ~]# . There seems to be missing some color, however. – faroskalin Jun 2 '15 at 4:50
  • @faroskalin For the missing color, I recomend using a PS1 generator, such as: kirsle.net/wizards/ps1.html There is an option to change the color. – Matthew D. Scholefield Jun 2 '15 at 5:04
0

Thanks to Random Person 323, I figured it out. Turns out my vim config forced my long alias PS1='..' into a new line, and so the ending ' went to the next line on accident, and caused the issue.

This is what fixed it:

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

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.