LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Showing full path in Terminal. (https://www.linuxquestions.org/questions/slackware-14/showing-full-path-in-terminal-647788/)

glore2002 06-08-2008 09:38 AM

Showing full path in Terminal.
 
Here I am again! Sorry, sorry! :-)

How can I show full path prompt in Terminal? Now, I always see bash-3.1$ as the prompt. I know I could use pwd to check where I am standing at a certain moment but it would be easier if I could always see the full path at the command prompt.

Thank you!

Glore 2002.-

Nylex 06-08-2008 09:41 AM

You want to use the "\w" flag in your PS1 environment variable. For example, in my .bashrc I have

export PS1='\u@\h:\w\$ ',

where \u is for username, \h for hostname and \$ for the prompt symbol ($ for regular user, # for root). Edit: you may like to look at this.

glore2002 06-08-2008 10:30 AM

Thank Nylex!
 
Thanks Nylex for your help. I already changed my prompt with your explanation. Now, it looks much better and self explanatory.

Glore2002.-

shadowsnipes 06-08-2008 11:26 AM

Personally, I like to add colors and newlines to mine so that they are more readable. For some I change the title bars as well.

You can also vary what you get depending upon what terminal you are using (screen session, xterm, std console, etc). Here's a snippet

Code:

case "$TERM" in
xterm*|rxvt*)
        # PROMPT_COMMAND Sets title.
        PROMPT_COMMAND='echo -ne "\033]0;$(date +%T) - ${USER}: ${PWD/$HOME/~}\007"'
        export PS1="\n[ \t ] \n\[\e[34;1m\]\u@\[\e[31;1m\]\H:\w\n\[\e[0m\]$> "
        ;;
screen*)
        PROMPT_COMMAND='echo -ne "\033]0;$(date +%T) - ${USER}: ${PWD/$HOME/~}\007"'
        export PS1="\nScreen Session: [ \t ]\n\[\e[34;1m\]\u@\[\e[31;1m\]\H:\w\n\[\e[0m\]$> "
        ;;
linux*)
        export PS1="\nPhil's Terminal Prefs \t\a\n\[\e[34;1m\]\u@\[\e[31;1m\]\H:\w\n\[\e[0m\]$> "
        ;;
*)
        # First section attempts to set title with "\n\[\e]2;"
        # Title ends at first '\n' after title escape sequence
        # If setting title not possible, then "\n\[\e]2" is ignored and the ';' is shown along with contents of title.
        # On some terminals the entire title section will be ignored.
        export PS1="\n\[\e]2;Phil's Terminal Prefs \t\n\[\e[34;1m\]\u@\[\e[31;1m\]\H:\w\n\[\e[0m\]$> "
        ;;
esac



All times are GMT -5. The time now is 06:27 PM.