User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Shell Scripting section within the Software Development category of DaniWeb, a massive community of 363,779 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,579 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Shell Scripting advertiser:
Oct 25th, 2007
Views: 1,279
This code changes color of prompt according to user, suppose if user is root then color would be red and normal user would have color black. This'll diffrentiate in users.
bash Syntax
  1. if [ $(id -u) -eq 0 ];
  2. then # you are root, set red colour prompt
  3. PS1="\[$(tput setaf 1)\]\u@\h:\w #\[$(tput sgr0)\]"
  4. else # normal
  5. PS1="\u@\h:\w $"
  6. fi
Post Comment

Only community members can submit or comment on code snippets. You must register or log in to contribute.

DaniWeb Marketplace (Sponsored Links)
All times are GMT -4. The time now is 10:39 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC