New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Join today!

• Get your questions answered by community gurus • Advice and insight from world-class Apple enthusiasts • Exclusive access to members-only contests, giveaways and deals


OS X - Operating System General OS operation information and support

Reply  
Thread Tools
pkri

 
Member Since: Jul 09, 2008
Posts: 8
pkri is on a distinguished road

pkri is offline
OS 10.5 - Customizing the terminal prompt on Mac

Iam using Mac OS X 10.5.2. Strangely, i dont have a .bashrc file on the users home folder. So i set out to create one. This is what i did.

First i created .bashrc by doing 'touch .bashrc'. Then i filled the following contents.

# User @ Host - working dir
#export PS1=”\u@\h\w$ ”
export PS1="\u@\h\w: "


In order to force Terminal.app to load .bashrc at the start: i opened terminal.app and then i opened preferences dialog. navigated to the startup section. Then i selected 'shells open with' under 'command(complete path)'. I gave the path as

/bin/bash –-rcfile /Users/pradeep/.bashrc --> pradeep is my username

Then i opened the new terminal window to check if it took effect, but there was no change.
am i doing something wrong ?

Best,
Pkri
Reply With Quote
mac57

 
mac57's Avatar
 
Member Since: Apr 29, 2006
Location: St. Somewhere
Posts: 4,547
mac57 has a brilliant futuremac57 has a brilliant futuremac57 has a brilliant futuremac57 has a brilliant futuremac57 has a brilliant futuremac57 has a brilliant futuremac57 has a brilliant futuremac57 has a brilliant futuremac57 has a brilliant futuremac57 has a brilliant futuremac57 has a brilliant future
Mac Specs: PowerMac G5 Quad, 2.5 GHz, 4 Core, 120 GB SSD, 500 GB HDD

mac57 is offline
I didn't have to do anything to my Terminal.app settings to get it to load .bashrc. Bash should do this automatically.

However, I believe that Terminal.app creates login shells. Hence, it will look for and process .bash_profile, not .bashrc. I have a one line .bash_profile in my home directory that just contains the line

Code:
source .bashrc
That does the trick for me.

My Macs: PowerMac G5 Quad, 2.5 GHz, 4 Core, Mac Pro, 3.2 GHz 8 Core, Power Macintosh 7500/100
My iStuff: 32 GB iPhone 4, 30 GB iPod Video, 16 GB iPod Touch
My OS': Mac OS X Tiger, Mac OS X Snow Leopard, Mac OS X Leopard, Mac OS 8.6, openSUSE 10.3, Win XP
I was on the Mac-Forums honor roll for September 2007
Reply With Quote
tux08902
Guest
 
Posts: n/a

Terminal.app isn't as customizable as standard Unix terminals. You won't really be able to change colors and such as much as you would be able on say Xterm or Urxvt. You may want to just use Xterm through X.
Reply With Quote
cradom

 
cradom's Avatar
 
Member Since: Feb 14, 2004
Location: South-East Texas
Posts: 1,478
cradom is just really nicecradom is just really nicecradom is just really nicecradom is just really nicecradom is just really nice
Mac Specs: 21in Dual core 3 ghz iMac, 13in Macbook - Snow Leopard, didn't care for Lion

cradom is offline
Unless there's a lot of differences between Tiger and Leopard...
Bash will read a .bashrc just fine, assuming you've restarted Terminal.
There's no need to "force" it to read from preferences.
Terminal is very customizable, type "man bash" (without the quotes) in Terminal.
Goto http://www.dotfiles.com/ and look at/download some of the OS X files.
All kinds of ways to customize prompts and more.
My favorite is bash_styles.

Quiet people have the loudest minds
... Stephen Hawking
Reply With Quote
Dysfunction

 
Dysfunction's Avatar
 
Member Since: Mar 17, 2008
Location: Tucson, AZ
Posts: 6,016
Dysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant future
Mac Specs: 2008 and 2011 15" mbps, late 11 iMac, iPhone 4s, and too many ipods and other stuff

Dysfunction is offline
It'll also process .profile automatically.

mike
This machine kills fascists
Got # ? phear the command line!
Reply With Quote
pkri

 
Member Since: Jul 09, 2008
Posts: 8
pkri is on a distinguished road

pkri is offline
But i don't find .bashrc, .bash_profile and .profile. When i tried loading them as nano .bashrc, i didnt get any tab completion. That's why i tried to create a .bashrc myself.
This is what i did now, i opened bash shell and then typed

bash --rcfile /Users/pradeep/.bashrc (or) bash -i

now the changes i mentioned in .bashrc works!! But when i open the new terminal the changes go away. I think this means it reads off /etc/bashrc first while starting up the machine or while opening a new terminal window, and not ~./bashrc. But ~./bashrc is invoked only when i do bash -i.

Last edited by pkri; 07-10-2008 at 05:11 AM.
Reply With Quote
cradom

 
cradom's Avatar
 
Member Since: Feb 14, 2004
Location: South-East Texas
Posts: 1,478
cradom is just really nicecradom is just really nicecradom is just really nicecradom is just really nicecradom is just really nice
Mac Specs: 21in Dual core 3 ghz iMac, 13in Macbook - Snow Leopard, didn't care for Lion

cradom is offline
If you have a .bash_profile in your home dir, put this in it:
Code:
# include .bashrc if it exists

if [ -f ~/.bashrc ]; then
    source ~/.bashrc
fi
That will make bash read your .bashrc in your home dir.
.bashrc is not in your home dir by default. You are supposed to create one to make changes to your $PATH or to make aliases, etc.
It needs to be plain text and executable as a linux file.
chmod +x .bashrc
will make it executable.

Quiet people have the loudest minds
... Stephen Hawking
Reply With Quote
Dysfunction

 
Dysfunction's Avatar
 
Member Since: Mar 17, 2008
Location: Tucson, AZ
Posts: 6,016
Dysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant future
Mac Specs: 2008 and 2011 15" mbps, late 11 iMac, iPhone 4s, and too many ipods and other stuff

Dysfunction is offline
there won't be any of them by default, you'll have to create them

Try doing a cp -p .bashrc .profile && . ./.profile

mike
This machine kills fascists
Got # ? phear the command line!
Reply With Quote
Reply

« Mismatched Icons | Black highlighted box »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
Running Windows on Mac rickmahmoud Running Windows (or anything else) on your Mac 7 02-16-2008 11:31 PM
Apples History.. Bainzey Schweb's Lounge 3 01-11-2007 10:33 PM
Mac info needed nork Switcher Hangout 15 12-01-2006 11:51 AM
Mac Users Get More ISP Choices schweb Apple Rumors and Reports 1 03-06-2003 10:57 AM

All times are GMT -4. The time now is 02:57 AM.

Powered by vBulletin
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.