Welcome to Linux Forums! With a comprehensive Linux Forum, information on various types of Linux software and many Linux Reviews articles, we have all the knowledge you need a click away, or accessible via our knowledgeable members.
Find the answer to your Linux question:
New to Linux Forums? Register here for free!
    Linux Forums > The Community > Everything BSD > [SOLVED] FreeBSD 5.4 $PROMPT_COMMAND

Forgot Password?
 Everything BSD   For all discussions regarding Free/NetBSD and OpenBSD.

Site Navigation
Linux Articles
Linux Forums
Linux Downloads
Linux Hosting
Free Magazines
Job Board
IRC Chat
RSS Feeds


Linux Forum Topics
Linux Forums
Your Distro
Linux Resources
GNU Linux Zone
The Community
Closed Thread
 
Thread Tools Display Modes
Old 07-24-2009   #1 (permalink)
Just Joined!
 
Join Date: Jan 2005
Posts: 38
Question [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:
Quote:
bash-2.05b$
This isn't very useful, so I wanted it to behave how I'm used to it ... showing something like
Quote:
username@hostname: current_dir$
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/):
So in my .bashrc:
Code:
export PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}\007"'.
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 -n "${USER}@`hostname -s`:  ${PWD/#$HOME/~}"'
This is REALLY CLOSE. The functionality is there. Here's what it looks like:
Quote:
username@hostname_short: CWDbash-2.05b$
However, for some reason (again, unknown to me), the bash prompt is ALWAYS appended with the bash version number:
Quote:
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?
Fermulator is offline  


Old 07-27-2009   #2 (permalink)
tpl
Linux User
 
Join Date: Jan 2007
Location: cleveland
Posts: 370
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_profile
__________________
the sun is new every day (heraclitus)
tpl is offline  
Old 07-27-2009   #3 (permalink)
Just Joined!
 
Join Date: Jan 2005
Posts: 38
Wink

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!
Fermulator is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Free Magazines
Run Your Own Web Server Using Linux & Apache - Free 191 Page Preview
Learn about everything you'll need to build and maintain your Linux servers, and to deploy Web applications to them.
subscribe
Open Source Security Myths Dispelled
Dispel the five major myths surrounding Open Source Security and gain the tools necessary to make a truly informed decision for your IT organization
subscribe
InformationWeek
InformationWeek is the only newsweekly you'll need to stay on top of the latest developments in information technology.
subscribe



All times are GMT. The time now is 07:28 AM.






© 2000 - 2009 - All Rights Reserved - Property of  MAS Media

Content Relevant URLs by vBSEO 3.3.0 RC2