LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 12-22-2017, 01:06 PM   #1
linustalman
Senior Member
 
Registered: Mar 2010
Location: Ireland
Distribution: Debian 9 Stable (Stretch) x64
Posts: 2,995

Rep: Reputation: 340Reputation: 340Reputation: 340Reputation: 340
Question How to edit MX 16 bashrc file to have terminal prompt items on one line?


Hi.

How do I edit the MX 16 .bashrc file to have the terminal prompt items on one line? In the image attached, I want the dollar and blinking cursor on the first line.

This is an excerpt from the .bashrc file which I think it the part that needs tweaking.

Code:
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
Attached Thumbnails
Click image for larger version

Name:	mx-linux-bashrc.png
Views:	22
Size:	1.2 KB
ID:	26582  
 
Old 12-22-2017, 02:41 PM   #2
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
If I understand your question, you want the prompt on one line, and the blinking cursor on the next line. Yes?

It's easy. At a newline \n to the end of your PS1 line in .bashrc.
 
Old 12-22-2017, 04:22 PM   #3
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.5
Posts: 2,018

Rep: Reputation: 628Reputation: 628Reputation: 628Reputation: 628Reputation: 628Reputation: 628
Quote:
Originally Posted by linustalman View Post
Hi.

How do I edit the MX 16 .bashrc file to have the terminal prompt items on one line? In the image attached, I want the dollar and blinking cursor on the first line.

This is an excerpt from the .bashrc file which I think it the part that needs tweaking.

Code:
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
Hmmm. I don't see the LF before the \$ in either of those definitions, nor did the colored one result in the prompt spanning two lines for me. Is something else setting PS1 perhaps?
Code:
echo $PS1
to see the running definition. There should be a \n before the '\$ '
Then search .bashrc, .bash_profile, /etc/bash* files for that definition and remove the \n
 
Old 12-23-2017, 01:12 PM   #4
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.5
Posts: 2,018

Rep: Reputation: 628Reputation: 628Reputation: 628Reputation: 628Reputation: 628Reputation: 628
follow-on:
To see the current definition
Code:
echo $PS1
experiment freely by (re)setting PS1. Example:
Code:
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
This will be a temporary change. PS1 will reset to the defined version on logout/login.
or
Save the result of the echo, and use it to reset.
 
Old 12-24-2017, 08:46 AM   #5
linustalman
Senior Member
 
Registered: Mar 2010
Location: Ireland
Distribution: Debian 9 Stable (Stretch) x64
Posts: 2,995

Original Poster
Rep: Reputation: 340Reputation: 340Reputation: 340Reputation: 340
Quote:
Originally Posted by bigrigdriver View Post
If I understand your question, you want the prompt on one line, and the blinking cursor on the next line. Yes?

It's easy. At a newline \n to the end of your PS1 line in .bashrc.
Hi BRD.

No, I want everything on one line - including the blinking cursor.
 
Old 12-24-2017, 08:47 AM   #6
linustalman
Senior Member
 
Registered: Mar 2010
Location: Ireland
Distribution: Debian 9 Stable (Stretch) x64
Posts: 2,995

Original Poster
Rep: Reputation: 340Reputation: 340Reputation: 340Reputation: 340
Post

Quote:
Originally Posted by scasey View Post
Hmmm. I don't see the LF before the \$ in either of those definitions, nor did the colored one result in the prompt spanning two lines for me. Is something else setting PS1 perhaps?
Code:
echo $PS1
to see the running definition. There should be a \n before the '\$ '
Then search .bashrc, .bash_profile, /etc/bash* files for that definition and remove the \n
Hi scasey.

Here's the output...

Code:
echo $PS1
Code:
\[\e[1;35m\]\u\[\e[0m\]@\[\e[1;36m\]\H\[\e[0m\]:\[\e[1;32m\]\w$\n\[\e[1;32m\]$\[\e[0m\]
 
Old 12-24-2017, 12:14 PM   #7
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Yawnstown, Ohio
Distribution: Mojave
Posts: 9,345
Blog Entries: 36

Rep: Reputation: Disabled
Merry Christmas!

I have kept my custom .bashrc file for almost 10 years now.
Most directives work across most Distros of Linux, and a Mac or two), sooooo once you find the string edit and it works, Keep your ~/.bashrc someplace "safe"
 
1 members found this post helpful.
Old 12-25-2017, 02:41 AM   #8
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.5
Posts: 2,018

Rep: Reputation: 628Reputation: 628Reputation: 628Reputation: 628Reputation: 628Reputation: 628
Quote:
Originally Posted by linustalman View Post
Hi scasey.

Here's the output...

Code:
echo $PS1
Code:
\[\e[1;35m\]\u\[\e[0m\]@\[\e[1;36m\]\H\[\e[0m\]:\[\e[1;32m\]\w$\n\[\e[1;32m\]$\[\e[0m\]
Remove the highlighted \n and the prompt will be all on one line.
Can't tell you where to do that tho...you'll need to grep for PS1 in the various bash files: ~/.bashrc, ~/.bash_profile, /etc/bash* and change the one that looks like the output of the echo.

Then, do what Habitual said...back up the file before and after you change it
 
Old 12-25-2017, 09:51 AM   #9
linustalman
Senior Member
 
Registered: Mar 2010
Location: Ireland
Distribution: Debian 9 Stable (Stretch) x64
Posts: 2,995

Original Poster
Rep: Reputation: 340Reputation: 340Reputation: 340Reputation: 340
Post

Quote:
Originally Posted by scasey View Post
Remove the highlighted \n and the prompt will be all on one line.
Can't tell you where to do that tho...you'll need to grep for PS1 in the various bash files: ~/.bashrc, ~/.bash_profile, /etc/bash* and change the one that looks like the output of the echo.

Then, do what Habitual said...back up the file before and after you change it
In my .bashrc file, I changed the line:

PS1="$PURPLE\u$nc@$CYAN\H$nc:$GREEN\w$nc\\n$GREEN\$$nc "
to
PS1="$PURPLE\u$nc@$CYAN\H$nc:$GREEN\w$nc$GREEN\$$nc "


Is that ok? Attached is an image of my terminal now - the red just blocks out most of my username + PC name.
Attached Thumbnails
Click image for larger version

Name:	ter.png
Views:	6
Size:	7.4 KB
ID:	26604  

Last edited by linustalman; 12-25-2017 at 09:52 AM. Reason: forgot to add attachment
 
Old 12-25-2017, 07:46 PM   #10
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.5
Posts: 2,018

Rep: Reputation: 628Reputation: 628Reputation: 628Reputation: 628Reputation: 628Reputation: 628
Looks like that does what you wanted. It’s OK if it’s OK with you.
 
Old 12-26-2017, 05:30 AM   #11
linustalman
Senior Member
 
Registered: Mar 2010
Location: Ireland
Distribution: Debian 9 Stable (Stretch) x64
Posts: 2,995

Original Poster
Rep: Reputation: 340Reputation: 340Reputation: 340Reputation: 340
Question

Quote:
Originally Posted by scasey View Post
Looks like that does what you wanted. Itís OK if itís OK with you.
I mean it's ok in that it wont cause issues later on?
 
Old 12-26-2017, 03:05 PM   #12
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.5
Posts: 2,018

Rep: Reputation: 628Reputation: 628Reputation: 628Reputation: 628Reputation: 628Reputation: 628
Quote:
Originally Posted by linustalman View Post
I mean it's ok in that it wont cause issues later on?
No. I mean that if the prompt is OK with you, it's OK.
What issues are you concerned about?
 
Old 12-26-2017, 03:11 PM   #13
linustalman
Senior Member
 
Registered: Mar 2010
Location: Ireland
Distribution: Debian 9 Stable (Stretch) x64
Posts: 2,995

Original Poster
Rep: Reputation: 340Reputation: 340Reputation: 340Reputation: 340
Quote:
Originally Posted by scasey View Post
No. I mean that if the prompt is OK with you, it's OK.
What issues are you concerned about?
Hi Sean. I was just curious that deleting things like that without fully knowing what they are in .bashrc might cause problems. So I take it that all is good then.
 
Old 12-26-2017, 03:22 PM   #14
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.5
Posts: 2,018

Rep: Reputation: 628Reputation: 628Reputation: 628Reputation: 628Reputation: 628Reputation: 628
I presumed you understood what that \n is/was: It's a line feed in the middle of your prompt definition causing the prompt to be displayed on two lines. Removing the \n will allow the prompt to display on one line, which is what you asked how to do.
 
Old 12-26-2017, 03:27 PM   #15
linustalman
Senior Member
 
Registered: Mar 2010
Location: Ireland
Distribution: Debian 9 Stable (Stretch) x64
Posts: 2,995

Original Poster
Rep: Reputation: 340Reputation: 340Reputation: 340Reputation: 340
Quote:
Originally Posted by scasey View Post
I presumed you understood what that \n is/was: It's a line feed in the middle of your prompt definition causing the prompt to be displayed on two lines. Removing the \n will allow the prompt to display on one line, which is what you asked how to do.
But I removed "\\n".
 
  


Reply

Tags
bashrc, mx


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Accidentally changed the bashrc file when making a change cannot find it in terminal though it appears in file browser HectorMHH Linux - Newbie 12 10-18-2017 02:20 PM
Ultimate Prompt and bashrc. File jeffguy77 Linux - General 30 06-13-2016 04:06 PM
[SOLVED] i3 - terminal prompt line endless - unwanted 'feature' ewsmith Slackware 5 02-21-2011 10:18 AM
help to edit Edit my bootloader's config file from kernel prompt jagdishpandey Linux - Kernel 5 07-03-2007 07:59 AM
terminal items to file g00ral Linux - General 2 05-09-2004 06:39 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:44 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration