Subject: ksh extensions
To: None <netbsd-help@netbsd.org>
From: Bruce J.A. Nourish <bjan+netbsd-help@bjan.net>
List: netbsd-help
Date: 10/27/2003 01:27:57
Hey Everyone,

With some recent changes made in -current to ksh, it now has what I
need to replace zsh as my login shell. There were, however, some 
features that I missed, that I had to implement by hand. I offer
this code to everyone here in the hope that it will be useful, and
perhaps allow others to migrate from bash/zsh.

I have implemented the following functionality in ksh:

* Directory stacks

I have implemented pushd/popd/dirs in a way that should be functionally
equivalent for interactive use. Error messages are the only major area
of difference, and this is not worth the trouble to fix. 

Unfortunately, implementing an array shuffle routine in ksh proved 
incredibily difficult, and would probably have been unmaintainable, so 
I wrote a helper program in C to do the job. If, for security reasons,
you can't use the helper program, you can use everything except the 
+n/-n commands to pushd.

* Formatted workdir strings

This means, for instance, that /home/Mail will be contracted to ~/Mail.
Also, a long path like: /usr/src/sys/arch/i386/compile/obj/TELSTAR will
be contracted to: /<4>/arch/i386/compile/obj/TELSTAR. This emulates
similar functionality in zsh/tcsh.

* Easy-to use prompt strings

It is possible to use escape sequences in the ksh PS1 prompt, but it 
is slightly tricky. I provide some simple tools to make a prompt with
highlighting, and an example (my prompt).

* Generally nice options

ksh has many useful options that are disabled by default: Brace 
expansion, alias tracking (hashing), tab completion, and others.
These scripts enable them.

This code works on my -current and 1.6.1_STABLE systems. Please
send any comments to bjan (at) bjan (dot) net. It will shortly
be posted at:

http://bjan.net/ksh-ext/ksh-ext-0.1.tar.gz

Installation:

Look at the files and tweak to taste. Install them as follows:

kshrc -> ~/.kshrc
shrc -> ~/.shrc
profile -> ~/.profile

lshuffle.c: gcc -O -o ~/.lshuffle lshuffle.c

You should back up the old versions of these files before installing,
of course.
~
-- 
Bruce J.A. Nourish <bjan+public@bjan.net> http://bjan.net