OSDN Git Service

4beaf909d78f7d116db4f0faea856678e845f28e
[android-x86/external-mksh.git] / mkshrc
1 # Copyright (c) 2010, 2012, 2013, 2014
2 #       Thorsten Glaser <tg@mirbsd.org>
3 # This file is provided under the same terms as mksh.
4 #-
5 # Minimal /system/etc/mkshrc for Android
6 #
7 # Support: https://launchpad.net/mksh
8
9 : ${TERM:=xterm} ${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='${|
13         local e=$?
14
15         (( e )) && REPLY+="$e|"
16
17         return $e
18 }$USER@$HOSTNAME:${PWD:-?} '"$PS1 "
19 export HOME HOSTNAME MKSH SHELL TERM USER
20
21 function hd {
22         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; }
50 }
51
52 function setenv {
53         eval export "\"$1\""'="$2"'
54 }
55
56 for p in ~/.bin; do
57         [[ -d $p/. ]] || continue
58         [[ :$PATH: = *:$p:* ]] || PATH=$p:$PATH
59 done
60
61 unset p
62
63 : place customisations above this line