Advertisement
thioshp

mkshrc file

Sep 16th, 2017
517
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.33 KB | None | 0 0
  1. # Copyright (c) 2010, 2012, 2013
  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:=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. function precmd {
  13.     typeset e=$?
  14.  
  15.     (( e )) && print -n "$e|"
  16. }
  17. PS1='$(precmd)$USER@$HOSTNAME:${PWD:-?} '"$PS1 "
  18. export HOME HOSTNAME MKSH SHELL TERM USER
  19. alias l='ls'
  20. alias la='l -a'
  21. alias ll='l -l'
  22. alias lo='l -a -l'
  23.  
  24. function hd {
  25.     cat "$@" | command hd /proc/self/fd/0
  26. }
  27.  
  28. function more {
  29.     local dummy line llen curlin=0
  30.  
  31.     cat "$@" | while IFS= read -r line; do
  32.         llen=${%line}
  33.         (( llen == -1 )) && llen=${#line}
  34.         (( llen = llen ? (llen + COLUMNS - 1) / COLUMNS : 1 ))
  35.         if (( (curlin += llen) >= LINES )); then
  36.             print -n -- '\033[7m--more--\033[0m'
  37.             read -u1 dummy
  38.             [[ $dummy = [Qq]* ]] && return 0
  39.             curlin=$llen
  40.         fi
  41.         print -r -- "$line"
  42.     done
  43. }
  44.  
  45. function setenv {
  46.     eval export "\"$1\""'="$2"'
  47. }
  48.  
  49. for p in ~/.bin; do
  50.     [[ -d $p/. ]] || continue
  51.     [[ :$PATH: = *:$p:* ]] || PATH=$p:$PATH
  52. done
  53.  
  54. unset p
  55.  
  56. : place customisations above this line
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement