SETTING UP KSH

INSTALL

SLACKWARE

KSH93 is the default. In case you wanna switch to PDKSH

slackpkg search ksh
removepkg ksh93
slackpkg install pdksh
mv /bin/ksh /bin/ksh.trash
ln -s pdksh /bin/ksh
cat /etc/shells

check at login time

^V

SETUP

vi /etc/shrc #new file

case "$-" in *i*)
    ( set -o emacs 2>/dev/null ) && set -o emacs

    [[ -z $HOST ]] && HOST=`uname -n`
    (( `id -u` == 0 )) && PS1='$HOST# ' || PS1='$HOST> '

    alias ll='ls -alhF'
    alias l='ls -altrhF'
    alias cp='cp -i'
    alias mv='mv -i'
    alias rm='rm -i'

    alias neta='netstat -antup'
    alias netl='netstat -lntup'
    alias runq='postfix flush'
    [[ -f /etc/slackware-version ]] && alias runq='sendmail -v -q'
    alias lynxg='lynx -accept_all_cookies google.com/ncr'
    alias lynx='lynx -accept_all_cookies'
    alias push='git nc && git push'
    alias stat='git diff --stat --cached origin/master'
    alias findexec='find . -executable -type f'

    #export TERM=xterm
    #export TERM=linux

    j=$((`grep ^processor /proc/cpuinfo | tail -1 | awk '{print $3}'` + 2))
    export MAKEFLAGS=-j$j
    ;;
esac

Note: this setup is even compatible with BASH

KSH93 SPECIFIC

keybd_trap () {
    case ${.sh.edchar} in
        $'\f')    .sh.edchar=$'\e\f';;  # clear-screen (THIS QUESTION)
        $'\e[1~') .sh.edchar=$'\001';;  # Home = beginning-of-line
        $'\e[4~') .sh.edchar=$'\005';;  # End = end-of-line
        $'\e[5~') .sh.edchar=$'\e>';;   # PgUp = history-previous
        $'\e[6~') .sh.edchar=$'\e<';;   # PgDn = history-next
        $'\e[3~') .sh.edchar=$'\004';;  # Delete = delete-char
    esac
}

case "$-" in *i*)
    ...
    trap keybd_trap KEYBD
    #set -o tabcomplete

PDKSH SPECIFIC

case "$-" in *i*)
    ...
    bind -m ^L='clear^M'
    bind ^I=complete-list

RESOURCES

KSH93 http://www.kornshell.com/doc/

Frequently Asked Questions http://www.kornshell.com/doc/faq.html

How to make “Ctrl + L” to clear screen in ksh under Red hat linux? https://unix.stackexchange.com/questions/272591/how-to-make-ctrl-l-to-clear-screen-in-ksh-under-red-hat-linux/272720

Tab complete in VI mode KSH ‘vi-tabcomplete’ gives bad options https://superuser.com/questions/65964/tab-complete-in-vi-mode-ksh-vi-tabcomplete-gives-bad-options

Change the key that show previous command lines in ksh https://unix.stackexchange.com/questions/294592/change-the-key-that-show-previous-command-lines-in-ksh

ksh93 KEYBD trap: how to make it work? https://groups.google.com/forum/#!msg/comp.unix.shell/hTkFJm_dNKw/AIZ2cx9uyrgJ


Nethence | Pub | Lab | Pbraun | SNE Russia | xhtml