Go Back  Mac-Forums.com  > Software > OS X - Operating System > OS 10.5 - Customizing the terminal prompt on Mac

Reply
 
LinkBack Thread Tools
Old 07-09-2008, 02:04 PM   #1 (permalink)
pkri

 
Member Since: Jul 09, 2008
Posts: 8
pkri is on a distinguished road
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
pkri is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Stumble this post
Reply With Quote
Old 07-09-2008, 03:16 PM   #2 (permalink)
mac57

 
mac57's Avatar
 
Member Since: Apr 29, 2006
Location: St. Somewhere
Posts: 4,538
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: Mac Pro, 3.2 GHz 8 Core, 8 GB RAM, 2*750 GB Disk, nVidia 8800 GT
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: Mac Pro, 3.2 GHz 8 Core, MacBook Pro, 2.2 GHz C2D
My iStuff: 32 GB iPhone 3G S, 30 GB iPod Video, 16 GB iPod Touch
My OS': Mac OS X Leopard, Mac OS X Tiger, openSUSE 10.3, Win XP
I was on the Mac-Forums honor roll for September 2007
mac57 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Stumble this post
Reply With Quote
Old 07-09-2008, 03:26 PM   #3 (permalink)
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.
 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Stumble this post
Reply With Quote
Old 07-09-2008, 10:59 PM   #4 (permalink)
cradom

 
Member Since: Feb 14, 2004
Location: South-East Texas
Posts: 1,143
cradom is a jewel in the roughcradom is a jewel in the roughcradom is a jewel in the rough
Mac Specs: 21in Dual core 3 ghz iMac - Snow Leopard
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.
cradom is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Stumble this post
Reply With Quote
Old 07-09-2008, 11:13 PM   #5 (permalink)
Dysfunction

 
Dysfunction's Avatar
 
Member Since: Mar 17, 2008
Location: Tucson, AZ
Posts: 3,581
Dysfunction is a glorious beacon of lightDysfunction is a glorious beacon of lightDysfunction is a glorious beacon of lightDysfunction is a glorious beacon of lightDysfunction is a glorious beacon of lightDysfunction is a glorious beacon of light
Mac Specs: 15" mbp, too many ipods and other stuff
It'll also process .profile automatically.
__________________
mike
Warning: Sharp chisels are dangerous and should be handled with care. Dull chisels are even more dangerous and should be sharpened.
Got # ? phear the command line!
Dysfunction is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Stumble this post
Reply With Quote
Old 07-10-2008, 04:47 AM   #6 (permalink)
pkri

 
Member Since: Jul 09, 2008
Posts: 8
pkri is on a distinguished road
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.
pkri is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Stumble this post
Reply With Quote
Old 07-10-2008, 11:08 AM   #7 (permalink)
cradom

 
Member Since: Feb 14, 2004
Location: South-East Texas
Posts: 1,143
cradom is a jewel in the roughcradom is a jewel in the roughcradom is a jewel in the rough
Mac Specs: 21in Dual core 3 ghz iMac - Snow Leopard
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.
cradom is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Stumble this post
Reply With Quote
Old 07-10-2008, 12:45 PM   #8 (permalink)
Dysfunction

 
Dysfunction's Avatar
 
Member Since: Mar 17, 2008
Location: Tucson, AZ
Posts: 3,581
Dysfunction is a glorious beacon of lightDysfunction is a glorious beacon of lightDysfunction is a glorious beacon of lightDysfunction is a glorious beacon of lightDysfunction is a glorious beacon of lightDysfunction is a glorious beacon of light
Mac Specs: 15" mbp, too many ipods and other stuff
there won't be any of them by default, you'll have to create them

Try doing a cp -p .bashrc .profile && . ./.profile
__________________
mike
Warning: Sharp chisels are dangerous and should be handled with care. Dull chisels are even more dangerous and should be sharpened.
Got # ? phear the command line!
Dysfunction is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Stumble this post
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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 On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Running Windows on Mac rickmahmoud Windows, Classic, Linux, and Other OS 7 02-16-2008 11:31 PM
Apples History.. Bainzey Anything Goes 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

 
 
 
     
Home Calendar Get New
     

Hosted by LiquidWeb


Copyright ©2001-2010 Mac-Forums.com. All Rights Reserved. A division of iNET Interactive.

Other iNET Interactive Sites: Web Hosting Talk | Swish Talk | Hosting Catalog.com| Dev Papers| Deleted Domains| Hot Scripts

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