Results 1 to 10 of 15
Well I have had a google about, and have read man-bash > PS1 & man-bash > PROMPTING... but I still don't geddit!
My preset bash prompt is this:
Code:
stephen@linux-ahy5:~>
...
- 02-19-2009 #1Just Joined!
- Join Date
- Feb 2009
- Posts
- 12
PS1 bash prompt
Well I have had a google about, and have read man-bash > PS1 & man-bash > PROMPTING... but I still don't geddit!
My preset bash prompt is this:
My response toCode:stephen@linux-ahy5:~>
is:Code:echo $PS1
My current root prompt is:Code:$(ppwd \l)\u@\h:\w>
Code:linux-ahy5:/home/stephen #
If I set a new PS1 it (more or less!) works as expected.
Working from the right, I think I understand that:
The > is just an echoed character after the:Code:$(ppwd \l)\u@\h:\w>
\w which shows the PWD, or if I am in /stephen/home, working as stephen it shows ~
the colon is just another echoed character.
The \h shows ?? I guess brief hostname,
The \u shows me , the user, as stephen, and the @ is echoed:
So; \u@\h:\w> shows:
stephen@linux-ahy5:~> .... so far so good. But; if I add, change or delete any of these components, I get the error message:
so it must be somewhere in the part:Code:syntax error near unexpected token `newline'
.... which is where I get confused. A stab in the dark: Does the $ mean:Code:$(ppwd \l)
"If the UID is 000 then do what is in brackets if not do the rest"?
if this is so, does the "(ppwd \l)" mean "prompt for password", and why does not the $ take a forward slash before? What does the "\l" part do in this context?
I am not especially unhappy with the current one, but as manipulating the prompt is often offered as "Lesson 1" in any intro to linux CLI, it is frutrating not to be able to do this!
One thing is that I can see no reason to be told by the prompt that I am working in Linux, I cannot see myself swapping in to PERL or PYTHON any time soon, also I have no real idea what the "linux-ahy5" part of the prompt means!
For convenience here is the "Prompting" section of man bash:
PROMPTING
When executing interactively, bash displays the primary
a command. Bash allows these prompt strings to be cus
tomized by inserting a number of backslash-escaped special
characters that are decoded as follows:
\t the current time in HH:MM:SS format
\d the date in "Weekday Month Date" format
(e.g., "Tue May 26")
\n newline
\s the name of the shell, the basename of $0
(the portion following the final slash)
\w the current working directory
\W the basename of the current working direc
tory
\u the username of the current user
\h the hostname
\# the command number of this command
\! the history number of this command
\$ if the effective UID is 0, a #, otherwise a
$
\nnn the character corresponding to the octal
number nnn
\\ a backslash
\[ begin a sequence of non-printing characters,
which could be used to embed a terminal con
trol sequence into the prompt
\] end a sequence of non-printing characters
The command number and the history number are usually dif
ferent: the history number of a command is its position in
the history list, which may include commands restored from
the history file (see HISTORY below), while the command
number is the position in the sequence of commands exe
cuted during the current shell session. After the string
is decoded, it is expanded via parameter expansion, com
mand substitution, arithmetic expansion, and word split
ting.
Last edited by WakouonSuSe; 02-19-2009 at 10:46 AM. Reason: addenda
- 02-19-2009 #2Just Joined!
- Join Date
- Oct 2004
- Posts
- 62
Here are my prompts , in color (from .bashrc)
Bye.
for my home....
# background cyan (46) - char (fg) bold white (37:1)
PS1="\[\033[37;1;46m\]`date "+%a %d"` \w\033[0m\] "
when I am "superuser" (insert in /root./.bashrc - use "superuser")...
# root --> bg red (41) - char (fg) bold white (37:1)
PS1="\[\033[37;1;41m\]`date "+%a %d"` \w\033[0m\] "
- 02-19-2009 #3Just Joined!
- Join Date
- Feb 2009
- Posts
- 12
Thank-you, but that is no help at all!


I need to know why any manipulation of my current "$(ppwd \l)\u@\h:\w>" returns
bash: syntax error near unexpected token `newline'
even if I "PS1= EXACTLY THE SAME AS echo $PS1"
and what the $(ppwd \l) means....
- 02-19-2009 #4Just Joined!
- Join Date
- Oct 2004
- Posts
- 62
Sorry....I didn't read well...
And now.... an "uncorrect" advice... RTFM !
- 02-19-2009 #5Just Joined!
- Join Date
- Feb 2009
- Posts
- 12
and the first line of my original post.....?
have read man-bash > PS1 & man-bash > PROMPTING... but I still don't geddit!
- 02-19-2009 #6Just Joined!
- Join Date
- Nov 2007
- Posts
- 46
bumpety bump
- 02-19-2009 #7Just Joined!
- Join Date
- Oct 2004
- Posts
- 62
Don't take "RTFM" too literally... I was only upset by the two emoticons!
However I don't know the answer to your problem... and I don't care nor
I have time to lose... I only wanted you to know prompts alternative from the
standard. But if you are OK with your prompts.... no problem.
- 02-20-2009 #8Just Joined!
- Join Date
- Nov 2007
- Posts
- 46
Sorry about the 'moticons, they were supposed to convey my confusion, not a comment about you...
- 02-20-2009 #9Linux Guru
- Join Date
- Nov 2007
- Location
- Córdoba (Spain)
- Posts
- 1,513
The key will reside in whatever "ppwd" is.
There's a pwd command (with a single 'p') that is used to show the current path. I assume that your "ppwd" is a custom command, script or function, but since I have no idea what it is of what does it do, I can't give any more concrete info.
The syntax $(whatever) will expand to the output of whatever command there's inside. In other words, "ppwd \l" (whatever that means) is run, and it's output is dumped in the place where "$(ppwd \l)" was before.
- 02-20-2009 #10
I found this useful ... having said that I tend to go with the default prompt unless I am chroot'in.


Reply With Quote