Author Topic: How to get PS1 to show anything useful?  (Read 5030 times)

bb

  • Jr. Member
  • **
  • Posts: 88
    • View Profile
    • http://
How to get PS1 to show anything useful?
« on: February 29, 2004, 08:55:25 am »
Has anyone here succeeded in getting PS1 to show anything useful on a terminal? It seems to me there is an issue with busybox not being very willing to work with PS1 the way one\'s used to from bash.
I have tried this in ~/.bashrc:
export PS1=\'u@h:w# \'
that just gives me *exactly* the string assigned to PS1. With this:
export PS1=\"$USER@$HOSTNAME:$PWD# \"
the shell variables are expanded as the PS1 variable is being set, and the prompt doesn\'t change even if I \'su\' or change into another directory. Using singlequotes for the latter string results in the variables not being expanded *at all*.
Best regards,
bb
SL-C860, Cacko 1.23 ROM
512MB SanDisk SD, Origo CF WiFi

tumnus

  • Hero Member
  • *****
  • Posts: 1176
    • View Profile
    • http://www.cpinkney.org.uk
How to get PS1 to show anything useful?
« Reply #1 on: February 29, 2004, 02:06:08 pm »
In my .bashrc I have

export PS1=\'[w]$ \'

And it works fine. Are you sure you are using bash and not sh? Make sure you are set to use /bin/bash in /etc/passwd
# Search the Zaurus Howtos ## Search the Zaurus FAQs ## Find Z software at ELSI #
--------------------
UK SL5500 with Sharp ROM 3.13, SL5600 with Sharp ROM 1.32 - SuSE 9.0 Pro, Windows XP Home
Qualendar for Calendar and Todo
Socket Bluetooth CF Card (Rev F), Kingmax 512MB MMC Card, Palm Tungsten T Stylus,
Pretec CF->Smartmedia Adapter, Semsons Universal Battery Extender

havoc

  • Jr. Member
  • **
  • Posts: 69
    • View Profile
    • http://www.galacticslacker.com/
How to get PS1 to show anything useful?
« Reply #2 on: February 29, 2004, 04:53:39 pm »
Tumnus is on it.

I found that I can get the results I expected (after modifying /etc/passwd to make my shell /bin/bash for both root and zaurus) by using .profile in my home directories.

Here\'s what I use:

PS1=\"h | t d | [$(jobs|wc -l|sed -e \'s/ *//\')]nu@W $ \"

... no \"export\" required from .profile

havoc

bb

  • Jr. Member
  • **
  • Posts: 88
    • View Profile
    • http://
How to get PS1 to show anything useful?
« Reply #3 on: March 02, 2004, 12:05:31 pm »
Quote
Tumnus is on it.
I found that I can get the results I expected (after modifying /etc/passwd to make my shell /bin/bash for both root and zaurus) by using .profile in my home directories.
Here\'s what I use:
PS1=\"h | t d | [$(jobs|wc -l|sed -e \'s/ *//\')]nu@W $ \"
... no \"export\" required from .profile
I suffered from the assumption that /bin/bash *was* the used shell, since I\'m used to /bin/sh being symlinked to /bin/bash. I should\'ve checked that, of course. I see that /bin/sh is symlinked to /bin/ash. After changing the user\'s shell to /bin/bash PS1 works as I\'m used to.
Thank you for your answers.
Best regards,
bb
SL-C860, Cacko 1.23 ROM
512MB SanDisk SD, Origo CF WiFi

ericglam

  • Newbie
  • *
  • Posts: 11
    • View Profile
How to get PS1 to show anything useful?
« Reply #4 on: March 14, 2004, 03:18:11 pm »
Quote
I found that I can get the results I expected (after modifying /etc/passwd to make my shell /bin/bash for both root and zaurus)

This works, but how do you make your new prompt stick?  Everytime I restart the terminal program on the SL5600 I have to run a script to reset the PS1 otherwise it is back to the default.  To make this question more general; where is the terminal getting its defaults from as \'user zaurus\'?

tumnus

  • Hero Member
  • *****
  • Posts: 1176
    • View Profile
    • http://www.cpinkney.org.uk
How to get PS1 to show anything useful?
« Reply #5 on: March 14, 2004, 05:48:22 pm »
It may differ depending on your ROM, but it should be either /home/zaurus/.profile or /home/zaurus/.bashrc
# Search the Zaurus Howtos ## Search the Zaurus FAQs ## Find Z software at ELSI #
--------------------
UK SL5500 with Sharp ROM 3.13, SL5600 with Sharp ROM 1.32 - SuSE 9.0 Pro, Windows XP Home
Qualendar for Calendar and Todo
Socket Bluetooth CF Card (Rev F), Kingmax 512MB MMC Card, Palm Tungsten T Stylus,
Pretec CF->Smartmedia Adapter, Semsons Universal Battery Extender

ericglam

  • Newbie
  • *
  • Posts: 11
    • View Profile
How to get PS1 to show anything useful?
« Reply #6 on: March 17, 2004, 01:10:40 am »
Quote
it should be either /home/zaurus/.profile or /home/zaurus/.bashrc

I have a /root/.profile and a /home/root/.profile   and not a .bashrc in sight.  Editing either .profile does not seem to do much.  When I restart the terminal program I am back to the same defaults under either bash or sh.  Grepping the entire Zaurus file system for variables that the set command brings up does not shed any light on what’s happening or where my defaults are comming from.  What is there that is exporting these variables?

tumnus

  • Hero Member
  • *****
  • Posts: 1176
    • View Profile
    • http://www.cpinkney.org.uk
How to get PS1 to show anything useful?
« Reply #7 on: March 17, 2004, 03:24:00 am »
Currently you are probably using an in-built default in bash. So to change it you need to put something like this in /home/zaurus/.profile and then restart your terminal session:

export PS1=\'[w]$ \'

The 5600 runs as the user \'zaurus\' by default, so when you open the terminal app, you will be using /home/zaurus/.profile . I also linked /home/zaurus/.bashrc to /home/zaurus/.bashrc just in case like this:

cd /home/zaurus
ln .profile .bashrc

(This is a hard link BTW, so both filenames point to the real file)
# Search the Zaurus Howtos ## Search the Zaurus FAQs ## Find Z software at ELSI #
--------------------
UK SL5500 with Sharp ROM 3.13, SL5600 with Sharp ROM 1.32 - SuSE 9.0 Pro, Windows XP Home
Qualendar for Calendar and Todo
Socket Bluetooth CF Card (Rev F), Kingmax 512MB MMC Card, Palm Tungsten T Stylus,
Pretec CF->Smartmedia Adapter, Semsons Universal Battery Extender

ericglam

  • Newbie
  • *
  • Posts: 11
    • View Profile
How to get PS1 to show anything useful?
« Reply #8 on: March 20, 2004, 11:20:46 am »
Quote
ln .profile .bashrc

Hard linking  .bashrc to .profile did the trick.    

Thanks very much.  It is little things like this that drive me bonkers. (the very first thing that I had tried to do was create a /home/zaurus/.profile - with no result of course)

dtruchan

  • Jr. Member
  • **
  • Posts: 89
    • View Profile
    • http://
How to get PS1 to show anything useful?
« Reply #9 on: March 20, 2004, 07:42:11 pm »
This is how bash reads the shell startup and shutdown files.

Startup (in this order):
    /etc/profile - login shell only
          .bash_profile - login shell only  
          .bash_login - login shell only, if .bash_profile not found  
          .profile - login shell only, if .bash_profile and .bash_login not found  
          .bashrc - interactive, non-login shells  
          $BASH_ENV - non-interactive shells, if it is defined
      Shutdown:
        .bash_logout    login shell only  
          Bourne Shell Compatibility:
            When the bash shell is invoked with the name sh, it attempts to mimic the startup sequence of the original Bourne shell.
            It runs commands in /etc/profile followed by ~/.profile, if these files exist.
    860 Debian EABI
    Lexar Cards
    WCF11 v2.5
    Mittoni SD-CF Adapter
    Gentoo