On newer distributions you can easily change your terminal prompt, (which is controlled by the PS1 environment variable, btw) by adding a file with the prompt format string to the /etc/profile.d directory. You may name the file whatever you like, e.g. set-prompt.sh, but make sure that inside it there is a line that sets PS1 (PS1="....."). Here’s a nice one which shows, in the prompt, the entire path to where you currently are and allows you to double click it for easy copy-paste action:

if [ "$PS1" ]; then
    PS1="\u@\h \w\\$ "

In distributions where the /etc/profile script does not use a loop to load all the files in the profile.d directory you can edit either /etc/profile or /etc/bashrc and add the PS1 definition in there manually. Look for lines looking like this (this is the proper location to add the def):

    # Turn on checkwinsize
    shopt -s checkwinsize
   [ "$PS1" = "\\s-\\v\\\$ " ] && PS1="\u@\h \w\\$ "
    # You might want to have e.g. tty in prompt (e.g. more virtual machines)

Tagged with:

Leave a Reply

Your email address will not be published. Required fields are marked *

Set your Twitter account name in your settings to use the TwitterBar Section.