Prompt \w gives relative path

This is a discussion on Prompt \w gives relative path within the Linux Programming forums, part of the Platform Specific Boards category; When I use \w to set my prompt in bashrc (using ubuntu, if it makes a difference) it shows prompt ...

  1. #1
    Registered User
    Join Date
    Feb 2009
    Posts
    12

    Prompt \w gives relative path

    When I use \w to set my prompt in bashrc (using ubuntu, if it makes a difference)

    it shows prompt as

    ~/sources
    vivek-laptop:vivek

    while i want it to be like

    /home/vivek/sources
    vivek-laptop:vivek

    Where am I making the mistake?

  2. #2
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    That is not a relative path. The tilde (~) is your home directory. Eg, if you log in as root and go to the same place, you will see /home/vivek, since ~ for root is (usually) /root.

    I don't think you would be using the bash prompt in this way, but generally if you need to replace a ~ which has been output it is equal to the $HOME environment variable.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  3. #3
    {Jaxom,Imriel,Liam}'s Dad Kennedy's Avatar
    Join Date
    Aug 2006
    Location
    Alabama
    Posts
    1,065
    okay, let's try that again. . . you'd want to put this in (somewhere)
    Code:
    PS1="\${PWD}# "
    and the best thing to do is to try it out first via export PS1="\${PWD}# "

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Buidl Library with ./configure script
    By Jardon in forum C Programming
    Replies: 6
    Last Post: 07-24-2009, 09:36 AM
  2. How to judge whether a path is relative or absolute?
    By bbebfe in forum C Programming
    Replies: 2
    Last Post: 11-16-2008, 02:23 AM
  3. MSVC: output .pd under relative path?
    By pheres in forum Windows Programming
    Replies: 0
    Last Post: 02-04-2008, 09:55 AM
  4. Path of file relative to program
    By ulillillia in forum C Programming
    Replies: 13
    Last Post: 04-15-2007, 05:30 AM
  5. linked list recursive function spaghetti
    By ... in forum C++ Programming
    Replies: 4
    Last Post: 09-02-2003, 02:53 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21