OESF Portables Forum

General Forums => General Discussion => Topic started by: bb on February 29, 2004, 08:55:25 am

Title: How to get PS1 to show anything useful?
Post by: bb 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*.
Title: How to get PS1 to show anything useful?
Post by: tumnus 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
Title: How to get PS1 to show anything useful?
Post by: havoc 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
Title: How to get PS1 to show anything useful?
Post by: bb 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.
Title: How to get PS1 to show anything useful?
Post by: ericglam 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\'?
Title: How to get PS1 to show anything useful?
Post by: tumnus 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
Title: How to get PS1 to show anything useful?
Post by: ericglam 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?
Title: How to get PS1 to show anything useful?
Post by: tumnus 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)
Title: How to get PS1 to show anything useful?
Post by: ericglam 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)
Title: How to get PS1 to show anything useful?
Post by: dtruchan on March 20, 2004, 07:42:11 pm
This is how bash reads the shell startup and shutdown files.

Startup (in this order):