Eric Radman : a Journal

Linux Userland Hacks

Install VI

VIM is a powerful editor, but vim is not the same as vi, and many Linux distros automatically alias the two. First, get the source from the The Berkeley Vi Editor Home Page and do a local install:

$ cd nvi-1.79/build
$ ./configure --prefix=$HOME
$ make
$ make install

Now get rid of the alias in .profile and prepend your personal bin directory to your path:

unalias vi

PATH=$HOME/bin:$PATH
MANPATH=$HOME/share/man:$MANPATH

Replace Broken Linux Shell

The versions of ksh that ship with Red Hat 4 and 5 as both broken. They don't support proper tab-completion and they keep command line history that is shared between shells. Several Linux binary and source packages are available at http://www.wormhole.hu/~ice/ksh/.

$ rpm2cpio openbsd-ksh-4.0-4L.i386.rpm | cpio -id
1315 blocks
$ cp bin/ksh ~/bin/
$ cp etc/ksh.kshrc ~/etc/
$ cp usr/share/man/man1/ksh.1 ~/share/man/man1/

Now the trick is to invoke KSH as a login shell. Somebody posted this on the Web, which works great:

#include <stdio.h>
#include <unistd.h>

int main(void)
{
     execl("/home/eradman/bin/ksh","-",0);
     return 0;
}
$ cc --static login.c
$ mv a.out ~/bin/ksh-login

A little more logic in .profile makes this work.

if [ ${SHELL} == "/usr/bin/ksh" ]; then
        if [ `uname -s` == "Linux" ]; then
                export SHELL=${HOME}/bin/ksh
                echo "starting BSD shell"
                ${HOME}/bin/ksh-login ; exit
        fi
fi

By default xterm won't spawn a login shell, but you can add a resource definition to .Xdefaults to instruct it to do so:

xterm*loginShell: true

$ Fri Jan 08 13:51:39 -0500 2010 $