LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-08-2010, 10:11 AM   #1
richman1234
LQ Newbie
 
Registered: Mar 2010
Distribution: Fedora12 & Angstrom
Posts: 22

Rep: Reputation: 0
default shell prompt


I have looked almost everywhere for how to change my default shell prompt. When I open my bash shell, the prompt is [fedora-dev@Fedora-Dev Documents]$. I would like it to open at fedora-dev@Fedora-Dev]$.

Can someone tell me where to change this at. I have looked in .bashrc, etc/profile, and environmental variables.

Thanks,
Rich
 
Old 07-08-2010, 10:20 AM   #2
pr_deltoid
Member
 
Registered: Jun 2010
Distribution: Fedora
Posts: 289

Rep: Reputation: 41
http://www.linuxconfig.org/Bash_prompt_basics
http://www.ibm.com/developerworks/li.../l-tip-prompt/
EDIT: removed the first link and added two different ones.

Last edited by pr_deltoid; 07-08-2010 at 10:25 AM.
 
Old 07-08-2010, 10:43 AM   #3
imagine_me2
Member
 
Registered: Nov 2009
Location: Kolkata, India
Distribution: Fedora 11
Posts: 136

Rep: Reputation: 22
How do you open your terminal? If you use any launcher check any command line arguments that may be passed.
 
Old 07-08-2010, 11:00 AM   #4
vikas027
Senior Member
 
Registered: May 2007
Location: Sydney
Distribution: RHEL, CentOS, Debian, OS X
Posts: 1,298

Rep: Reputation: 102Reputation: 102
Lightbulb

PS1 variable is used to change or set shell prompt.

See this http://www.cyberciti.biz/tips/howto-...up-prompt.html

Example
Add this line in your $HOME/.bash_profile
Code:
PS1="[\d \t \u@\h:\w ] $ "; export PS1
 
Old 07-08-2010, 11:05 AM   #5
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 18,484

Rep: Reputation: 3970Reputation: 3970Reputation: 3970Reputation: 3970Reputation: 3970Reputation: 3970Reputation: 3970Reputation: 3970Reputation: 3970Reputation: 3970Reputation: 3970
Quote:
Originally Posted by richman1234 View Post
I have looked almost everywhere for how to change my default shell prompt. When I open my bash shell, the prompt is [fedora-dev@Fedora-Dev Documents]$. I would like it to open at fedora-dev@Fedora-Dev]$.

Can someone tell me where to change this at. I have looked in .bashrc, etc/profile, and environmental variables.

Thanks,
Rich
.bashrc is where you need to look. Specifically, you can set the PS1 environment variable to do what you want. I like how I've got mine, so I'll share:
Code:
PS1="\[\033[1;36m\][\u@\[\033[1;37m\]\h:\[\033[1;33m\]\w]\\$\[\033[0m\] "
SUDO_PS1="\[\033[1;31m\][\u@\[\033[1;37m\]\h:\[\033[1;33m\]\w]\\$\[\033[0m\] "
Yes, it looks horrible. However, those are actually color-codes, that affect the different variables. It actually comes out to be:
[username@Hostname:Working Directory]$

For a regular user. The Hostname: piece is white text (I use a black background on my terminal...your mileage may vary) When I SUDO (the SUDO_PS1 variable), into a shell, the user ID changes to "root@" in bright red. That way, I know what user ID I'm using, on what machine, in what directory, just by my prompt. The red is a good visual indicator of "be careful!".

Last edited by TB0ne; 07-08-2010 at 11:06 AM.
 
Old 07-08-2010, 11:16 AM   #6
rsciw
Member
 
Registered: Jan 2009
Location: Essex (UK)
Distribution: Home: Debian/Ubuntu, Work: Ubuntu
Posts: 206

Rep: Reputation: 44
I never liked the default bash shell on fedora/centos/etc, being used to the debian default bash, which is:

Code:
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
which will appear as
home: achim@Warbird:~$
other dir: achim@Warbird:/usr/lib$

however now with my preferred shell, zsh, I have
Code:
PROMPT='${red}%n${NC}@${NC}%m${NC}:%~%%${NC}> '
whereas {red} and {NC} are colour settings,
showing as:
home: achim@Warbird:~%>
other dir: achim@Warbird:/usr/lib64%>

useful imo also, same as TB0ne does
Code:
case `whoami` in
    root)
         PROMPT='${RED}%n${NC}@${BLUE}%m${RED}:%~${GREEN}%%${NC}> '
    ;;
esac
showing as:

root@Warbird:/home/achim%>


Last edited by rsciw; 07-08-2010 at 11:17 AM.
 
Old 07-09-2010, 08:58 AM   #7
richman1234
LQ Newbie
 
Registered: Mar 2010
Distribution: Fedora12 & Angstrom
Posts: 22

Original Poster
Rep: Reputation: 0
Thanks a lot. Good information, and good links.
Rich
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
I'd like to change the default shell prompt. lynnevan Linux - General 9 09-08-2011 08:00 AM
passing parameters from a unix shell prompt into a windows cmd.exe prompt nano2 Programming 1 09-01-2009 11:26 AM
LXer: Shell tip: Set the shell prompt and themes in Linux Terminal LXer Syndicated Linux News 0 06-12-2007 03:02 AM
'sh' shell - Actually calls legacy Bourne shell, or uses system default? Dtsazza Linux - Software 1 10-28-2005 09:20 AM
default prompt nero64 Linux - Newbie 6 12-10-2002 06:16 PM


All times are GMT -5. The time now is 12:54 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration