*BSD News Article 44012


Return to BSD News archive

Path: sserve!newshost.anu.edu.au!harbinger.cc.monash.edu.au!yarrina.connect.com.au!classic.iinet.com.au!news.uoknor.edu!news.ecn.uoknor.edu!paladin.american.edu!howland.reston.ans.net!news.sprintlink.net!kaleka.seanet.com!news.seanet.com!michaelv
From: michaelv@MindBender.HeadCandy.com (Michael L. VanLoon)
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Re: Unix/FreeBSD versions of DOS utilities
Date: 13 May 1995 05:16:30 GMT
Organization: HeadCandy Associates... Sweets for the lobes.
Lines: 133
Message-ID: <MICHAELV.95May12221630@MindBender.HeadCandy.com>
References: <3ojlul$r3c@warp.cris.com>
NNTP-Posting-Host: mindbender.seanet.com
In-reply-to: Da_worm@cris.com's message of 7 May 1995 23:43:17 GMT

In article <3ojlul$r3c@warp.cris.com> Da_worm@cris.com (DAWORM) writes:

   Does anyone know of a method/program to simulate some of the DOS 
   directory enhancement utilities.  Namely, what I am looking for are 
   PROMPT and NCD (Norton Change Directory) and RIR (Rock Island 
   Directory).  For those who totally disdain DOS (and if I loved it so 
   much, I wouldn't have installed FreeBSD!), these programs do the following.

   PROMPT - Lets you set a customized command prompt with features like 
   [...]

You definitely have been stuck in DOS land for too long!  Dealing with
brain-dead DOS shells will ruin your brain.

You don't need utilities for these.  You need a decent shell.  If you
don't already have it, get a copy of tcsh.  (You can do similar things
with ksh and zsh, two other modern shells, but I don't use them, so
I'm only telling you how to do this in tcsh.)

One of Windows NT greatest weaknesses is that they still use the
crappy DOS shell -- it doesn't deserve to be in the same class with
modern unix shells (for many more reasons than the few I'll touch on
here).

Any unix shell will let you alter the prompt.  A good one like tcsh
will do everything you want.  Here's an excerpt from the man page
(edited for brevity):

       The format for the prompt shell variable has been  changed
       to  include  many  new things, such as the current time of
       day, current working directory, etc..  The new format uses
       "%<char>"  to  signal  an expansion, much like printf(3S).
       The available sequences are:

             %/          Current working directory.
             %~          cwd.  If it starts with $HOME, that part is
             %c or %.    Trailing component of cwd, may be
             %C          Trailing component of cwd, may be followed
             %h, %!, !   Current history event number.
             %M          The full machine hostname.
             %m          The hostname up to the first ".".
             %S (%s)     Start (stop) standout mode.
             %B (%b)     Start (stop) boldfacing mode. (Only if
             %U (%u)     Start (stop) underline mode. (Only if
             %t or %@    Current time of day, in 12-hour, am/pm format.
             %T          Current time of day, in 24-hour format.
             %p Current time in 12-hour format, am/pm format with
             %P          Current time in 24-hour format, with seconds.
             \c          `c' is parsed the same way as in bindkey.
             ^c          `c' is parsed the same way as in bindkey.
             %%          A single %.
             %n          The user name, contents of $user.
             %d          The weekday in <Day> format.
             %D          The day in dd format.
             %w          The month in <Mon> format.
             %W          The month in mm format.
             %y          The year in yy format.
             %Y          The year in yyyy format.
             %l          The line (tty) the user is logged on.
             %L          clear from prompt to end of display or end of line.
             %#          A `#' if tcsh is run as a root shell,
             %{..%}      Include string as a literal escape sequence.
             %?          return code of the last command executed just
             %R          In prompt3 this is the corrected string; in

The prompt string I use is:

	[%B%n%b@%B%m%b]%B%c3%b%#

Which looks like this when I'm in (for example) /usr/src/sys/arch/i386:

	[michaelv@MindBender]sys/arch/i386>

Or like this when I'm in my home dir:

	[michaelv@MindBender]~>

(Of course the bold-facing doesn't work over email/Usenet.)


   NCD - This program, when first ran, creates a database of sorts of all of 
   the directories on the drive.  Then, by typing "ncd dirname" it change 
   the directory to the first/closest match to dirname it finds.  So if I 
   [...]

Just set the cdpath variable to the paths where you want it to look.
My cdpath looks like this:

	(/usr/home/michaelv /usr/home/michaelv/projects
	 /usr/home/michaelv/misc /usr/home/michaelv/bin
	 /usr/home/michaelv/bin/i386 /usr/home/michaelv/tmp /sys /usr/src/bin
	 /usr/src/sbin /usr/src/usr.bin /usr/src/usr.sbin
	 /usr/src/usr.local.bin /usr/src/lib /usr/src/libexec /usr/src/share
	 /usr/src/gnu)

If I'm in my home dir and type ``cd fsck'', I get this:

	[michaelv@MindBender]~> cd fsck
	/usr/src/sbin/fsck 
	[michaelv@MindBender]src/sbin/fsck>

   RIR - Actually, ls handles 90% of RIR, but the one thing RIR does is 
   allow you to see the contents of archived files.  It shows the archive 
   name, then indents the contents.

I'm not sure what you're talking about.  What do you mean ``archived
files''?

However, it doesn't matter -- you're mixing functionality.  The
beautify of unix is its simplicity and modularity.  The ls command
accomplishes a single purpose, and combines with other commands to
build more complex tools out of simple building blocks.  Ls was never
intended to show the contents of files.

If I could figure out what exactly you're describing, maybe I could
tell you how to do it in unix.  I'd need more info, though.  (Feel
free to mail me privately.)

   I apologize in advance if any of this sounds stupid, but once you get 
   used to something, it's hard to give it up!

It's not stupid -- it's just obvious that you're thinking in a DOS
(constricted) mind set.  Step back another step and try to see things
from a bigger perspective.  Good luck.

--
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  Michael L. VanLoon                                 michaelv@HeadCandy.com
       --<  Free your mind and your machine -- NetBSD free un*x  >--
     NetBSD working ports: 386+PC, Mac, Amiga, HP300, Sun3, Sun4, PC532,
                           DEC pmax (MIPS R2k/3k), DEC/AXP (Alpha)
     NetBSD ports in progress: VAX and others...
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -