blob: 4beaf909d78f7d116db4f0faea856678e845f28e [file] [log] [blame]
Thorsten Glaserc6476ac2014-07-28 13:18:35 +00001# Copyright (c) 2010, 2012, 2013, 2014
Thorsten Glaserc2dc5de2013-02-18 23:02:51 +00002# Thorsten Glaser <tg@mirbsd.org>
Jean-Baptiste Queru5155f1c2011-06-16 10:05:28 -07003# This file is provided under the same terms as mksh.
4#-
5# Minimal /system/etc/mkshrc for Android
Thorsten Glaserc2dc5de2013-02-18 23:02:51 +00006#
7# Support: https://launchpad.net/mksh
Jean-Baptiste Queru5155f1c2011-06-16 10:05:28 -07008
Elliott Hughes11ed7f92014-12-11 17:13:19 -08009: ${TERM:=xterm} ${HOME:=/data} ${MKSH:=/system/bin/sh} ${HOSTNAME:=$(getprop ro.product.device)}
Thorsten Glaserc2dc5de2013-02-18 23:02:51 +000010: ${SHELL:=$MKSH} ${USER:=$(typeset x=$(id); x=${x#*\(}; print -r -- ${x%%\)*})} ${HOSTNAME:=android}
Jean-Baptiste Queru5155f1c2011-06-16 10:05:28 -070011if (( USER_ID )); then PS1='$'; else PS1='#'; fi
Thorsten Glaser811a5752013-07-25 14:24:45 +000012PS4='[$EPOCHREALTIME] '; PS1='${|
13 local e=$?
Jean-Baptiste Queru5155f1c2011-06-16 10:05:28 -070014
Thorsten Glaser811a5752013-07-25 14:24:45 +000015 (( e )) && REPLY+="$e|"
16
17 return $e
18}$USER@$HOSTNAME:${PWD:-?} '"$PS1 "
Thorsten Glaserc2dc5de2013-02-18 23:02:51 +000019export HOME HOSTNAME MKSH SHELL TERM USER
Jean-Baptiste Queru5155f1c2011-06-16 10:05:28 -070020
Thorsten Glaserc2dc5de2013-02-18 23:02:51 +000021function hd {
Thorsten Glaser811a5752013-07-25 14:24:45 +000022 local -Uui16 -Z11 pos=0
23 local -Uui16 -Z5 hv=2147483647
24 local dasc line i
25
26 cat "$@" | { set +U; if read -arN -1 line; then
27 typeset -i1 line
28 i=0
29 while (( i < ${#line[*]} )); do
30 hv=${line[i++]}
31 if (( (pos & 15) == 0 )); then
32 (( pos )) && print -r -- "$dasc|"
33 print -n "${pos#16#} "
34 dasc=' |'
35 fi
36 print -n "${hv#16#} "
37 if (( (hv < 32) || (hv > 126) )); then
38 dasc+=.
39 else
40 dasc+=${line[i-1]#1#}
41 fi
42 (( (pos++ & 15) == 7 )) && print -n -- '- '
43 done
44 while (( pos & 15 )); do
45 print -n ' '
46 (( (pos++ & 15) == 7 )) && print -n -- '- '
47 done
48 (( hv == 2147483647 )) || print -r -- "$dasc|"
49 fi; }
Thorsten Glaserc2dc5de2013-02-18 23:02:51 +000050}
51
Thorsten Glaserc2dc5de2013-02-18 23:02:51 +000052function setenv {
53 eval export "\"$1\""'="$2"'
54}
55
Jean-Baptiste Queru5155f1c2011-06-16 10:05:28 -070056for p in ~/.bin; do
57 [[ -d $p/. ]] || continue
58 [[ :$PATH: = *:$p:* ]] || PATH=$p:$PATH
59done
60
61unset p
62
63: place customisations above this line