Shell prompt (bash) - Ubuntu

This is a discussion on Shell prompt (bash) - Ubuntu ; A couple weeks ago I changed my prompt using PS1="new_prompt_here", and it worked fine. Today I decided that I don't care for my new prompt and tried changing it to something else. It works but now I can't get it ...

+ Reply to Thread
Results 1 to 11 of 11

Thread: Shell prompt (bash)

  1. Shell prompt (bash)


    A couple weeks ago I changed my prompt using PS1="new_prompt_here", and it
    worked fine. Today I decided that I don't care for my new prompt and tried
    changing it to something else. It works but now I can't get it to stick
    after I close Terminal and reopen a new one.

    Am I forgetting something?

    --
    Hobart

  2. Re: Shell prompt (bash)

    On Fri, 26 Sep 2008 00:27:52 -0400, Hobart wrote:

    > A couple weeks ago I changed my prompt using PS1="new_prompt_here", and
    > it worked fine. Today I decided that I don't care for my new prompt and
    > tried changing it to something else. It works but now I can't get it to
    > stick after I close Terminal and reopen a new one.
    >
    > Am I forgetting something?


    Yes. You forgot that PS1 is set in your ~/.bashrc file. Edit that file.

    stonerfish

  3. Re: Shell prompt (bash)

    jellybean stonerfish wrote:
    > On Fri, 26 Sep 2008 00:27:52 -0400, Hobart wrote:
    >
    >> A couple weeks ago I changed my prompt using PS1="new_prompt_here", and
    >> it worked fine. Today I decided that I don't care for my new prompt and
    >> tried changing it to something else. It works but now I can't get it to
    >> stick after I close Terminal and reopen a new one.
    >>
    >> Am I forgetting something?

    >
    > Yes. You forgot that PS1 is set in your ~/.bashrc file. Edit that file.
    >
    > stonerfish


    Well, hmm. That's not how I changed it the first time.

    --
    Hobart

  4. Re: Shell prompt (bash)

    On Fri, 26 Sep 2008 01:37:34 -0400, Hobart wrote:

    > jellybean stonerfish wrote:
    >> On Fri, 26 Sep 2008 00:27:52 -0400, Hobart wrote:
    >>
    >>> A couple weeks ago I changed my prompt using PS1="new_prompt_here",
    >>> and it worked fine. Today I decided that I don't care for my new
    >>> prompt and tried changing it to something else. It works but now I
    >>> can't get it to stick after I close Terminal and reopen a new one.
    >>>
    >>> Am I forgetting something?

    >>
    >> Yes. You forgot that PS1 is set in your ~/.bashrc file. Edit that
    >> file.
    >>
    >> stonerfish

    >
    > Well, hmm. That's not how I changed it the first time.


    Are you using bash?



  5. Re: Shell prompt (bash)

    jellybean stonerfish wrote:
    > On Fri, 26 Sep 2008 01:37:34 -0400, Hobart wrote:
    >
    >> jellybean stonerfish wrote:
    >>> On Fri, 26 Sep 2008 00:27:52 -0400, Hobart wrote:
    >>>
    >>>> A couple weeks ago I changed my prompt using PS1="new_prompt_here",
    >>>> and it worked fine. Today I decided that I don't care for my new
    >>>> prompt and tried changing it to something else. It works but now I
    >>>> can't get it to stick after I close Terminal and reopen a new one.
    >>>>
    >>>> Am I forgetting something?
    >>> Yes. You forgot that PS1 is set in your ~/.bashrc file. Edit that
    >>> file.
    >>>
    >>> stonerfish

    >> Well, hmm. That's not how I changed it the first time.

    >
    > Are you using bash?
    >
    >


    Yes I am. I used your clue and looked at .bashrc. I only understand the
    simplest of scripts so I couldn't make much sense of it. I deleted it and
    replaced it with a copy of the backup that was there, .bashrc~. That seems
    to have returned the prompt to its original condition, so I guess it was
    successful. Thanks.

    I still don't understand why I was able to change the prompt last week using
    only the PS1= method, but was unable to change it again.


    --
    Hobart

  6. Re: Shell prompt (bash)

    Hobart wrote:

    > jellybean stonerfish wrote:
    >> On Fri, 26 Sep 2008 01:37:34 -0400, Hobart wrote:
    >>
    >>> jellybean stonerfish wrote:
    >>>> On Fri, 26 Sep 2008 00:27:52 -0400, Hobart wrote:
    >>>>
    >>>>> A couple weeks ago I changed my prompt using PS1="new_prompt_here",
    >>>>> and it worked fine. Today I decided that I don't care for my new
    >>>>> prompt and tried changing it to something else. It works but now I
    >>>>> can't get it to stick after I close Terminal and reopen a new one.
    >>>>>
    >>>>> Am I forgetting something?
    >>>> Yes. You forgot that PS1 is set in your ~/.bashrc file. Edit that
    >>>> file.
    >>>>
    >>>> stonerfish
    >>> Well, hmm. That's not how I changed it the first time.

    >>
    >> Are you using bash?
    >>
    >>

    >
    > Yes I am. I used your clue and looked at .bashrc. I only understand the
    > simplest of scripts so I couldn't make much sense of it. I deleted it and
    > replaced it with a copy of the backup that was there, .bashrc~. That
    > seems to have returned the prompt to its original condition, so I guess it
    > was
    > successful. Thanks.
    >
    > I still don't understand why I was able to change the prompt last week
    > using only the PS1= method, but was unable to change it again.
    >
    >
    > --
    > Hobart


    If you used PS1= in a terminal, the prompt will remain that way as long as
    you remain in that terminal session. To make a prompt permanent for all
    terminal sessions, you'd edit it in .bashrc

    Cheers.

    --
    The world can't afford the rich.


  7. Re: Shell prompt (bash)

    On Fri, 26 Sep 2008 02:44:28 -0400, Hobart wrote:

    > jellybean stonerfish wrote:
    >> On Fri, 26 Sep 2008 01:37:34 -0400, Hobart wrote:
    >>
    >>> jellybean stonerfish wrote:
    >>>> On Fri, 26 Sep 2008 00:27:52 -0400, Hobart wrote:
    >>>>
    >>>>> A couple weeks ago I changed my prompt using PS1="new_prompt_here",
    >>>>> and it worked fine. Today I decided that I don't care for my new
    >>>>> prompt and tried changing it to something else. It works but now I
    >>>>> can't get it to stick after I close Terminal and reopen a new one.
    >>>>>
    >>>>> Am I forgetting something?
    >>>> Yes. You forgot that PS1 is set in your ~/.bashrc file. Edit that
    >>>> file.
    >>>>
    >>>> stonerfish
    >>> Well, hmm. That's not how I changed it the first time.

    >>
    >> Are you using bash?
    >>
    >>
    >>

    > Yes I am. I used your clue and looked at .bashrc. I only understand the
    > simplest of scripts so I couldn't make much sense of it. I deleted it
    > and replaced it with a copy of the backup that was there, .bashrc~.
    > That seems to have returned the prompt to its original condition, so I
    > guess it was successful. Thanks.


    In my default .bashrc, there are a two lines that can set PS1. The
    script will decide which to use, based on whether or not TERM is set to
    "xterm-color". If I want to change my prompt to something else, I do not
    need to understand the script. I just add a line to the end with
    PS1="new_prompt_here"


    >
    > I still don't understand why I was able to change the prompt last week
    > using only the PS1= method, but was unable to change it again.


    The fact that you had a backup .bashrc~ is a good sign that you did
    edit .bashrc, and you did forget. By definition, if you forgot doing it,
    you won't remember doing it. Just let it go, and add a PS1= line at the
    end of your .bashrc.


  8. Re: Shell prompt (bash)

    jellybean stonerfish wrote:
    > [snip]
    >
    >> I still don't understand why I was able to change the prompt last week
    >> using only the PS1= method, but was unable to change it again.

    >
    > The fact that you had a backup .bashrc~ is a good sign that you did
    > edit .bashrc, and you did forget. By definition, if you forgot doing it,
    > you won't remember doing it. Just let it go, and add a PS1= line at the
    > end of your .bashrc.
    >


    I must be losing my mind. I read the .bashrc file carefully and my current
    prompt was not in there, and I don't have any recollection of editing the
    file. Having said that, the prompt is now fixed.

    Thanks for your help.

    --
    Hobart

  9. Re: Shell prompt (bash)

    On Fri, 26 Sep 2008 14:19:18 -0400, Hobart wrote:

    > jellybean stonerfish wrote:
    >> [snip]
    >>
    >>> I still don't understand why I was able to change the prompt last week
    >>> using only the PS1= method, but was unable to change it again.

    >>
    >> The fact that you had a backup .bashrc~ is a good sign that you did
    >> edit .bashrc, and you did forget. By definition, if you forgot doing
    >> it, you won't remember doing it. Just let it go, and add a PS1= line
    >> at the end of your .bashrc.
    >>
    >>

    > I must be losing my mind. I read the .bashrc file carefully and my
    > current prompt was not in there, and I don't have any recollection of
    > editing the file. Having said that, the prompt is now fixed.
    >
    > Thanks for your help.


    What version of ubuntu are you using?
    Can you post the output of the command "grep PS1 .bashrc"
    If PS1 isn't set in your .bashrc file, it may be set from /etc/profile
    or /etc/bash.bashrc
    Confusing, yes. But that is what you get when you let someone else build
    your system.

    sf

  10. Re: Shell prompt (bash)

    jellybean stonerfish wrote:
    > [snip]
    >
    > What version of ubuntu are you using?
    > Can you post the output of the command "grep PS1 .bashrc"
    > If PS1 isn't set in your .bashrc file, it may be set from /etc/profile
    > or /etc/bash.bashrc
    > Confusing, yes. But that is what you get when you let someone else build
    > your system.
    >
    > sf


    Sure. Here are all three you mentioned.

    ------------ grep PS1 .bashrc ----------------------
    [ -z "$PS1" ] && return

    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$
    '
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
    PS1="\u:\w\$"
    ---------------------------------------------------

    That last line I just added myself a couple of hours ago. My current prompt
    is: hobart:~$






    ______________________ etc/profile ___________________________
    # /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
    # and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).

    if [ -d /etc/profile.d ]; then
    for i in /etc/profile.d/*.sh; do
    if [ -r $i ]; then
    . $i
    fi
    done
    unset i
    fi

    if [ "$PS1" ]; then
    if [ "$BASH" ]; then
    PS1='\u@\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

    umask 022
    __________________________________________________ __________




    ----------------- etc/bash.bashrc -----------------------------
    # System-wide .bashrc file for interactive bash(1) shells.

    # To enable the settings / commands in this file for login shells as well,
    # this file has to be sourced in /etc/profile.

    # If not running interactively, don't do anything
    [ -z "$PS1" ] && return

    # check the window size after each command and, if necessary,
    # update the values of LINES and COLUMNS.
    shopt -s checkwinsize

    # set variable identifying the chroot you work in (used in the prompt below)
    if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
    debian_chroot=$(cat /etc/debian_chroot)
    fi

    # set a fancy prompt (non-color, overwrite the one in /etc/profile)
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '

    # Commented out, don't overwrite xterm -T "title" -n "icontitle" by default.
    # If this is an xterm set the title to user@host:dir
    #case "$TERM" in
    #xterm*|rxvt*)
    # PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'
    # ;;
    #*)
    # ;;
    #esac

    # enable bash completion in interactive shells
    #if [ -f /etc/bash_completion ]; then
    # . /etc/bash_completion
    #fi

    # sudo hint
    if [ ! -e $HOME/.sudo_as_admin_successful ]; then
    case " $(groups) " in *\ admin\ *)
    if [ -x /usr/bin/sudo ]; then
    cat <<-EOF
    To run a command as administrator (user "root"), use "sudo ".
    See "man sudo_root" for details.

    EOF
    fi
    esac
    fi

    # if the command-not-found package is installed, use it
    if [ -x /usr/lib/command-not-found ]; then
    function command_not_found_handle {
    # check because c-n-f could've been removed in the meantime
    if [ -x /usr/lib/command-not-found ]; then
    /usr/bin/python /usr/lib/command-not-found -- $1
    return $?
    else
    return 127
    fi
    }
    fi
    ---------------------------------------------------

    --
    Hobart

  11. Re: Shell prompt (bash)

    On Fri, 26 Sep 2008 18:10:19 -0400, Hobart wrote:

    > jellybean stonerfish wrote:
    >> [snip]
    >>
    >> What version of ubuntu are you using? Can you post the output of the
    >> command "grep PS1 .bashrc"



    >
    > ------------ grep PS1 .bashrc ---------------------- [ -z "$PS1" ] &&
    > return
    >
    > PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:

    \[\033[01;34m\]\w\[\033[00m\]\$
    > '
    > PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
    > PS1="\u:\w\$"
    > ---------------------------------------------------
    >
    > That last line I just added myself a couple of hours ago. My current
    > prompt is: hobart:~$
    >
    >


    Ok, you know how to make your change permanent. Don't forget! 87)

    It might be a good idea in the future, when you edit such a config file
    to place a comments in the file.


    # FOLLOWING ARE CHANGES I ADDED TO THIS FILE
    # This will set my prompt.
    PS1="\u:\w\$"


    That way in the future you will have a way to remember what you added,
    and what to remove to get back to the default config.

+ Reply to Thread