# vim:ft=sh:fdm=marker
-#
-# configuration used for an absolute minimal ksh shell.
-# Reason: reference no files in /usr/, so that FS can be umounted.
+# Configuration for the `minimal-shell' function of grml's zsh setup.
+# That function spawns a `mksh' shell with this file as its configuration.
# skip this setup for non-interactive shells
[[ -o interactive && -t 0 ]] || return
export PAGER='more'
fi
-FPATH=/usr/share/ksh/functions
-HISTSIZE=500
-HISTEDIT="$EDITOR"
-
# some options.
-set -o emacs -o trackall -o globstar
+set -o bgnice \
+ -o braceexpand \
+ -o emacs \
+ -o markdirs \
+ -o monitor \
+ -o nohup \
+ -o trackall
# aliases for various command shortcuts
alias ls='ls --color=auto' # we're on grml, so we do have GNU ls.
alias la='ls -LaFb'
alias pu='ps -fu $USER'
-# Use keyboard trap to map keys to other keys
-# note that escape sequences vary for different terminals so these
-# may not work for you
-trap '.sh.edchar=${keymap[${.sh.edchar}]:-${.sh.edchar}}' KEYBD
-
+## Keybindings
+bind '^L=clear-screen'
if [[ -x $(which infocmp) ]] && [[ -x $(which sed) ]] ; then
- # reading some special keys from terminfo database.
- # should work everywhere. hopefully.
- typeset -A keymap
- infocmp -L | sed '1,2d;s/\t//;s/, /\n/g;s/,$//' | \
+ # Reading some special keys from terminfo database. If `infocmp'
+ # cannot be found, we rely on mksh to do the right thing.
+ infocmp -x1L | sed '/^\t[^k]/d;/^[^\t]/d;s/\t//;s/,$//' | \
while read -r line ; do
key="${line%=*}"
- seq="${line#*=}"
+ [[ "${key}" != k* ]] && continue
+ seq="$(print -r -- "${line#*=}" | sed -e 's,\\\([1-7][0-7]*\),\\0\1,g')"
+ seq="$(print "${seq}")"
case "$key" in
- key_left) keymap+=( [$(print "$seq")]=$'\cb' ) ;;
- key_right) keymap+=( [$(print "$seq")]=$'\cf' ) ;;
- key_up) keymap+=( [$(print "$seq")]=$'\cp' ) ;;
- key_down) keymap+=( [$(print "$seq")]=$'\cn' ) ;;
- key_home) keymap+=( [$(print "$seq")]=$'\ca' ) ;;
- key_end) keymap+=( [$(print "$seq")]=$'\ce' ) ;;
- key_backspace) keymap+=( [$(print "$seq")]=$'\ch' ) ;;
- key_dc) keymap+=( [$(print "$seq")]=$'\cd' ) ;;
+ key_left) bind "${seq}"='backward-char' ;;
+ key_right) bind "${seq}"='forward-char' ;;
+ key_up) bind "${seq}"='up-history' ;;
+ key_down) bind "${seq}"='down-history' ;;
+ key_ppage) bind "${seq}"='search-history-up' ;;
+ key_npage) bind "${seq}"='search-history-down' ;;
+ key_home) bind "${seq}"='beginning-of-line' ;;
+ key_end) bind "${seq}"='end-of-line' ;;
+ key_backspace) bind "${seq}"='delete-char-backward' ;;
+ key_dc) bind "${seq}"='delete-char-forward' ;;
esac
done
-else
- # fallback, does not work in all terminals.
- keymap=(
- [$'\eOD']=$'\eb' # Ctrl-Left -> move word left
- [$'\eOC']=$'\ef' # Ctrl-Right -> move word right
- [$'\e[3~']=$'\cd' # Delete -> delete to right
- [$'\e[1~']=$'\ca' # Home -> move to beginning of line
- [$'\e[4~']=$'\ce' # End -> move to end of line
- )
fi
+function _lrv {
+ local rv="$?"
+ if [[ "${rv}" != 0 ]]; then
+ print -- "[${rv}]-"
+ fi
+ return 0
+}
# put the current directory and history number in the prompt.
# use a wrapper for 'cd' to get '~' instead of /home/foo/.
function _cd {
}
alias cd=_cd
_cd .
-PS1='(!)-$_pwd\$ '
+PS1='$(_lrv)(!)-$_pwd'
+if (( USER_ID )); then
+ PS1="$PS1"'\$ '
+else
+ PS1="$PS1"'# '
+fi
+
+HISTSIZE=500
+HISTEDIT="$EDITOR"
+# This is the default in mksh, but we make sure in case people tempered
+# with it in their environment.
+unset HISTFILE
+true