[olug] Unix Tip: WHERE AM I ALWAYS

Brian Wiese bwiese at cotse.com
Fri Mar 14 05:18:46 UTC 2003


In bash (bourne again shell) I often times find myself deep in some
directory path, usually looking at my class homework, or some web
directory and such... for example:

bwiese at franklin:/mnt/lib-data/backups/freedom-laptop/CLASSES/CURR/forensi
cs/homework/assign1$

yeah, we can all agree that's ugly, but at times I like my bash prompt to
tell me exactly where I am at - in case there are more than one directory
with the same name on the system.  I check out my current shell prompt
config like so... echo $PS1

bwiese at franklin:/mnt/lib-data/backups/freedom-laptop/CLASSES/CURR/forensi
cs/homework/assign1$ echo $PS1\u@\h:\w\$

To see what can be done about this, I did a 'man bash' and the pertinent
information is under the "PROMPTING" section, just do a "/PROMPTING" to
get there, hit "n" (for next) twice.  The "W" gives the current directory
while "w" gives the current path.

So I change my prompt like so... PS1="\u@\h:\W\$ "  (leave a space after
the $ with your quotes so it looks nice when you type)

bwiese at franklin:/mnt/lib-data/backups/freedom-laptop/CLASSES/CURR/forensi
cs/homework/assign1$ PS1="\u@\h:\W\$ " bwiese at franklin:assign1$ pwd
/mnt/lib-data/backups/freedom-laptop/CLASSES/CURR/forensics/homework/assi
gn1

And hey, thats what the "pwd" command is for when you need it!  If you
prefer this prompt style, edit your ~/.bashrc to set it as so for every
time you start a bash session....
or to simply cut down on the path length, create a symbolic link to the
prefered directory. (I usually tend to get the target/link arguments
switched up... but it should be of the form 'where you want to go' and
'how you want to get there')

ln -s <target dir> <link location>

$ ln -s
/mnt/lib-data/backups/freedom-laptop/CLASSES/CURR/forensics/homework/assi
gn1 ~/assign1


On Thu, 13 Mar 2003 11:25:17 -0800
Unix Guru Universe <listserv at ugu.com> wrote:

|
|=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
|			      UNIX GURU UNIVERSE 
|			         UNIX HOT TIP
|
|			Unix Tip 1898 - March 13, 2003
|
|		    http://www.ugu.com/sui/ugu/show?tip.today
|
|=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
|
|WHERE AM I ALWAYS
|
|In csh, if you always want to know 
|where you are, put in your .cshrc-file 
|the following 2 lines:
|
|alias sp 'set prompt="`hostname`:`pwd`> "'  
|alias cd 'cd \!*;sp'
|
|
|
|------------------------------------------------------------------------
|-- To Subscribe:    http://www.ugu.com/sui/ugu/show?tip.subscribe
|To Unsubscribe:  http://www.ugu.com/sui/ugu/show?tip.unsubscribe
|To Submit A Tip: http://www.ugu.com/sui/ugu/show?tip.today
|
|========================================================================
|== DISCLAIMER: All UNIX HOT TIPS ARE OWNED BY THE UNIX GURU UNIVERSE AND
|ARE NOT TO BE SOLD, PRINTED OR USED WITHOUT THE WRITTEN CONSENT OF THE
|UNIX GURU UNIVERSE. ALL TIPS ARE "USE AT YOUR OWN RISK". UGU  ADVISES
|THAT ALL TIPS BE TESTED IN A NON-PRODUCTION DEVELOPMENT ENVIRONMENT
|FIRST.
|
|Unix Guru Universe - www.ugu.com - tips at ugu.com - Copyright 1994-2001
|========================================================================
|==
|
|_______________________________________________
|OLUG mailing list
|OLUG at olug.org
|http://lists.olug.org/mailman/listinfo/olug
|


  Brian Wiese | bwiese at cotse.com | aim: unolinuxguru
------------------------------------------------------
  GnuPG/PGP key 0x1E820A73 | "FREEDOM!" - Braveheart 
------------------------------------------------------  
This is not about Napster or DVDs. It's about your Freedom.
  I'll see your DMCA and raise you a First Amendment.
              http://www.anti-dmca.org


More information about the OLUG mailing list