Getting Started, Documentation, Tips & Tricks

Using stock Ksh instead of Bash

Hey All,

Following Hamei's excellent example, I'm rebuilding redbox and have decided to try and use as much as possible of the default software that IRIX 6.5.30 provides. So I'm currently using the default Ksh as my shell rather than trusty old GNU Bash.

Which is fine, except that life without <TAB> filename auto-completion is trying. Turns out that you can get most of that back in Ksh by hitting <ESC><ESC> rather than <TAB>. Well, after you've set your keyboard mode to EMACS as shown below.

I also like my prompt to tell me who I am and where I am, and my up/down arrows to recall my command line history. In Bash you get command line history on the arrow keys for free and you set your prompt with something like: PS1="\u@\h \w".

In IRIX Ksh (which is actually the venerable Ksh88) something similar can be achieved, but it's a bit more involved.

1. put the following into your $HOME/.profile

ENV="$HOME/.kshrc"
export ENV

2. create a $HOME/.kshrc and insert the following:

Code: Select all

function _cd {

# Stock IRIX ksh is ksh88. Which is old. Very old. If we want prompts that
# print the current working directory when we cd into them, a la modern
# shells, we need to hack around ksh's walking frame.
#
# 1. cd to the directory
# 2. colourise the prompt
#
# NOTE: "\cd" evokes the non-aliased version of cd

\cd $1
PS1=`colourised_prompt`
}

function colourised_prompt {

# 0. colours are pwetty.
# 1. winterm tends to be blue, so colour regular prompt to be cyan
# 2. for extra protection against idiot user error, colour prompt RED
#    when logged in as root.

USR=`whoami`

FONT_NORMAL="\033[0m"

if [ $USR == "root" ]; then

FONT_COLOURED="\033[31m" # red
PROMPT_CAP="#"

else

FONT_COLOURED="\033[36m" # cyan
PROMPT_CAP=">"
fi

echo $(print "$FONT_COLOURED$USR@`hostname`:`pwd` $PROMPT_CAP $FONT_NORMAL")
}

PS1=`colourised_prompt`

# Setup EMACS-style key bindings to get arrow up/down command history recall
EDITOR=emacs

alias __A=$(print '\0020') # ^P = up    = previous command
alias __B=$(print '\0016') # ^N = down  = next command
alias __C=$(print '\0006') # ^F = right = forward a character
alias __D=$(print '\0002') # ^B = left  = back a character

alias cd="_cd"


Like the Meerkat says; "Simples." :?
:Fuel: redbox 800Mhz 4Gb V12
ksh is not such a good choice for interactive shells. tcsh which comes with 6.5.x as well usually is much nicer
r-a-c.de
jimmer wrote: ... have decided to try and use as much as possible of the default software that IRIX 6.5.30 provides. So I'm currently using the default Ksh as my shell rather than trusty old GNU Bash.

Umm, that may be going to extremes ... a shell is just a utility, and if you are used to one that you like, changing a tool you use all the time for something you dislike might not be a great idea ?

Getting rid of six layers of fonts that don't so anything is one thing, but a shell doesn't really interfere with the Irix Ambience (imo) ...

And I dislike bash, too, so not just saying that to be nice.

if you drag gcc into this tho, you're disowned :P
Juliet ! the dice were loaded from the start ...
foetz wrote: ksh is not such a good choice for interactive shells. tcsh which comes with 6.5.x as well usually is much nicer
I am using ksh in vi mode for decades now and for me it is the best choice.
:Tezro: :Fuel: :Octane2: :Octane: :Onyx2: :O2+: :O2: :Indy: :Indigo: :Cube:
sure it works. in the end it's a matter of choice.
what i meant is that by default ksh as interactive shell doesn't have the "usual" stuff like arrow keys history, tab completion etc. in contrast to tcsh
r-a-c.de
First thing I do with IRIX is to use tcsh for the shell. It's just so much more flexible and usable than ksh in my opinion. And as it comes with IRIX, it should still fit with your current philosophy :)
Systems in use:
:Fuel: - Lithium : R14000 600MHz CPU, 4GB RAM, V10 Graphics, 36GB 15k HDD & 300GB 10k HDD, New/quiet fans, IRIX 6.5.30
:Indigo2IMP: - Nitrogen : R10000 195MHz CPU, 384MB RAM, SolidIMPACT Graphics, 36GB 15k HDD & 300GB 10k HDD, New/quiet fans, IRIX 6.5.22
Other systems in storage: :O2: x 2, :Indy: x 2
FWIW, csh/tcsh was IRIX's default interactive shell for a while back in the late 90s and early 00s. Back when I was at the fabled Global Megacorp, we set up everyone (hundreds of IRIX users) with tcsh as the default shell on IRIX. The history and command completion features were much more accessible to non-IT end users than the equivalent features in ksh.

Of course, ksh works very well, too, if you put in the effort to learn it well and to customize your environment, as jimmer hinted in the OP. There was a time I enjoyed spending inordinate effort trying to develop the "perfect" .profile/.kshrc files. I never succeeded and always returned to tcsh. :lol:

As an aside, early versions of Mac OS X also used tcsh as the default interactive shell. Apple switched to bash in Panther (10.3).
changing the shell is so easy that the default is (imho) completely irrelevant. changing it to tcsh is literally the first thing I do to any computer.
:PI: :O2: :Indigo2IMP: :Indigo2IMP:
I personally prefer slightly more user friendly shells (bash, zsh, tcsh) to ksh. The shell does not really effect the way the system works, except to make your life easier. Now, I stick to MIPSPro over GCC as much as I can (until I hit something that really will not build), but I have no qualms personally with not using outdated software (I've built recent versions of httpd 2.2 (I can get 2.4 to build, but it's a pain), php 5.6, OpenSSL 1.0.2a, etc. I'm sorta big on security too, as I used to work for a major Network Security company. My IRIX box actually doesn't look bad on a Nessus scan....
"Apollo was astonished, Dionysus thought me mad."
:Octane: :Octane: :O2: