Results 1 to 4 of 4

Thread: Misbehaving Bash Prompt

  1. #1
    Join Date
    Jun 2009
    Location
    Little Rock, Arkansas
    Beans
    190
    Distro
    Ubuntu 12.04 Precise Pangolin

    Smile Misbehaving Bash Prompt

    I added this command to my root .bashrc file to add color to my prompt
    and to simplify its path portion to the lowest level directory,
    Code:
    export PS1="\e[1;31m\u@\h:\W\$\e[m "
    and my bash prompt comes up ending with $ when I expected #.
    Also, occasionally, when I enter a command, part of that command
    becomes part of my prompt!
    If the following is a prompt and command,
    Code:
    prompt$ command
    then my prompt might come back as
    Code:
    prompt$ com
    What's causing this strange behavior?
    Please let me know if you need to see more of my .bashrc file.

    Thanks for your help and grateful for this forum, Randy

  2. #2
    Join Date
    Jul 2011
    Beans
    3,037
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Misbehaving Bash Prompt

    It may be a copy/paste problem, but as far as I know, the double quotes should be replaced by single quotes. This site has a nice overview of how to design bash prompts:

    https://wiki.archlinux.org/index.php...#Basic_prompts

  3. #3
    Join Date
    Jan 2010
    Location
    Sydney, Australia
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: Misbehaving Bash Prompt

    The below section might be informative for you in /etc/profile
    Code:
    if [ "$PS1" ]; then
      if [ "$BASH" ] && [ "$BASH" != "/bin/sh" ]; then
        # The file bash.bashrc already sets the default PS1.
        # PS1='\h:\w\$ '
        if [ -f /etc/bash.bashrc ]; then
          . /etc/bash.bashrc
        fi
      else
        if [ "`id -u`" -eq 0 ]; then
          PS1='# '
        else
          PS1='$ '
        fi
      fi
    fi
    “Progress is made by lazy men looking for easier ways to do things”
    — Robert A. Heinlein

  4. #4
    Join Date
    Jun 2009
    Location
    Little Rock, Arkansas
    Beans
    190
    Distro
    Ubuntu 12.04 Precise Pangolin

    Smile Re: Misbehaving Bash Prompt

    Thanks, both of you.

Bookmarks

Posting Permissions

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