Using stock Ksh instead of Bash

New to SGIs? Need help getting things going? This is the forum for you!
Forum rules
Any posts concerning pirated software or offering to buy/sell/trade commercial software are subject to removal.
User avatar
jimmer
Donor
Donor
Posts: 464
Joined: Tue Oct 12, 2004 3:54 pm
Location: London, Ingerlund

Using stock Ksh instead of Bash

Unread postby jimmer » Sun Sep 06, 2015 7:09 am

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
:O2: bluebox 200Mhz 256Mb AV1+O2Cam

User avatar
foetz
Moderator
Moderator
Posts: 6542
Joined: Mon Apr 14, 2003 4:34 am
Contact:

Re: Using stock Ksh instead of Bash

Unread postby foetz » Sun Sep 06, 2015 7:13 am

ksh is not such a good choice for interactive shells. tcsh which comes with 6.5.x as well usually is much nicer

User avatar
hamei
Posts: 10433
Joined: Tue Feb 24, 2004 4:10 pm
Location: over the rainbow

Re: Using stock Ksh instead of Bash

Unread postby hamei » Sun Sep 06, 2015 7:50 am

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
I spent a fortune on booze, birds, and fast cars ... the rest I just squandered

diegel
Donor
Donor
Posts: 351
Joined: Tue Nov 17, 2009 2:08 am
Location: Hamburg, Germany

Re: Using stock Ksh instead of Bash

Unread postby diegel » Sun Sep 06, 2015 11:55 am

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:

User avatar
foetz
Moderator
Moderator
Posts: 6542
Joined: Mon Apr 14, 2003 4:34 am
Contact:

Re: Using stock Ksh instead of Bash

Unread postby foetz » Sun Sep 06, 2015 5:59 pm

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

User avatar
Trippynet
Donor
Donor
Posts: 783
Joined: Thu Aug 15, 2013 6:22 am
Location: Aberdeen, Scotland, UK

Re: Using stock Ksh instead of Bash

Unread postby Trippynet » Mon Sep 07, 2015 3:44 am

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:
:Indigo2IMP: - Nitrogen: R10000 195MHz CPU, 384MB RAM, SolidIMPACT Graphics, 36GB 15k HDD & 300GB 10k HDD, 100Mb/s NIC, New/quiet fans, IRIX 6.5.22
:Fuel: - Lithium: R14000 600MHz CPU, 4GB RAM, V10 Graphics, 72GB 15k HDD & 300GB 10k HDD, 1Gb/s NIC, New/quiet fans, IRIX 6.5.30
Other system in storage: :O2: R5000 200MHz, 224MB RAM, 72GB 15k HDD, PSU fan mod, IRIX 6.5.30

User avatar
josehill
Moderator
Moderator
Posts: 3302
Joined: Mon Jun 06, 2005 9:53 pm
Location: New England, USA
Contact:

Re: Using stock Ksh instead of Bash

Unread postby josehill » Mon Sep 07, 2015 5:53 am

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).

robespierre
Posts: 1551
Joined: Mon Sep 12, 2011 2:28 pm
Location: Boston

Re: Using stock Ksh instead of Bash

Unread postby robespierre » Mon Sep 07, 2015 7:12 am

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:

armanox
Posts: 206
Joined: Sun Feb 23, 2014 9:31 pm
Location: Baltimore, MD, USA

Re: Using stock Ksh instead of Bash

Unread postby armanox » Fri Sep 11, 2015 11:55 pm

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:


Return to “Getting Started, Documentation, Tips & Tricks”

Who is online

Users browsing this forum: No registered users and 2 guests