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 |
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 > " Code:
PS1="\[\033[0;34m\]mierin\[\033[0m\]:\u \w > " HTH |
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 :)
|
You're very welcome - glad I could help ya! :D
|
The coloured sintax just rocks.
[\u@\h (\w)]\$ This is the one I use, and now im gunna color it :) |
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? :) |
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 %~ > " |
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!
|
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?
|
"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... |
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 :) |
Aha, fasta, it's you and me both, getting lost in the terminals :p
|
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 |
Quote:
|
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. |