LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   change profile to show current directory (https://www.linuxquestions.org/questions/linux-newbie-8/change-profile-to-show-current-directory-280280/)

jpolachak 01-20-2005 06:03 PM

change profile to show current directory
 
What do I need to add to my .profile file so that the user logged in will show his current absolute path?

Thanks,
Jason

chrism01 01-20-2005 06:34 PM

Edit your .bashrc to look like this:
# User specific aliases and functions

Code:

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

or borrow the appropriate line

Dark_Helmet 01-20-2005 07:36 PM

Quote:

Originally posted by jpolachak
... so that the user logged in will show his current absolute path?
Are you referring to the shell prompt?

If so, then you want to modify the PS1 environment variable. From a command line, execute these statements:
Code:

echo $PS1
should see some output
export PS1='\u@\h:\w\$ '

That should change your prompt to look something like this:
jpolachak@hostname:/current/directory$

"\u" is replaced by the user name
"\h" is replaced by the host's name
"\w" is replace by your current directory (with a ~ representing your home directory)
"\$" is replaced with a $ if you're a normal user or a # if you're the super user

You can do lots of customization. Type man bash and search for the PROMPTING heading (hit the forwad slash ( / ) and type PROMPTING; hit "n" until you find the proper section heading). It will list the backslash codes and what they translate to.

If you find something you like, make the change permanent by putting your PS1 assignment into your ~/.bash_profile. If you don't see a line that gives a value to PS1 in that file, then just add the export command above to the end of the file. Just substitute your customized sequence instead of what I used.


All times are GMT -5. The time now is 09:56 AM.