Find the answer to your Linux question:
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.
  1. #1
    Just Joined!
    Join Date
    Jan 2005
    Posts
    54

    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:
    bash-2.05b$
    This isn't very useful, so I wanted it to behave how I'm used to it ... showing something like
    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:
    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:
    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?

  2. #2
    tpl
    tpl is offline
    Linux User
    Join Date
    Jan 2007
    Location
    cleveland
    Posts
    478
    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)

  3. #3
    Just Joined!
    Join Date
    Jan 2005
    Posts
    54

    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!

  4. $spacer_open
    $spacer_close

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •