LinuxQuestions.org
Visit Jeremy's Blog.
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
 
LinkBack Search this Thread
Old 05-06-2006, 05: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, 06:44 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Location: the Netherlands
Distribution: lfs, debian, rhel
Posts: 7,514
Blog Entries: 1

Rep: Reputation: 1139Reputation: 1139Reputation: 1139Reputation: 1139Reputation: 1139Reputation: 1139Reputation: 1139Reputation: 1139Reputation: 1139
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, 06: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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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


All times are GMT -5. The time now is 10:58 AM.

Main Menu
 
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
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration