LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Command prompt display (https://www.linuxquestions.org/questions/linux-general-1/command-prompt-display-442149/)

Jongi 05-06-2006 05:19 AM

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?

druuna 05-06-2006 06:44 AM

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.

Jongi 05-06-2006 06:57 AM

Very helpful post. Thanks.


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