1 # Copyright (c) 2010, 2012, 2013
2 # Thorsten Glaser <tg@mirbsd.org>
3 # This file is provided under the same terms as mksh.
5 # Minimal /system/etc/mkshrc for Android
7 # Support: https://launchpad.net/mksh
9 : ${TERM:=vt100} ${HOME:=/data} ${MKSH:=/system/bin/sh} ${HOSTNAME:=$(getprop ro.product.device)}
10 : ${SHELL:=$MKSH} ${USER:=$(typeset x=$(id); x=${x#*\(}; print -r -- ${x%%\)*})} ${HOSTNAME:=android}
11 if (( USER_ID )); then PS1='$'; else PS1='#'; fi
12 PS4='[$EPOCHREALTIME] '; PS1='${|
15 (( e )) && REPLY+="$e|"
18 }$USER@$HOSTNAME:${PWD:-?} '"$PS1 "
19 export HOME HOSTNAME MKSH SHELL TERM USER
26 local -Uui16 -Z11 pos=0
27 local -Uui16 -Z5 hv=2147483647
30 cat "$@" | { set +U; if read -arN -1 line; then
33 while (( i < ${#line[*]} )); do
35 if (( (pos & 15) == 0 )); then
36 (( pos )) && print -r -- "$dasc|"
37 print -n "${pos#16#} "
41 if (( (hv < 32) || (hv > 126) )); then
46 (( (pos++ & 15) == 7 )) && print -n -- '- '
48 while (( pos & 15 )); do
50 (( (pos++ & 15) == 7 )) && print -n -- '- '
52 (( hv == 2147483647 )) || print -r -- "$dasc|"
57 local dummy line llen curlin=0
59 cat "$@" | while IFS= read -r line; do
61 (( llen == -1 )) && llen=${#line}
62 (( llen = llen ? (llen + COLUMNS - 1) / COLUMNS : 1 ))
63 if (( (curlin += llen) >= LINES )); then
64 print -n -- '\033[7m--more--\033[0m'
66 [[ $dummy = [Qq]* ]] && return 0
74 eval export "\"$1\""'="$2"'
78 [[ -d $p/. ]] || continue
79 [[ :$PATH: = *:$p:* ]] || PATH=$p:$PATH
84 : place customisations above this line