LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 11-09-2003, 07:54 AM   #1
melquiades
Member
 
Registered: Jul 2003
Location: Northern Scotland
Distribution: Slackware 9.1
Posts: 48

Rep: Reputation: 15
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

thanks in advance,
cheers
mlqds
 
Old 11-09-2003, 08:07 AM   #2
Bebo
Member
 
Registered: Jul 2003
Location: Göteborg
Distribution: Arch Linux (current)
Posts: 553

Rep: Reputation: 31
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 > "


HTH

Last edited by Bebo; 11-09-2003 at 08:08 AM.
 
Old 11-09-2003, 08:58 AM   #3
melquiades
Member
 
Registered: Jul 2003
Location: Northern Scotland
Distribution: Slackware 9.1
Posts: 48

Original Poster
Rep: Reputation: 15
You're a genius, thank you so much, it worked a treat! I am now the proud owner of a useful, informative bash prompt! 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
 
Old 11-10-2003, 03:14 AM   #4
Bebo
Member
 
Registered: Jul 2003
Location: Göteborg
Distribution: Arch Linux (current)
Posts: 553

Rep: Reputation: 31
You're very welcome - glad I could help ya!
 
Old 11-10-2003, 05:00 AM   #5
fasta
Member
 
Registered: Aug 2003
Location: Livorno - Italy
Distribution: Debian
Posts: 84

Rep: Reputation: 15
The coloured sintax just rocks.

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

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

Last edited by fasta; 11-10-2003 at 05:29 AM.
 
Old 11-10-2003, 05:24 AM   #6
fasta
Member
 
Registered: Aug 2003
Location: Livorno - Italy
Distribution: Debian
Posts: 84

Rep: Reputation: 15
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?
 
Old 11-10-2003, 05:53 AM   #7
Bebo
Member
 
Registered: Jul 2003
Location: Göteborg
Distribution: Arch Linux (current)
Posts: 553

Rep: Reputation: 31
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 %~ > "
 
Old 11-10-2003, 05:57 AM   #8
melquiades
Member
 
Registered: Jul 2003
Location: Northern Scotland
Distribution: Slackware 9.1
Posts: 48

Original Poster
Rep: Reputation: 15
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!
 
Old 11-10-2003, 06:03 AM   #9
melquiades
Member
 
Registered: Jul 2003
Location: Northern Scotland
Distribution: Slackware 9.1
Posts: 48

Original Poster
Rep: Reputation: 15
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! Do you find tcsh better all round, or is it just the prompt abilities that drew you to it bebo?
 
Old 11-10-2003, 06:11 AM   #10
fasta
Member
 
Registered: Aug 2003
Location: Livorno - Italy
Distribution: Debian
Posts: 84

Rep: Reputation: 15
"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...
 
Old 11-10-2003, 06:20 AM   #11
Bebo
Member
 
Registered: Jul 2003
Location: Göteborg
Distribution: Arch Linux (current)
Posts: 553

Rep: Reputation: 31
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

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
 
Old 11-10-2003, 06:23 AM   #12
Bebo
Member
 
Registered: Jul 2003
Location: Göteborg
Distribution: Arch Linux (current)
Posts: 553

Rep: Reputation: 31
Aha, fasta, it's you and me both, getting lost in the terminals
 
Old 11-10-2003, 07:33 AM   #13
melquiades
Member
 
Registered: Jul 2003
Location: Northern Scotland
Distribution: Slackware 9.1
Posts: 48

Original Poster
Rep: Reputation: 15
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
 
Old 11-10-2003, 07:51 AM   #14
fasta
Member
 
Registered: Aug 2003
Location: Livorno - Italy
Distribution: Debian
Posts: 84

Rep: Reputation: 15
Quote:
from bebo:
I find it useful to know on which computer I'm removing files
LOL !!!!
 
Old 11-10-2003, 07:58 AM   #15
fasta
Member
 
Registered: Aug 2003
Location: Livorno - Italy
Distribution: Debian
Posts: 84

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


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
change default bash directory in gnome-terminal ming0 Linux - Software 5 10-01-2009 06:54 PM
gnome-terminal fails to give bash prompt wfhoney Red Hat 8 04-21-2004 03:38 PM
How can I change the terminal prompt? ICO Slackware 4 02-15-2004 08:09 AM
no prompt in terminal xyfan Linux - Newbie 1 12-05-2003 11:25 PM
terminal with no prompt fletch88 Red Hat 0 11-17-2003 12:45 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 02:26 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration