this is obsolete doc -- see http://doc.nethence.com/ instead

KSH configuration 

 

http://pbraun.nethence.com/doc/shells/ksh.html 

http://pbraun.nethence.com/doc/lang/kshdev.html 

 

 

KSH Versions 

Look for your KSH version, 

Ctrl-V (PDKSH emacs mode)
Esc, Ctrl-V (PDKSH vi mode)
Ctrl-Alt-V (KSH93 emacs mode)
Esc, Ctrl-Alt-V (KSH93 vi mode)

Note. seen versions, 

RHEL4: PDKSH
RHEL5: KSH93 (Version AJM 93t+ 2010-02-02)
Slackware: KSH93 (Version M 1993-12-28 s+)
NetBSD: PDKSH (PD KSH v5.2.14 99/07/13.2)
HP/UX: KSH88
Solaris: KSH88
AIX: KSH88

 

 

Usage 

For HP/UX, BSD and other systems, make sure KSH is enabled, 

vi /etc/shells

add, 

/bin/ksh

 

Start KSH, 

/bin/ksh

Note. "-l" for login shell with PDKSH 

 

Make it the default shell, 

#HP/UX & Redhat
#chsh -s /bin/ksh USERNAME
#NetBSD,
#chpass -s /bin/ksh USERNAME
#vi /etc/passwd
#vipw

 

 

Minimal configuration 

Proceed, 

cd /etc
mv profile profile.dist
vi profile

like, 

ENV=/etc/kshrc

then, 

vi kshrc

like, 

HOSTNAME=`uname -n`

 

(( `id -u` == 0 )) \
        && PS1='${HOSTNAME%%.*}:${PWD/#$HOME/\~}# ' \
        || PS1='${HOSTNAME%%.*}:${PWD/#$HOME/\~}> '

 

set -o emacs
alias ll='ls -alF'
alias rm='rm -i'
alias mv='mv -i'
alias cp='cp -i'

Note. the /#$HOME/ substitution works with KSH93 only, remove it, eventually 

Note. single quotes around the PS1 variables ! Otherwise the PWD won't be dynamic. 

Note. eventhough the ENV variable should work on Solaris (KSH88), it doesn't. Just put kshrc's content inside profile (some lines won't work if another shell gets started). 

 

 

KSH88 specific 

The default Korn Shell configuration on HP/UX has the freacking local dir in the PATH. Overwrite it with the c 

Note. "^?" may be written using VI's special character mode (^V), but it also works just like that. 

 

Refs. 

http://docs.hp.com/en/B2355-90046/ch16s05.html#shellparam 

http://docs.hp.com/en/hpuxman_pages.html 

http://docs.hp.com/en/B2355-90689/ksh.1.html 

 

 

KSH93 specific 

Use the provided link above and uncomment the KSH93 part. 

Note. this only works with Emacs style 

Note. tab "\t" becomes ESC ESC 

Note. "^L" clears the screen 

Note. "^L" needs to be written with Vi's character mode (insert "^V"). 

Ref. http://www.kornshell.com/examples/keybind 

 

In case of older terminals, 

infocmp | grep clear

or check that output against the ascii table, 

cput clear | oc -d
man ascii

in example, 

0000000 033   [   H 033   [   J

gives, 

\E[H\E[J

Try it out on the command line, 

echo -ne "\E[H\E[J"

Include it inside the kshrc and add a carriage return, as shown in the keybinding example above, 

$'\'

 

There's also a brute force method which should work everywhere, 

keybind $'^L' $'clear\r'

Note. "^L" needs to be written with VI's character mode ("^V"). 

 

Unused bindings (works already), 

keybind $'\EOA' $'\020' # Up key
keybind $'\EOB' $'\016' # Down key
keybind $'\EOC' $'\006' # Right key
keybind $'\EOD' $'\002' # Left key
keybind $'\EOH' $'\001' # Home key
keybind $'\EOP' $'\004' # Delete key
keybind $'\EOY' $'\005' # End key

 

Ununsed history feature (works already), 

alias __A=$(print -n "\020")
alias __B=$(print -n "\016")
alias __C=$(print -n "\006")
alias __D=$(print -n "\002")

 

Refs. 

http://kornshell.com/doc/ksh93.html 

http://kornshell.com/doc/faq.html 

http://docs.hp.com/en/B2355-90046/ch16s05.html 

http://www.cs.sun.ac.za/~akruger/red_hat_linux/rhl11.htm#E68E72 

http://home.nyc.rr.com/computertaijutsu/ksh.html 

http://www.unixguide.net/ibm/faq/faq1.401.shtml 

http://www.idris.fr/su/divers/Exemple_fich_environ.html 

http://marcg.developpez.com/ksh/ 

http://bp.noos.org/computer/ksh.html 

http://wwwacs.gantep.edu.tr/docs/KornShell/faq.html 

http://www.research.att.com/~gsf/download/gen/ast-ksh.html#ksh93%20changes 

http://www.zenez.com/tmp/ou8faqz/cache/54.html 

http://www.mail-archive.com/solaris_fr@x86.sun.com/msg00950.html 

 

Refs. keyboard trap 

http://groups.google.fr/group/comp.unix.shell/browse_thread/thread/853905266fdd34ac/20541e5c0f9c59f2?hl=fr&lnk=st&q=%22David+Korn%22+ksh93+keybind#20541e5c0f9c59f2 

http://www.unixinfo.org/books/ProUnixShellProg/ProUnixShellProg-Keybindi.html 

http://groups.google.fr/group/alt.comp.editors.batch/browse_thread/thread/1fbcbc450d9dacb4/7819109fc978b1b1?hl=fr&lnk=st&q=ksh93+key+binding+question#7819109fc978b1b1 

 

 

PDKSH specific 

Use the provided link above and uncomment the PDKSH part. 

Note. "^M" should be an enter key made with VI's "^V" mode. But it works anyway ! 

Note. in VI mode, "set -i viraw" is the default with PDKSH. 

 

Refs. 

PDKSH Home : http://www.cs.mun.ca/~michael/pdksh/ 

PDKSH Manual : http://www.cs.mun.ca/~michael/pdksh/pdksh-man.html 

PDKSH Notes : http://www.cs.mun.ca/~michael/pdksh/NOTES 

Default kshrc : http://www.cs.mun.ca/~michael/pdksh/XXXXXXXXX.tar.gz (see etc/ksh.kshrc) 

OpenBSD kshrc : http://openbsd.md5.com.ar/pub/OpenBSD/src/etc/ksh.kshrc 

 

 

Common keybindings 

Filename completion, 

ESC ESC

 

See if you have an /etc/inputrc file on your system, 

less /etc/inputrc

 

 

Emacs style 

Keybindings, 

^E  # End of line
^A  # Beginning of line.  Use ^Aa inside screen
^U  # Clear line
^H  # Backspace
^B  # Character back
^F  # Character forward

 

 

VI style 

To use the Shell prompt history, enter into command mode, 

ESC

and use VI's equivalent for arrow keys, 

k
j

Note. other usual VI commands work. 

 

 

Compilance 

From the official FAQ, 

Q3.  What is the history of ksh?
A3.  ksh was written by David Korn at Bell Telephone Laboratories.
  David Korn is currently at AT&T Laboratories.
  The first version of ksh was in 1983.  It was the first
  shell to have command line editing with both emacs
  and vi style interaction.  The 1986 version was the first
  to offer multibyte support.  The 1988 version of ksh
  is the version that was adopted by System V Release 4 UNIX
  and was a source document for the IEEE POSIX and ISO
  shell standards.  The 1993 version is a major rewrite
  of the 1988 version and focuses more on scripting.

 

Refs. 

Korn Shell FAQ : http://kornshell.com/doc/faq.html 

OpenGroup POSIX® 1003.1 FAQ http://www.opengroup.org/austin/papers/posix_faq.html 

IEEE Standards : http://standards.ieee.org/catalog/olis/arch_posix.html 

 

 

DTKSH 

Graphical Desktop Korn Shell : http://www.linuxjournal.com/article/2643 

http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/V40F_HTML/DTKSH/DOCU_007.HTM 

http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/V51A_HTML/MAN/MAN1/0034____.HTM 

http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/V40F_HTML/DTKSH/DOCU_011.HTM 

 

 

Comeau C/C++ 

Greg Comeau (Comeau C++) claims to have a shell to C++ translator on his website. 

Wikipedia Comeau C/C++ : http://en.wikipedia.org/wiki/Comeau_C/C%2B%2B 

 

 

References 

gilb's EXINIT : http://pagesperso-orange.fr/bsdcow/netbsd/profile 

Setting terminal characteristics with stty : http://www.acm.uiuc.edu/workshops/cool_unix/stty.html 

Special Keys : http://www.fnal.gov/docs/UNIX/unix_at_fermilab/htmldoc/rev1997/uatf-14.html 

any file exists in dir ? : http://www.generation-nt.com/reponses/savoir-si-un-repertoire-contient-au-moins-un-fichier-ksh-sun-entraide-172896.html 

solaris & backups examples : http://home.comcast.net/~dwm042/scripts.htm (syncit, root, solaris TCP tweak) 

Oreilly : http://www.unix.com.ua/orelly/unix/ksh/ch01_04.htm 

C shell pushd/popd on steroids as Korn Shell functions : http://blogs.sun.com/nico/entry/ksh_functions_galore 

Sensing locale with HP-UX applications : http://h21007.www2.hp.com/portal/site/dspp/menuitem.863c3e4cbcdc3f3515b49c108973a801/?ciid=8b08852bcbe02110852bcbe02110275d6e10RCRD 

Building Locales for HP-UX 11.0 and HP-UX 11i : http://docs.hp.com/en/5991-1194/ch03s03.html 

MEMORANDUM FOR FILE : http://mideiros.net/doc/system/packages/ksh/MEMORANDUM