Norton Change Directory (NCD) clones
The Norton Utilities
releases were collections of software utilities.
Peter Norton
published the first version for
DOS, The Norton Utilities,
Release 1, in 1981. Release 2 came out several years later, long with the first
hard drives for the IBM PC line. Release 4 for was around 1987 and was the first
in which the set of utilities became more or less stable.
Version 4 of NU was the version of NU were Norton Change Directory (NCD)
was introduced. It was written by Brad Kingsbury. Later he recollected those
early days in the following way:
I joined Peter Norton Computing in 1985, as the company’s first programmer.
My previous employer had just closed its doors, so I had sent my resume to a
few companies in the area. Peter responded, flew me to Seattle where he was
vacationing for the summer, and hired me on the spot. Because Peter was still
on vacation, I worked out of a hotel in Seattle for my first two weeks on the
job. After that, I spent another six months working from the Nortons’ kitchen
table. When Eileen, Peter’s wife, started cooking dinner, I knew it was time
to call it a day and head home.
... My job responsibility was to develop the software, and that's what I did.
I just developed the programs, and that was pretty
much the last day Peter programmed.
The PNCI staff was up to five now. Peter did
his writing, managing and marketing from the den of his home. The three clerical
people worked upstairs...
Peter Norton has always been a laid-back person. His whole philosophy, and I've
heard him quote this many times, was, "We're
going to do this business stuff while it's fun.'" So that was
our primary focus that first it has to be fun, and second it has to make money.
"I never knew what would happen if we didn't make any money and it was still
fun. It probably wouldn't have been too fun at that point, especially for Peter,''
says Kingsbury. "But he wasn't out to create the next greatest generation of
software, he wasn't out to make a whole lot of money. It was really to have
fun and he enjoyed the flexibility of not having to work under someone else.''
PNCI reached $5 million in revenues in 1986. It published several other software
packages but, according to Kingsbury, the Norton Utilities was still PNCI's
cash cow. Utility software was gaining wider acceptance in the microcomputer
industry as users realized the advantages of data recovery.
It soon was improved in the release of Norton Utilities 4.5. Peter Norton's company
was sold to Symantec in 1990 and at this point Norton Utilities were doomed.
Soon NDD disappeared from the package. Later Norton Utilities themselves disappeared
from Symantec product line as they were replaced by eclectic collection of utilities
company bought called Norton Systemworks. The latter included
Norton AntiVirus, Norton Utilities, and a number of other utilities that expanded
as Symantec purchased more utilities companies. SystemWorks continues to be a suite
of utilities, but Norton Utilities is no longer available as a separate package.
The importance of Norton Change Directory (NCD) is that it inspired
OFM file managers navigation paradigm. But it was important
stand-alone utility in its own right.
The key idea was probably partially borrowed from
Xtree (Ytree
clone for Linux is available for most linux distributions) but it was
refined for quick navigation of complex directory trees and proved to be very influential:
- Builds a database of all directories (or all subdirectories of a
certain directory). In simple clones find command that stores the list
of directories into gzip archive is usually used. Sometimes multiple
archives are used (one per each root directory) to speed up search. But generally
database is needed here as you need to compare modification date of the directory
with archive data to decide if you need to rescan the sub tree or not.
- Allows a user to search this database for directory names using regular
expressions and then cd to the directory. Along with
regular expressions some kind of "Directories
Morse Code" is often used when just initial letters of each subdirectory are
supplied. For example "ncd ulb"
means cd /usr/local/bin.
If multiple directories are found for the supplied "Directories Morse Code"
they are all displayed instead of jumping to the target directory (often with
leading numbers to simplify user choice).
Here multiple enhancements are possible for example but
"ncd ul+" means the second directory
that starts with letter "l" in the /usr
directory and ncd ul++ the
third such directory. Return on investment is unclear.
- Optionally (for example if invoked without parameters) provide a visual
interface to navigate the directory tree. NCD pioneered a new and
interesting style of visual navigation of directory tree which later became
common in OFM and best GUI-based filemanagers. Each letter typed serves as a
prefix for directory to find. Arrows permit moving to/out of branches. Ctrl-Enter
finds the next directory with the same prefix within the same branch.
This simple interface provided a very powerful way to change quickly from directory
to another without having to type in complex pathnames.
The most common modern implementation of NCD functionality can be found in OFM
managers, for example FAR.
Unfortunately none of Unix shells implements ncd
functionality out of the box. In a way Unix administrators are stuck with the navigational
paradigm (cd command) that definitely
outlived its usefulness and is completely unsuitable for modern filesystem with
their deeply nested directory structures. Therefore you need to extend it either
with a utility or with a script to get this functionality.
Several implementation of varying quality exists. Shell scripts are more flexible
and can be adapted to individual needs but complied versions are more powerful and
sometimes (like in case of kcd -- actually a very interesting
implementation with some novel ideas of its own) provide functionality close to
ncd.
At one time a Unix version of Norton Utilities was developed and marketed by
Interactive Systems Corp. On September 26, 1991 Sun Microsystems acquired the
Intel-UNIX operating system business from ISC and the product was scrapped. In 1994
it was later relaunched as "The Almond Utilities for UNIX" by
Dave
Mandelkern's company AlmondSeed Software. The product was successful
enough to sustain a commercial company and the company did not last long.
As of late 2007 Dave Mandelhern is CEO of QuickHealth. Here is the press
release:
AlmondSeed Software Announces The Almond Utilities for UNIX
-- Formerly The Norton Utilities for UNIX; Provides Disk and File Management
Tools --
MOUNTAIN VIEW, CA, February 14, 1994-- AlmondSeed Software, Inc. announced
today the availability of The Almond Utilities for UNIX, a comprehensive suite
of disk and file management tools that ease the complexity of UNIX. The product
was previously marketed as The Norton Utilities for UNIX under license from
Symantec Corporation, which currently provides the DOS and Macintosh versions
of The Norton Utilities and is the owner of The Norton Utilities trademark.
AlmondSeed announced the immediate availability of The Almond Utilities for
SCO UNIX and introduced The Almond Utilities for Sun SPARC, which is scheduled
for release in the second quarter of 1994.
While The Norton Utilities have gained enormous popularity among DOS, Windows
and Macintosh users for their ability to rescue inadvertently or accidentally
erased files and directories, this capability has been unavailable to UNIX users
since Interactive Systems Corporation ceased marketing the original Norton Utilities
for UNIX in early 1992. With the release of The Almond Utilities for UNIX, UNIX
system users can once again recover accidentally deleted files with The Almond
Utilities' file recovery tool, Almond UnRemove. In addition to its rescue features,
The Almond Utilities for UNIX diagnoses hard-disk problems, manages files and
replaces some of the unwieldy systems tools typical of UNIX with more user-friendly
products, including:
- Almond Disk Explorer--allows a user to explore any area of a
disk and make repairs to damaged file systems
- Almond ScrubDisk--protects confidential data by wiping an entire
logical disk to U.S. Dept. of Defense standards.
- Almond Change Directory--displays a full-screen graphical image
of the directory tree and allows users to interactively change directories.
- Almond Text Search and Almond File Find--searches for user-specified
text patterns in one or more files, and locates files whose names match
a specified pattern, or lists files in a specified directory.
Dave Mandelkern, president and chief executive officer of AlmondSeed Software,
Inc., said, "There is a strong potential for UNIX to thrive in the world of
mainstream desktop computing. By providing user-friendly, low-cost, shrink-wrapped
products for end-users, AlmondSeed hopes to increase the popularity and commercial
usage of UNIX on the desktop. The Norton Utilities is one of the consistently
best-selling utility packages for DOS and Macintosh, and we are pleased to make
similar capabilities available to today's UNIX users through The Almond Utilities."
Peter Norton, founder, Peter Norton Computing, Inc., said, "We originally
developed The Norton Utilities to take the average user's fear out of disk and
file management. AlmondSeed's product carries on our efforts to increase the
user-friendliness of UNIX and to offer the popular tools that are familiar in
the PC environment to UNIX system users."
"The Norton Utilities is the industry standard for disk and file management,
and we are pleased that AlmondSeed is relaunching the UNIX version as The Almond
Utilities for UNIX. Because of our cooperation with AlmondSeed, customers will
now be able to have a standard set of tools that runs across all of the major
computing platforms throughout their enterprise," said Ellen Taylor, Symantec's
vice president and general manager of the Peter Norton Group.
Availability and Pricing
The Almond Utilities for UNIX is available now for SCO UNIX and sells for
$495. System requirements are the SCO UNIX operating system, version 3.2.4.0
or higher with a STREAMS driver and optional SCO Link Kit software; 386, 486
or Pentium CPU; hard disk with 6 MB free disk space; 3.5" 1.44 MB disk media.
The product is packaged and documented in a style consistent with PC and Macintosh
software. VAR and distributor discounts are available.
AlmondSeed Software Inc.
AlmondSeed Software, Inc. is setting the industry standard for easy-to-use,
off-the-shelf UNIX software products in the sub-$500 price range. AlmondSeed
products are designed to boost the productivity of end-users and increase the
value of the UNIX desktop workstation to the enterprise. The privately-held
company can be reached at 444 Castro Street, Suite 440, Mountain View, CA 94041.
Tel: 415-968-5100, Fax: 415-969-8670.
Attempt to provide NCD functionality for Unix started long ago but none of the
was very successful. I really cannot understand why as the idea was simple and brilliant.
For example as recently as in April 2003 Unix Review published a note by Ed
Schaefer
Shell
Corner Changing Directories with ncd which compared two recent implementations:
Changing Directories with ncd
This month,
Fergal Goggin submits Korn/Bash script
ncd, a Unix version of the Norton change directory utility. Instead of typing
in long directory paths, using regular expressions, ncd greps a file for matches.
If ncd finds more than one match, the user is prompted to choose the required
directory.
After Fergal describes ncd, I contrast the ncd solution with Fred Brunet's
article,
fcd:
a Smart Change Directory (Sys Admin, November 1994), and I include
my testing results.
Introducing ncd
Norton change directory was a useful utility when I was using PCs in the
DOS days, but when I started using Unix, no equivalent existed so I created
ncd, which:
- Builds a database of all directories below shell variable $BASEDIR
(default is /). The database is a compressed file created by sending directories
to the gzip file.
- Allows a user to search this database for directory names using regular
expressions and then changes to the directory.
ncd should run in both Korn and Bash shells. I normally run it in an xterm
window. The scroll bar is very handy if there are loads of "hits". It should
run fine in a terminal (if you choose your regular expressions carefully!).
Since cd is called in the script, it should be dot executed.
I use an alias:
alias ncd='. /home/fgoggin/scripts/ncd.bash'
Once the alias exists, enter the directory to change to:
ncd
ncd vs. fcd
Essentially, Fred Brunet's
fcd script (fcd:
A Smart Change Directory) shares the same goal as Fergal's ncd — build a
database of full path directories, search the database, and allow the user to
choose the correct directory.
Where fcd uses traditional grep to search a flat ASCII file, ncd uses zrep
to search a gzip compressed file. Other "z" utilities exist for processing gzip
files — zdiff, zcat, and zmore.
Don't expect the "z" utilities to function consistently across Unix variants.
The Solaris 7 zcat expects the compressed file to have a "Z" extention. This
means zcat only works on files created with the compress utility. Conversely,
the Red Hat Linux 7.1 zcat version works on ncd's data file.
If the argument to fcd isn't exact, Brunet displays the matching directories
with a sequence number and prompts the user to choose one; ncd performs the
same function, but Fergal elegantly uses the select construct to generate a
menu of directories to choose from.
Testing ncd
I successfully tested ncd under Solaris 7 and Red Hat Linux 7.1. In the course
of my testing, I made two changes:
- I changed the default BASEDIR from root, /, to $HOME.
I decided to test as a regular, non-root user.
- My Solaris 7 home directory is actually a link to another directory.
For either fcd or ncd to work on a linked home directory, add the find -follow,
the link option:
find $BASEDIR -type d -follow 2> /dev/null | gzip > $NCDDATABASE
In ncd, the BOLD_TYPE and NORMAL_TYPE shell variables are hard-coded escape
sequences. You could use the tput command arguments for terminal control:
BOLD_TYPE=`tput smso`
NORMAL_TYPE=`tput smso`
In conclusion, fcd/ncd's obvious weakness is that the database file rapidly
obsoletes as the directory structure grows and shrinks. Consider dropping the
database file periodically.
Apparix allows fast command-line file system navigation by bookmarking directories
and jumping to a bookmark directly. The apparix command for jumping to a bookmark
is called to. By default to can use both bookmarks and regular
directory names and path names as targets. It is possible to jump to subdirectories
of a bookmark in a single to invocation. All three modes, bookmarks,
regular directories, and subdirectories of bookmarks, allow tab completion on
the query string. Additionally, apparix supplies commands ae (apparix
edit) and als (apparix ls) that can be used to invoke distant edit or
listing commands on files and subdirectories in bookmarked locations. Finally,
the portal command can be used to add all subdirectories of a given directory
as locations bookmarked by their relative name. Examples:
Change directory to the location bookmarked by mcl, say /nfs/cvs/mic/mcl/.
Change directory to a subdirectory of that, /nfs/cvs/mic/mcl/doc.
Change directory to a further subdirectory, /nfs/cvs/mic/mcl/doc/test.
to mcl <TAB> to mcl d<TAB> to mcl doc/te<TAB>
The first will generate directory completions for /nfs/cvs/mic/mcl/,
the second for /nfs/cvs/mic/mcl/d, the third for /nfs/cvs/mic/mcl/doc/te.
List the contents of /nfs/cvs/mic/mcl, /nfs/cvs/mic/mcl/doc,
respectively. Tab completion acts as for to.
Edit /nfs/cvs/mic/mcl/TODO. Tab completion generates all files in
the target directory matching the query pattern.
Edit /nfs/cvs/mic/mcl/doc/TODO.
todo mcl todo mcl doc clog mcl
Edit /nfs/cvs/mic/mcl/TODO, /nfs/cvs/mic/mcl/TODO,
/nfs/cvs/mic/mcl/ChangeLog, respectively. It depends on the user appreciation
and needs whether such custom edit commands are useful or not.
The portal command is described in the
apparix manual page.
The als function (distant listing with apparix) was updated.
You can now use shell expansion characters in the string optionally
specified after the bookmark:
(/homes/svd) als a 'src/*.c' /homes/svd/apparix/apparix/src/apparix.c
It is necessary to quote patterns containing shell wildcards in order
to prevent the current shell from trying to expand them. Find the
als function
here, and note
that its definition is quite simple. It is easy to further customize
apparix by deriving or creating your own variants of als-type
bash functions.
Get the most out of apparix
Bookmark projects, use subdirectory specification as in to proj
data.
For subdirectory specification use tab completion.
Use now to bookmark sudden hotspots of activity and unexpected
projects. Keep all now bookmarks, they mark the occasions which
put you off track and will help you find those off-track locations later.
to foo .. and to foo ../bar work and change to
the parent directory and sibling directory respectively.
Use todo proj to edit the TODO file for the project bookmarked
proj.
Use clog proj to edit the ChangeLog file for the project
bookmarked proj.
Apparix can be invoked with the option --shell-examples to get basic
functions for bookmarking and jumping. However, I've added a few other functions
that people may find useful, and changes to these functions occur more often
than changes to apparix itself. The extended set of bash functions is
available here. It
is recommended to name this file for example .bash_apparix in your
$HOME directory and to put the line source $HOME/.bash_apparix
in your $HOME/.bashrc file.
The functionality for CSH-like shells is much more limited in comparison,
mainly because of its deficiencies as a scripting language, or perhaps because
of my lack of ability. It is
available here.
I've had requests for ZSH apparix support. If someone writes it, please let
me know. The same applies to any shell, of course.
Apparix was inspired by
cdargs.
The HISTORY
section in the manual has a few more remarks on that. The CDargs homepage lists
two more cd-related applications. These are
wcd
— wherever CD. This utility will scan any filesystem you throw at it. It is
then possible to change/search directory by pattern and do a hundred things
more. It was pointed out to me that on some Unix/Linux flavours locate does
to a very large extent the same thing as wcd does - in creating a database describing
file systems. Combine the locate resources with standard UNIX utilities such
as grep in a small script such as goto, throw in CDargs
or apparix, and your setup is small, adaptible, powerful, and uses existing
resources. Still, I've tried wcd and it delivers what it promises.
kcd — k
CD. Seems similar to CDargs. I've not been able to track the meaning of k.
Possibly it is just the first initial of the author, Kriang Lerdsuwanakij. Hopefully
it is not in the long and lamentable tradition of KDE kapplikations with klunky
knames.
See also Sitaram Chamarty's bash goto functions.
takes you to the previous directory. The apparix equivalent is
to - and does the same.
erases any symlink side-effects that your path may suffer from. Well,
that's what I thought. I've now found a a more correct statement is
pwd may erase symlink side-effects that your path suffers from.
Pattern-based cd with goto
Sitaram Chamarty wrote a bash goto function that leverages
the locate database or a user-created dump of file system locations.
This is very useful for a) browsing and searching (new) file systems b) visiting
locations in a hugely branched file hierarchy or when you want to range over
many destinations (so that the bookmark approach is not a good fit) c) on systems
where you somehow have such a minimal presence that you do not want to bother
installing whatever file system navigation tools you normally use.
It is possible to ask for locations by directory name pattern and file name
pattern, and it is possible to restrict matches to a specified directory that
will act as root for the query.
goto can be thought of as a very convenient chimera of find
and cd. It is complementary to bookmarking in that the latter provides
unambiguous and instantaneous change of directory to what is presumably an oft-visited
hotspot, where the mark is independent of its associated destination. goto
can take you anywhere but may require zooming in by means of a selection menu,
depending on the distinctiveness of the query string. The latter is used to
match destinations directly.
Go to
Sitaram's goto page.
WCD is a directory changer for DOS and Unix. Another NCD (Norton Change Directory)
clone. This program jumps to a (sub)directory anywhere in the directory-tree.
The directory to jump to can be given by... only the first
characters or an expression with wildcards
Does anybody else remember NCD.exe? This is a way old school
command-line utility written in the mid-eighties. It built
a databaose of the directories on your hard drive, then
when you typed ncd <foo> it would try to get a partial match
against the database. Where there were multiple matches,
a little ANSI graphics box popped up and allowed you to
use the cursor to select the right folder. Once the folder
is selected, your working directory is changed. Very simple
and to the point.
I don’t know why I got to thinking about
it. I used to collect utilities like this back in the DOS
days but as I got into Windows that became less and less
important. But now I’m always in a powershell console and
I find myself missing this sort of tool. I found a very
informative (if confused and rambling)
webpage on the topic which brought back some old memories.
There’s a bunch of clones of NCD, I found one called
WCD released as recently as 2006 which is available
for several different shells.
Seems this sort of thing would be well within the realm
of a PowerShell utility. A bit beyond my own skills perhaps,
or at least my interest in learning how to write at the
moment. But maybe someone else will be inspired.
Comments
It's not clear if aliases and symbolic links are worse then storage of
favorites in some file and using special program. At least they are simpler.
This week's "Cool Tool" is
CDargs, a
browser and bookmark utility for all of you Unix command-line commandos. CDargs
is an extension to the cd, or "change directory" command, that lets you
quickly navigate to the farthest corners of your filesystem. As the author says,
CDargs is for "... when even the almighty and wonderful tab-completion is too
much typing." (And CDargs also supports tab-completion.)
To get started, first reference the path to examples/cdargs-bash.sh
in your ~/.bashrc:
source /usr/share/doc/cdargs/examples/cdargs-bash.sh
|
Then, open the CDargs browser:
$ cdargs
[. ] /home/carla
0 [1writin-g] /home/carla/1writing
1 [Desktop ] /home/carla/Desktop
2 [Mail ] /home/carla/Mail
3 [Maildir ] /home/carla/Maildir
4 [archive ] /home/carla/archive
5 [bin ] /home/carla/bin
...
|
Navigate with the arrow keys, and hit return to select. Toggle using
the tab key to switch between Browse and List modes. List mode contains
your own custom bookmarks, which you create in a plain text file, or by using
CDarg's built-in commands.
CDargs also works with the tcsh shell. It is released under the GPL, so anyone
who wishes to adapt it for other shells can go for it. Read all about it at
the CDargs home
page.
It's not clear if aliases and symbolic links are worse then storage of
favorites in some file and using special program. At least they are simpler.
The code is really bad, I know that. It was written during that phase when you
start learning C++ after coding in C for quite a while... This is just another
reason for never touching it again (unless, of course, I receive fixes for bugs
not detected yet.)I'd like to include some ZSH-code for completion into the
distribution but I don't use ZSH and thus I won't write it.

Current Version: 1.35
CDargs heavily enhances the navigation of the common unix file-system inside
the shell. It plugs into the shell built-in cd-command (via a shell function
or an alias) and thus adds bookmarks and a browser to it. It enables you to
move to a very distant place in the file-system with just a few keystrokes.
This is the kind of thing that power shell users invent when even the almighty
and wonderful TAB-completion is too much typing. (Just as a side-note: there
exists TAB-completion for cdargs ;-)
This little piece of software was inspired by an article
Michael Schilli wrote for the German
iX-Magazine]. There he showed a script which
let you choose from a list of alternatives were to cd to, e.g. in your xterm.
In the forum connected to this article some others enhanced this script.
When I wanted to change it even more and put some more features in it I discovered
that it was not under the GPL so I decided to do a complete rewrite of the whole
thing. Since I wanted to make sure that I shared no code with the original artwork
I chose to use C/C++ together with the ncurses library. This program is the
result of those efforts.
Actually
were heavily involved in this project. Please read the THANKS file in the
distribution for a full list of contributors. It's amazing that such a small
program can have so many people helping it.
This is essentially reinvention and re-implementation of OFM context sensitive
linkage of extension to commands (via ext file) with he additional twist that if
there is no extension file type (for example as discovered by file) is used.
Closebracket lets you define multiple shell actions in a single command to
speed up the typing of the most repetitive shell commands. It includes ']' and
'][' commands, which are located near the "Enter" key and are easy to type quickly.
They invoke primary and secondary actions respectively.
Sep 29, 2005
OS: MS-DOS/Windows 3.1/95/98/ME/NT/2000 |
License: Freeware |
N/A Wcd is a program to change directory fast (another Norton Change
Directory clone). It saves time typing at the keyboard. One needs to type only
a part of a directory name and wcd will jump to it. Wcd has a fast selection
method in case of multiple matches and allows aliasing and banning of directories.
Wcd also includes a full-screen interactive directory browser with speed search.
Features:
- - Full screen interactive directory browser
- - Let the user choose in case of multiple match
- - Wildcards *, ? and [SET] supported
- - Subdir definition possible. Eg. wcd subdira/subdirb
- - Long directory-names support in Win95/98 DOS box
- - UNC paths support
- - Add directories without scanning
- - Alias directories -
- Ban paths
- - Change disk and drive in one go (DOS)
- - 'cd' behaviour. Eg. wcd ../../src will work.
- - Directory stack, push pop
- - Free portable source-code
- - Supports: DOS 16/32 bit, DJGPP Bash Windows 9x/NT Cygwin Bash Win
32 Z shell Unix csh, ksh, bash and zsh
this not NCD variant but attempt to reimplement and enhance pushd/popd functionality.
|
cdll
readme
|
Bash scripts |
A replacement
for cd. Keeps unlimited history, setup special directories for quick
access |
cdll allows easy moving about between directories.
When changing to a new directory the current one is automatically put onto a
stack. By default 50 entries are kept but this is configurable. Special directories
can be kept for easy access - by default up to 10 but this is configurable.
The most recent stack entries and the special entries can be easily viewed.
The directory stack and special entries can be saved to, and loaded from, a
file. This allows them to be set up on login, saved before logging out
or changed when moving project to project.
In addition, cdll provides a flexible command prompt facility that allows, for
example, a directory name in colour that is truncated from the left if it gets
too long.
Do you realize how many times you type cd per day? Do you realize
how many times you retype the same directory names again and again? Ever since
I migrated from 4DOS/NT shell on Windows to using Bash on Unix platforms, I've
missed its cd history access. In 4DOS/NT the history of the visited
directories can be navigated by Ctrl+PgUp/Dn. Every time you go to a new directory
by cd, its name automatically goes on top of an easily accessible history
list.
In Bash, cd - switches between the last two directories. This is
a function in the right direction but many times I wanted to go to the directory
before the last, I dreamed of something like cd -2.
A little scripting creates some sanity in the directory navigation of Bash.
Installing the CD history function
To install the modified CD function, copy
acd_func.sh to any directory in your $PATH, or even your home directory.
At the end of your .bashrc add source acd_func.sh. Restart your bash
session and then type cd --.
lotzmana@safe$ cd --
0 ~
Type cd -- to verify if the installation works. Above you may see
the result 0 ~. This shows that you have one directory in your history.
lotzmana@safe$ cd work
lotzmana@safe$ cd scripts
lotzmana@safe$ pwd
/home/petarma/work/scripts
lotzmana@safe$ cd --
0 ~/work/scripts
1 ~/work
2 ~
lotzmana@safe$ cd -2
lotzmana@safe$ pwd
/home/petarma
The cd command works as usual. The new feature is the history of
the last 10 directories and the cd command expanded to display and
access it. cd -- (or simply pressing ctrl+w) shows the history. In
front of every directory name you see a number. cd -num with
the number you want jumps to the corresponding directory from the history.
How CD with history works
lotzmana@safe$ nl -w2 -s' ' acd_func.sh
1 # do ". acd_func.sh"
2 # acd_func 1.0.5, 10-nov-2004
3 # petar marinov, http:/geocities.com/h2428, this is public domain
4 cd_func ()
5 {
6 local x2 the_new_dir adir index
7 local -i cnt
8 if [[ $1 == "--" ]]; then
9 dirs -v
10 return 0
11 fi
12 the_new_dir=$1
13 [[ -z $1 ]] && the_new_dir=$HOME
14 if [[ ${the_new_dir:0:1} == '-' ]]; then
15 #
16 # Extract dir N from dirs
17 index=${the_new_dir:1}
18 [[ -z $index ]] && index=1
19 adir=$(dirs +$index)
20 [[ -z $adir ]] && return 1
21 the_new_dir=$adir
22 fi
23 #
24 # '~' has to be substituted by ${HOME}
25 [[ ${the_new_dir:0:1} == '~' ]] && the_new_dir="${HOME}${the_new_dir:1}"
26 #
27 # Now change to the new dir and add to the top of the stack
28 pushd "${the_new_dir}" > /dev/null
29 [[ $? -ne 0 ]] && return 1
30 the_new_dir=$(pwd)
31 #
32 # Trim down everything beyond 11th entry
33 popd -n +11 2>/dev/null 1>/dev/null
34 #
35 # Remove any other occurence of this dir, skipping the top of the stack
36 for ((cnt=1; cnt <= 10; cnt++)); do
37 x2=$(dirs +${cnt} 2>/dev/null)
38 [[ $? -ne 0 ]] && return 0
39 [[ ${x2:0:1} == '~' ]] && x2="${HOME}${x2:1}"
40 if [[ "${x2}" == "${the_new_dir}" ]]; then
41 popd -n +$cnt 2>/dev/null 1>/dev/null
42 cnt=cnt-1
43 fi
44 done
45 return 0
46 }
47 alias cd=cd_func
48 if [[ $BASH_VERSION > "2.05a" ]]; then
49 # ctrl+w shows the menu
50 bind -x "\"\C-w\":cd_func -- ;"
51 fi
4-7: cd_func() is a function, variables are declared local and are automatically
deleted at the end of the function
8-11: if the function is called with a parameter "--" then it dumps the current
content of the directory history. It is stored in the same place pushd/popd
keep names -- the directory stack. Storage is the same, access is different.
12-13: Argument $1 is transferred into $the_new_dir for some post-processing.
Immediately after that, if there are no parameters we assume that user asked
for his home directory.
14-22: If parameter begins with '-' then the user is attempting to access
one of the names in the history list. $index gets the number of the directory,
then we extract the corresponding name into $adir. For example, dirs +3
dumps directory #3 from the stack.
At this point in $the_new_dir we have either a name specified explicitly
as a parameter or a name obtained from the history of previously visited directories.
23-25: If a directory name begins with '~' then this character has to be
replaced by the actual home directory name.
26-30: pushd does the actual 'cd'. It also puts the name on top of the directory
stack. stdout is redirected to /dev/null in order to completely imitate how
'cd' works. Notice that any output to stderr, for example a message telling
that the directory specified by the user doesn't exist will show up, which is
again similar to what 'cd' does. The function aborts if pushd fails. We also
need the new directory name for further analysis and $the_new_dir carries it
down the function.
31-33: Keeping track of more than 10 directories is unproductive. Since we
have just pushed one on top of the stack, we trim off any that fall below 11
names deep.
34-44: We loop through all the names in the directory stack. Any name that
matches the new current directory is eliminated. Again, we have to translate
any name from the list which begins with '~' to its format of fully expanded
home directory.
47: We assign cd to be cd_func().
48-51: If the bash version allows for macros to be assigned we make ctrl+w
summon the history of visited directories.
This script defines a function. It must be sourced and not executed, so that
cd_func() is parsed and stored in the current environment. Try env
and you must see it after all environment variables.
Documentation page of the script
Visit the
acd_func.sh man page.
For comments on this article please visit or join
zepp mailing list.
The text of this page is public domain.
An interesting idea of first letter abbreviations. Implementation can be better,
but idea is sound.
Since I moved to Win XP my old and trusted companion
for easily jumping between different spots in the directory tree, NCD (Norton
Change Directory) has ceased to work.
NCD worked by building a database and by using
NCD to make and remove directories, the database could be kept in sync, well
almost anyway.
If the directory you wanted to go to had a unique
name all you had to type was NCD dir_name but if it was a common name
like test you might have had to recall the commandline one or more times
to get to the destination.
Another approach would be to note that if you
consider part of or the whole branch, from root to the destination, the situation
will be less ambigous or even unique Using that idea I came up with this simple
solution which IMHO works quite well. The user interface may be rendered idiosyncratic
by some, but I welcome you to suggest improvements. The documentation is nothing
fancy just a few examples included in the code. The program is tested under
Win XP, but I think it could work on other OS's with some minor tweaks. PS.
As directory delimiter "\", "/" or even "," can be used. The comma is due to
laziness, because on the Swedish keyboard one has to use Shift or Alt Gr key
to get slashes!!
So instead of typing
cd "C:\Documents and Settings\All Users\Application Data\Microsoft\Crypto\RSA\Machin
eKeys"
at the DOS prompt, typing the more dense command of
a ,d,a,a,m,c,r,m
will suffice. Or even horrors a ,d,,,,,r,m ;-), but that one is tougher
on the filesystem.
@perl -Swx %0 %*
@c:\a_cd.bat
@goto :eof
#!perl
#
# Utility for quickly changing directory
# Named to "a.bat" in homage to Pr1mOS's change working directory comm
+and *a* (attach) ;-]
#
# Syntax:
# a ,wi,ja,pa ===> cd \Windows\java\Packages
# a ...\me ===> cd \Windows\Media
# a ===> cd \Windows\Media\Microsoft Office 2000 *OR* a se
+lection of subdirectories
# a / ===> cd \
# a mys,d,*
# [a] /mysql/data/mysql/
# [b] /mysql/data/tast/
# [c] /mysql/data/test/
# [d] /mysql/Docs/Flags/
# select:
#
# if ambigous the correct target is selected with alpha keys /a .. zz/
#
# Versions:
# 0.2 2003-02-22 Cleanup
# 0.1 2003-01-31 First working
# 0.0 2003-01-15 Start of Coding
#
use strict;
use warnings;
use Cwd;
my $DEBUG = 0;
my $DELIM = qr{,|\\|\/}; ## Either "," or "/" or \"
my @to = @ARGV ? split(/$DELIM/, $ARGV[0] ) : ();
my @cwd = split(/$DELIM/, cwd);
shift @cwd; # Remove disk
unless ( @ARGV ) {
push @to, @cwd, '*';
}
elsif ( $ARGV[0] =~ /^$DELIM/ and not @to ){
}
elsif ( $to[0] eq '' ) {
shift @to;
}
else {
unshift @to, @cwd;
}
## Lazy-dots
foreach my $part (0 .. $#to) {
if ( $to[$part] =~ /\.(\.+)/ ) {
$to[$part] = join('/', ('..') x length($1));
}
}
@to = split(/\//, join('/', @to));
## Rel2Abs
my @fixed;
for (@to) {
if ($_ eq '..') {
pop @fixed if @fixed;
} elsif($_ eq '.') {
## Skip
} else {
push @fixed, $_
}
}
my @choices = expand('/', @fixed);
my %hash;
my $enum = 'a';
my $choice = '';
if (1 == @choices) { # Autoselect if only one item to choose
$hash{a} = $choices[0];
$choice = $enum;
} elsif(1 < @choices) {
foreach my $c (@choices) {
($hash{$enum} = $c) ;
print '[', $enum++, "] $c\n";
}
print "select: ";
$choice = <STDIN>;
chomp $choice;
}
# Create a batch file to change the directory in the shell.
open (CD, '>', 'C:/A_CD.BAT') or die "Failed to create CD bat file $!\
+n";
if ( defined $hash{$choice} ) {
$hash{$choice} =~ s/\//\\/g; # Make windows happy
print CD "\@CD \"$hash{$choice}\"\n";
} else {
print CD "\@echo No match\n";
}
close CD;
sub expand {
my ($bough, @twigs) = @_;
return $bough unless @twigs; ## Looked it up in the thesaurus ;-]
opendir(my $dh, $bough) || die "Can not check $bough for twigs due
+ to $!\n";
my $regexp = shift @twigs;
$regexp =~ s/\*/.*/;
my @found;
foreach my $f ( grep { $_ =~ /^$regexp/i and $_ !~ /^\./} readdir
+($dh) ) {
push @found, expand("$bough$f/", @twigs) if (-d "$bough$f");
}
closedir($dh) || die "Bad close for $bough $!\n";
return @found;
}
__END__
Ze Freeware.
NCD : 'Nother Change Directory
My good old Norton Change Directory (©1988…) choked on a disc having 15 000
directories, the weakling. Then I had to do what I do every time I want something
to be done well : I rewrote it myself.
No size limit, unlike ACD (boo !). I imitated the behavior of Norton CD,
in particular, if you type several times "NCD TMP", NCD will trot you through
all TMP directories on the hard disk in turn. You do not remain stuck on the
first one.
Also, the disk is rescanned automatically if NCD is launched from a directory
created since last scanning or from its parent. And of course, I added my fabulous
fuzzy search as usual, quite convenient for the mistypings which are thus "forgiven"
(Norton CD only goes to the directory having the longest common beginning).
On the other hand it is not optimized (for the moment) : a large file, NCD.NCD,
is placed in the root of each hard disk. It will shrink in later versions.
Soon also, indexing of CD-ROMs.
Click
here Size : 50 kB.
Directory
Maven 95 is an automated change directory program.
Like the DOS version, you can quickly change to any directory on any drive from
the MS-DOS command line or view the directory trees of all your drives.
However, Directory Maven 95 is a 32-bit console application that supports
long filenames and up to 10,000 directories per drive. This program
is freeware:
Try it!
Coig Change Directory (CCD) is a freeware DOS
enhanced directory changer. It allows you to change to any directory in your
drives quickly, and without typing long CD commands from the command line.
CCD can be used with arguments from the command
line or by using its user-friendly graphical interface, where you can navigate
through the directory tree with the cursor keys.
| Fergal's ncd Script |
February 2003 |
#!/usr/bin/ksh
#
# Fergal Goggin 11-April-2000, SSL
# ncd : a change directory script for UNIX. works like norton change
# directory on a PC. It can take regular expressions on the
# command line. Remove $HOME/.ncd if you want to change the
# database. Use env var BASEDIR to specify the top level directory
# in the tree (defaults to the root dir, /)
#
# usage: [BASEDIR=XXX] ncd - to create, remove $HOME/.ncd first
# ncd - to search
#
BOLD_TYPE=""
NORMAL_TYPE=""
INVERSE_TYPE=""
if [ $TERM = "xterm" ]
then
BOLD_TYPE="[1m"
NORMAL_TYPE="[0m"
INVERSE_TYPE="[7m"
fi
NCDDATABASE=$HOME/.ncd.`uname -n`
NCDTMPFILE=/tmp/$$.ncd
if [ "$BASEDIR" = "" ]
then
BASEDIR=/
fi
if [ ! -f $NCDDATABASE ]
then
echo "re-creating database from $BASEDIR"
find $BASEDIR -type d 2> /dev/null | gzip > $NCDDATABASE
elif [ $# -lt 1 ]
then
echo "ncd, change directory for UNIX, fgoggin 2000"
echo "usage: [BASEDIR=XXX] ncd "
else
zgrep $1 $NCDDATABASE > $NCDTMPFILE
trap 'rm -f $NCDTMPFILE' 2
noLines=0
# wc -l seems to stick a tab in front of it output
# so it is just as easy to use grep -c
noLines=`grep -c ^ $NCDTMPFILE`
if [ $noLines -eq 0 ]
then
echo "No match"
elif [ $noLines -eq 1 ]
then
# exact match
cd `cat $NCDTMPFILE`
else
# list all directories found and let the user pick one
directorySelected=""
PS3="${INVERSE_TYPE}Pick one from the above list${NORMAL_TYPE} > "
select directorySelected in `cat $NCDTMPFILE`
do
if [ "$directorySelected" = "" ]
then
# when the user wants to break out of the
# display loop without changing directory.
case "$REPLY"
in "q"|"Q"|"quit"|"Quit"|"QUIT"|"E"|"e"|"X"|"x"|"exit"|"Exit"|"EXIT")
break
esac
echo "${BOLD_TYPE}not valid${NORMAL_TYPE}"
# force list to be re-displayed
REPLY=""
else
cd $directorySelected
# break out of select loop
break
fi
done
fi
fi
rm -f $NCDTMPFILE
BASEDIR=""
|
NCD.EXE
5,592 bytes
KeN's Change Directory. If you like jumping to different directories quickly,
you should try my version of the program, based on one of my favorite Norton
Utilities. My NCD program is extremely small and fast. One cool feature is that
it stores the entire directory tree (skips hidden directories) in the "NCD.EXE"
program file itself. This keeps your HD from getting cluttered and makes the
program load even faster. DOS16
|
Changing Directories with ncd
This month,
Fergal Goggin submits Korn/Bash script
ncd, a Unix version of the Norton change directory utility. Instead of typing
in long directory paths, using regular expressions, ncd greps a file for matches.
If ncd finds more than one match, the user is prompted to choose the required
directory.
After Fergal describes ncd, I contrast the ncd
solution with Fred Brunet's article,
fcd:
a Smart Change Directory (Sys Admin, November 1994), and I include
my testing results.
KCD is the most interesting Linux implementation of NCD functionality with some
novel ideas. Actively supported. Highly recommended.
kcd is a directory change utility under Linux or any other Unix clones. It
helps you navigate the directory tree. You can supply the desired directory
name in the command line and let kcd find it for you or let kcd show the entire
directory tree and use arrow keys to go to the destination directory.
Here is a list some features available in kcd:
- Fast directory rescanning. All directory
timestamp is saved so that certain directories do not need rescanning if
they are not changed.
-
When you supply directory in command line and kcd find too many matches.
kcd shows all of them and let you select using cursor keys.
-
You can tell kcd to skip some directory.
You can also chose whether you want the whole directory tree, inside your
home directory, etc. They can be set in kcd configuration file.
-
Supports bash, ash, pdksh, zsh and tcsh.
-
Multiple configuration profiles.
-
Priority directory matching via bookmark.
-
Fuzzy directory searching (Contributed by Robert Sandilands).
-
Supports UTF-8 Unicode encoding with combining characters.
-
Supports localization.
-
Default, vi, and emacs key binding modes.
-
Partial directory tree display.
-
| Display directory tree without saved data. |
kcd is available as stable version and development version. You can distinguish
development version from stable version by looking at its version number. Beginning
from version 5.0.0, any version x.y.z where y is even is a stable version. Those
where y is odd is a development version. Features currently present in the development
version will eventually appear in the future stable version 8.0.0.
kcd is distributed in source form under
General Public
License (GPL).
The program and this web page is maintained by Kriang Lerdsuwanakij
Erwin Waterlander,
WCD Wherever Change Directory Another Norton Change Directory (NCD) clone with
too many features. This is too complex variant. Not very useful in Linux/Unix environment.
Wcd is a program to change directory fast. It
saves time typing at the keyboard. One needs to type only a part of a directory
name and wcd will jump to it. By default wcd searches for a directory with a
name that begins with what has been typed, but the use of wildcards is also
fully supported.
For instance:
wcd Desk
will change to directory /home/waterlan/Desktop
But also
wcd *top
will do that.
Wcd is free to use and you can get the source
code too.
Some features of wcd:
- Full screen interactive directory browser
with speed search.
- Present the user a list in case of multiple
matches.
- Wildcards *, ? and [SET] supported.
- Directory stack, push pop.
- Subdir definition possible. E.g. wcd subdira/subdirb
- Long directory names support in Win95/98/NT
DOS-box
- Windows LAN UNC paths supported.
- Change drive and directory at once.
- Alias directories.
- Ban directories.
- 'cd' behaviour
- Free portable source-code, no special libraries
required
- Multi platform:
DOS 16 bit, DOS 32 bit, DOS bash, Windows 3.1/95/NT DOS-box, Cygwin bash,
Unix ksh, csh, bash and zsh.
Wcd has been tested on:
FreeDOS, MS-DOS 6.2, Win95,
Win98, Windows NT 4.0, Linux,
FreeBSD, HP-UX, SunOS,
Solaris, SGI IRIX. Wcd works on any PC and can be ported to any Unix system.
WCD is free software, distributed under GNU General Public License.
Most popular humor pages:
Manifest of the Softpanorama IT Slacker Society
: Ten Commandments of the IT Slackers Society
: Computer Humor Collection : BSD Logo
Story : The Cuckoo's Egg : C++ Humor
:
ARE YOU A BBS ADDICT? : Object oriented programmers of all nations :
C Humor :
Financial Humor :
Financial Humor Bulletin, 2008 :
Financial Humor Bulletin, 2010 :
Richard Stallman Related Humor : Admin Humor
: Perl-related Humor :
Linus Torvalds Related humor :
PseudoScience Related Humor : Networking Humor :
Shell Humor:
Financial Humor Bulletin, 2011 :
Financial Humor Bulletin, 2012 :
Financial Humor Bulletin, 2013 :
Java Humor : Software Engineering Humor :
Sun Solaris Related Humor : The Most Comprehensive Collection of
Editor-related Humor : Microsoft plans to buy Catholic Church :
Education Humor : IBM Humor :
Assembler-related Humor : VIM Humor
Computer Viruses Humor : Bright tomorrow is
rescheduled to a day after tomorrow : Classic Computer Humor :
Best Russian Programmer Humor :
Russian Musical Humor :
The Perl Purity Test :
Politically Incorrect Humor : GPL-related
Humor : OFM Humor : IDS Humor :
Real Programmers Humor : Scripting
Humor : Web Humor : Programming Language
Humor :
Goldman Sachs related humor :
Greenspan
humor :
The Last
but not Least
Copyright © 1996-2013 by Dr. Nikolai Bezroukov. www.softpanorama.org
was created as a service to the UN Sustainable Development Networking Programme (SDNP) in the author free time. This document
is an industrial compilation designed and created exclusively for educational use and is distributed under the
Softpanorama Content License. Site uses AdSense so you need to be aware of Google privacy policy.
Original materials copyright belong to respective owners. Quotes are made for educational purposes
only in compliance with the fair use doctrine. This is a Spartan WHYFF (We Help You For Free) site written
by people for whom English is not a native language. Grammar and spelling errors should be expected. The site contain
some broken links as it develops like a living tree...
Disclaimer:
The statements, views and opinions presented on this web page are those of the author and are not endorsed by, nor
do they necessarily reflect, the opinions of the author present and former employers, SDNP or any other organization the
author may be associated with. We do not warrant the correctness of the information provided or its fitness for any purpose.
Last modified:
January 15, 2013
| | | | | | | | | | |