Portal » Login    Forum    Register    Search    FAQ

Board index » Developers » Other Programming Languages




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Custom bash prompt
 Post Posted: Mon Aug 17, 2009 8:33 am 
Offline
Computer God
Computer God
User avatar

Joined: Sun Dec 09, 2007 7:57 pm
Posts: 408
The bash prompt is the first thing you see when you log into a *nix machine.
Customizing you bash prompt is easy, very useful and ofcourse, cool. Here are some tips n tricks. The prompt of your bash shell can be changed by altering the PS1 shell variable. To try out shell modifications you can directly do this, try the code below
Code:
PS1="hey there! #"


causing your prompt to be displayed as,
Code:
hey there ! #


Now thats cool, but it ain't useful yet. You can make your prompt useful by using certain escape sequences which are replaced by useful values. Example -
Code:
u - Username
h - Hostname
w - The current working directory with complete path.
W - The current working directory.
d - Current date.
t - Time.

Setting the value of PS1 at the prompt will only be temporary and the next time you run bash, the changes won't be seen. For permanent changes, you must add the PS1 statements into .bashrc or any of the startup scripts that bash processes. Here are some useful prompts that might be of use -
Code:
PS1="[u@h w]"
PS1="[u@h W]"
PS1="d t W >"
PS1="w $"

_________________
What would you attempt to do if you knew you couldn't fail?


Top 
 Profile  
 
 Post subject: Re: Custom bash prompt
 Post Posted: Mon Aug 31, 2009 9:30 pm 
Offline
Computer God
Computer God
User avatar

Joined: Tue Jan 20, 2009 3:14 am
Posts: 414
Location: Kampala
Another reason why Linux/Unix is going nowhere.

There are so many Linux Distros. What the Linux faithful should be aiming at is to create one OS which can be used by all folks. The young, youth and the Old.

How can my kid bro or mom learn all those shell commands.

Obuntu is kind of user friendly.I wish it could become the official linux distribution.

"Too many cooks spoil the soup."

_________________
The person who says it cannot be done should not interrupt the person doing it.


Top 
 Profile  
 
Display posts from previous:  Sort by  
 
Post new topic Reply to topic  [ 2 posts ] 

Board index » Developers » Other Programming Languages


Who is online

Users browsing this forum: No registered users and 1 guest

 
 

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Jump to:  
cron