Results 1 to 3 of 3
Hey everyone.
I'm an advanced Linux user, but relatively new to FreeBSD.
Running:
* FreeBSD 5.4-STABLE
* Shell: /bin/bash
So by default, my shell prompt looked like:
bash-2.05b$
This isn't ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 07-24-2009 #1Just Joined!
- Join Date
- Jan 2005
- Posts
- 54
[SOLVED] FreeBSD 5.4 $PROMPT_COMMAND
Hey everyone.
I'm an advanced Linux user, but relatively new to FreeBSD.
Running:
* FreeBSD 5.4-STABLE
* Shell: /bin/bash
So by default, my shell prompt looked like:
This isn't very useful, so I wanted it to behave how I'm used to it ... showing something likebash-2.05b$To do this, I'm using something similar to Ubuntu (and recommended by a few websites -- e.g. http://kinzlaw.wordpress.com/2007/08...mpt_command/):username@hostname: current_dir$
So in my .bashrc:
Unfortunately though, (for reasons unknown to me), the FreeBSD doesn't know what those ANSI escape character codes mean ... so I removed it and made a simpler statement of:Code:export PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}\007"'.
This is REALLY CLOSE. The functionality is there. Here's what it looks like:Code:export PROMPT_COMMAND='echo -n "${USER}@`hostname -s`: ${PWD/#$HOME/~}"'However, for some reason (again, unknown to me), the bash prompt is ALWAYS appended with the bash version number:username@hostname_short: CWDbash-2.05b$.bash-2.05b
I've looked at .bash_profile, .profile, etc. I can't find anywhere where it might "append" something to the existing value of PROMPT_COMMAND...
Any tips on how to fix this?
- 07-27-2009 #2Linux User
- Join Date
- Jan 2007
- Location
- cleveland
- Posts
- 468
from "man bash"
"PROMPT_COMMAND
If set, the value is executed as a command prior to issuing each
primary prompt.
PS1 The value of this parameter is expanded (see PROMPTING below) and
used as the primary prompt string.
The default value is ‘‘\s-\v\"
where /s is name of shell, and /v version i.e. "bash-2.05b"
so you are not changing PS1 from the default, just
prepending to it. Why not set PS1 directly: I use
PS1=\h/\u\w \033[1;42m\$\033[0m
for example--in .bash_profilethe sun is new every day (heraclitus)
- 07-27-2009 #3Just Joined!
- Join Date
- Jan 2005
- Posts
- 54
Ha!
Thanks, you're so right. I'm not really sure how/why ubuntu uses both PS1 and PROMPT_COMMAND:
* PROMPT_COMMAND = echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007"
* PS1 = ${debian_chroot:+($debian_chroot)}\u@\h:\w\$
But, on FreeBSD, setting the PS1 environment variable directly worked like magic.
Thanks!



