blob: 510fdb72ea16b75119a2d33866d0b480923498e3 [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 Hughes417ccf42015-02-09 12:25:41 -08009: ${HOME:=/data}
10: ${HOSTNAME:=$(getprop ro.product.device)}
11: ${HOSTNAME:=android}
12: ${MKSH:=/system/bin/sh}
13: ${SHELL:=$MKSH}
14: ${TERM:=xterm}
15: ${TMPDIR:=/data/local/tmp}
16: ${USER:=$(id -un)}
17export HOME HOSTNAME MKSH SHELL TERM TMPDIR USER
18
Jean-Baptiste Queru5155f1c2011-06-16 10:05:28 -070019if (( USER_ID )); then PS1='$'; else PS1='#'; fi
Thorsten Glaser811a5752013-07-25 14:24:45 +000020PS4='[$EPOCHREALTIME] '; PS1='${|
21 local e=$?
Jean-Baptiste Queru5155f1c2011-06-16 10:05:28 -070022
Thorsten Glaser811a5752013-07-25 14:24:45 +000023 (( e )) && REPLY+="$e|"
24
25 return $e
26}$USER@$HOSTNAME:${PWD:-?} '"$PS1 "
Jean-Baptiste Queru5155f1c2011-06-16 10:05:28 -070027
Thorsten Glaserc2dc5de2013-02-18 23:02:51 +000028function hd {
Thorsten Glaser811a5752013-07-25 14:24:45 +000029 local -Uui16 -Z11 pos=0
30 local -Uui16 -Z5 hv=2147483647
31 local dasc line i
32
33 cat "$@" | { set +U; if read -arN -1 line; then
Elliott Hughes50012062015-03-10 22:22:24 -070034 typeset -i1 'line[*]'
Thorsten Glaser811a5752013-07-25 14:24:45 +000035 i=0
36 while (( i < ${#line[*]} )); do
37 hv=${line[i++]}
38 if (( (pos & 15) == 0 )); then
39 (( pos )) && print -r -- "$dasc|"
40 print -n "${pos#16#} "
41 dasc=' |'
42 fi
43 print -n "${hv#16#} "
44 if (( (hv < 32) || (hv > 126) )); then
45 dasc+=.
46 else
47 dasc+=${line[i-1]#1#}
48 fi
49 (( (pos++ & 15) == 7 )) && print -n -- '- '
50 done
51 while (( pos & 15 )); do
52 print -n ' '
53 (( (pos++ & 15) == 7 )) && print -n -- '- '
54 done
55 (( hv == 2147483647 )) || print -r -- "$dasc|"
56 fi; }
Thorsten Glaserc2dc5de2013-02-18 23:02:51 +000057}
58
Thorsten Glaserc2dc5de2013-02-18 23:02:51 +000059function setenv {
60 eval export "\"$1\""'="$2"'
61}
62
Elliott Hughes50012062015-03-10 22:22:24 -070063for p in ~/bin; do
Jean-Baptiste Queru5155f1c2011-06-16 10:05:28 -070064 [[ -d $p/. ]] || continue
65 [[ :$PATH: = *:$p:* ]] || PATH=$p:$PATH
66done
67
68unset p
69
70: place customisations above this line