LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-06-2006, 06:19 AM   #1
Jongi
Senior Member
 
Registered: Aug 2003
Distribution: Debian Sid 32/64-bit, F10 32/64-bit
Posts: 1,070

Rep: Reputation: 45
Command prompt display


I want to change the command prompt to display as:

<name of current user> : <full directory path> #

So as an example

jongi:/home/jongi#

How does one go about doing this?
 
Old 05-06-2006, 07:44 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2392Reputation: 2392Reputation: 2392Reputation: 2392Reputation: 2392Reputation: 2392Reputation: 2392Reputation: 2392Reputation: 2392Reputation: 2392Reputation: 2392
Hi,

You can change your prompt (PS1) to a lot of different things. What's possible, what is not and how to do it depends on the shell your are using. Linux defaults to bash (most of the time), so that's what I'm going to assume (dangerous, I know).

All the possibilities are mentioned in the PROMPTING section of the bash manpage.

An echo $PS1 will show your current setting.

Ok, to change your prompt to <name of current user> : <full directory path> # you need to set PS1 to the following: \u:\w#

\u => (current) username
\w => (current) working directory. If you are in your homedir a ~ is shown, otherwise the full path.

You can set your (default) PS1 prompt by editing /etc/profile or make it local by editing one of the appropriate files in your homedir (don't know if that is .bashrc, .profile or .bash_profile on your box).

Before making permanent changes try it on the command line first:

PS1="\u:\w#"

And see if you like the result.

Here are some relevant URL's:

Bash Prompt Howto
Prompt Magic
Extending the Bash Prompt

Hope this clears things up.
 
Old 05-06-2006, 07:57 AM   #3
Jongi
Senior Member
 
Registered: Aug 2003
Distribution: Debian Sid 32/64-bit, F10 32/64-bit
Posts: 1,070

Original Poster
Rep: Reputation: 45
Very helpful post. Thanks.
 
  


Reply

Tags
prompt


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Command line/ command prompt saiinch Linux - Newbie 5 03-17-2006 03:29 AM
display time in the prompt rpb Linux - General 1 05-18-2005 05:03 PM
Key stroke/command to shut down x and go into the command prompt screen? Fear58 Linux - General 1 07-14-2004 08:14 PM
Command Prompt? eXdener Linux - Newbie 3 01-05-2004 05:38 PM
How to recall an old command at the command prompt? J_Szucs Linux - Newbie 9 03-07-2003 01:29 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 07:12 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