LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Bash, Gnome-Terminal and Prompt Mysteries (https://www.linuxquestions.org/questions/slackware-14/bash-gnome-terminal-and-prompt-mysteries-114058/)

melquiades 11-09-2003 07:54 AM

Bash, Gnome-Terminal and Prompt Mysteries
 
hi all,
I'm having some trouble and could really do with a hand out of the mud. It started off because I was tryingt o edit the prompt I see in gnome-terminal from a fairly useless "$ " to "[user] /currentDirectory >"

so after doing some reading I edited the '/etc/profile' to have a default prompt of "[\u] \w >" (which is the conrtol characters needed for my chosen prompt). Ok, saved and exited vi. the root prompt works fine, just as planned, both within X and outwith it too. However my personal; day-to-day account keeps coming up with just plain old "$" - damn! so I play around a bit more and discover that when I launch gnome-terminal, for some reason it is asking /etc/profile for a an '/bin/ash' shell prompt and not a default bash - so I tried editing the default /bin/ash prompt in /etc/profile and now I get the following prompt

[\u] \w >

i.e. it's not working out the control character and just printing the syntax form - arrggh!

I've tried searching for helps with this but I'm getting really lost and don't want to edit too many files in case I forget all my changes and really screw something up - I just want a prompt within gnome-terminal for my usual username (chris) that actually gives me some decent info (i.e. username and current directory) rather than just "$"
it's weird but this has got to be the hardest thing I've tried to do in slackware in my 2 months of using it - it's been the easiest distro around in my experience and there's always a handy answer so I'm kinda in shock that something so simple has taken up about 8 hours of my life so far!

please help 'coz I think I'm losing my marbles :D

thanks in advance,
cheers
mlqds

Bebo 11-09-2003 08:07 AM

First of all, look in your /etc/passwd to see what shell you have defined. Do a echo $SHELL too. To change the shell for the current user, do chsh -s /bin/bash if it's bash you want to have. For some reason I usually also have to change the $SHELL variable too, to make it work. Don't really know why. When you change the shell with chsh, make sure that the shell exists! And don't just write bash, but the whole path (/bin/bash)! I friend of mine did a chsh -s /bin/tsch once. Guess if it didn't work :)

Now, if the shell is correct, you should be able to set your prompt by putting a line such as

Code:

PS1="[\u] \w > "
in /etc/profile or /etc/bashrc or where appropriate. I'm using something as strange as

Code:

PS1="\[\033[0;34m\]mierin\[\033[0m\]:\u \w > "
:p

HTH

melquiades 11-09-2003 08:58 AM

You're a genius, thank you so much, it worked a treat! I am now the proud owner of a useful, informative bash prompt! :D isn't it alway the little things that stump you! I managed to write a php front-end to a database without hardly any errors yesterday and today a tiny shell prompt has me perplexed for hours! haha! the brain's a funny old thing, thanks again bebo :)

Bebo 11-10-2003 03:14 AM

You're very welcome - glad I could help ya! :D

fasta 11-10-2003 05:00 AM

The coloured sintax just rocks.

[\u@\h (\w)]\$

This is the one I use, and now im gunna color it :)

fasta 11-10-2003 05:24 AM

Try this one out (i just modified mine and it kinda rocks...)

PS1="[\u@\h][\[\033[1;34m\]\[$(date +%I:%M)\]\[\033[0m\]]\[\033[1;31m\]\w\[\033[0m\] $ "

gives you this result:

[root@fasta][12:20]/path/you/are/in $

pretty funky huh? :)

Bebo 11-10-2003 05:53 AM

Very nice :) But does the date string really work? I mean, is it updated? Doesn't it just show the time when you set the prompt? That is actually the reason why I use tcsh - just for the sake of getting a nice prompt :)

My prompt, in tcsh:

Code:

set prompt="%B%m%b:%n %T %~ > "

melquiades 11-10-2003 05:57 AM

that's pretty cool fasta, I like the directory in red, nice and clear, I think I'm gonna try using that. Another useful thing I've found is adding a newline (\n) at the beginning of the prompt, it helps to seperate out your feedback from programs and I've found actually speeds up my work a little because the the layout is clearer - thanks for sharing fasta!

melquiades 11-10-2003 06:03 AM

I don't find the time on the prompt to be very useful, in fact it's kinda distrcating for me, I try to go for the minimalist approach, hence no hostname, but it's really interesting how different people feel comfortable with different amounts and styles of information at the prompt - ahh poor windows users and they're lack of a command line! :D Do you find tcsh better all round, or is it just the prompt abilities that drew you to it bebo?

fasta 11-10-2003 06:11 AM

"SHARING IS MY PHILOSOPHY" :)
the hostname is very useful to me since I ssh around servers all day long and most likely get lost switching term windows back and forth :)
The hour is just because I am lazy and dont wanna move my wrist :) LOL
I love the "\n" hint, gonna use it immediately!!!

Bebo: actually it does not update the hour. Ill look if i can change it...

Bebo 11-10-2003 06:20 AM

Yep, poor windows users :)

I'm pretty inconsistent in what shell I'm using. As you may have seen from my posts here (and I'm sorry I wasn't clearer on this) I'm using bash for root and tcsh as a user. The only reason for this is that I want my prompt to display proper time - although only as a user, not as root. Don't ask me why... ;) Moreover, when I'm scripting I use bash, never tcsh, and I would like to script more in sh, just because I think that's cooler :p

The reason I include host name in my prompt(s) is since I'm working a lot from home, logged in on my work computer. I find it useful to know on which computer I'm removing files :)

Bebo 11-10-2003 06:23 AM

Aha, fasta, it's you and me both, getting lost in the terminals :p

melquiades 11-10-2003 07:33 AM

Ah you see I rarely ssh around at present so username only for me, but yeah can imagine that its pretty important to stop your self getting lost! for interests sake here's what I'm using at present, and pretty happy with,

PS1="\n\u:\[\033[1;33m\] \w\[\033[0m\] \n> "

which gives :-

user: current/dir
>

with the current dir in yellow, takes up quite a lot of screen room but with enough screen real estate works nicely, not 100% about the yellow though :D

fasta 11-10-2003 07:51 AM

Quote:

from bebo:
I find it useful to know on which computer I'm removing files
LOL !!!!

fasta 11-10-2003 07:58 AM

BTW: like bash uses bash_profile, tcsh uses --->?
Could u guys tell me pls?
Thx


All times are GMT -5. The time now is 04:30 PM.