LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 06-03-2011, 11:21 AM   #1
Fraeco
LQ Newbie
 
Registered: Mar 2009
Posts: 5

Rep: Reputation: 0
Bash PS1


Hey

I just figured out how I can change the look of my shell and I've been tinkering arround with the PS1 and adding some colour to it (for now :-)). I'm quite happy with the new look, it has only 1 problem.

If i type a command that's too long and should continue on a new line, it just jumps to the start of the line and prints over the shell prompt. If i use the default prompt, it works like it should

Eg:
fraeco@linux:/this/is/a/long/path$ with_an_even_l
onger_command

This is ok, but now with the modification I made it goes like this

onger_command/this/is/a/long/path$ with_an_even_l

My default PS1 is this
\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w\$

The one I made is this: "\e[1;34m\u@\h:\e[m\w\$ "
What needs to be there, to make it function like before again?
 
Old 06-03-2011, 11:27 AM   #2
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux
Posts: 2,766
Blog Entries: 1

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
Hello!

Mine is this:

Code:
PS1='\[\033[1;31m\]\[\033[1;30m\](\[\033[1;34m\]\u\[\033[1;37m\]@\[\033[0;37m\]\h\[\033[1;30m\])-(\[\033[0;37m\]\@\[\033[0;32m\] \[\033[1;34m\]\d\[\033[1;30m\])-(\[\033[1;32m\]\w\[\033[1;30m\])\[\033[0;34m\]\n\[\033[1;34m\]\$ \[\033[1;37m\]>\[\033[0;37m\]'

export PS1
 
Old 06-03-2011, 11:38 AM   #3
wpeckham
Member
 
Registered: Apr 2010
Location: USA
Distribution: Debian, Ubuntu, Fedora, RedHat, DSL, Puppy, CentOS, Knoppix
Posts: 746

Rep: Reputation: 169Reputation: 169
PS1

There are several tricks you can use, even placing some of the information at the TOP pf the screen and the REST at the cursor location. What I decided in your position was that more than one half line is too long a prompt!
 
Old 06-03-2011, 01:00 PM   #4
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 1,343

Rep: Reputation: 575Reputation: 575Reputation: 575Reputation: 575Reputation: 575Reputation: 575
When your prompt includes a non-printing terminal control sequence, you need to bracket that sequence with \[ and \] to tell bash that the characters within the brackets do not advance the cursor position.
 
1 members found this post helpful.
Old 06-05-2011, 04:24 AM   #5
Fraeco
LQ Newbie
 
Registered: Mar 2009
Posts: 5

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by rknichols View Post
When your prompt includes a non-printing terminal control sequence, you need to bracket that sequence with \[ and \] to tell bash that the characters within the brackets do not advance the cursor position.
This was what I was looking for, after inserting the brackets before and after my shell behaves the way it shouls again. Thnx all!
 
  


Reply


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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] BASH $PS1 Hack cryingthug Programming 10 10-02-2011 08:30 PM
\$ in Bash's PS1 not working for root SlowCoder Linux - General 3 05-28-2008 12:06 PM
Post your BASH prompt [PS1]? introuble General 11 12-27-2006 03:47 PM
PS1 = * in bash, where '*' = parameters BlueSpirit Slackware 5 11-05-2006 08:21 AM
bash PS1 problems Krelian Linux - General 2 10-07-2006 09:16 PM


All times are GMT -5. The time now is 06:20 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration