# (new)user friendlyness
alias vi='echo -e "HINT: type :q (and press enter) to quit\n[press a key]";read;vi'; 
alias mg='echo -e "HINT: type Ctrl+c Ctrl-x to quit\n[press a key]";read;mg'; 
alias nano='echo -e "HINT: type Ctrl+x to quit\n[press a key]"       ;read;nano'; 

# save space in the iso image
alias curl="wget -q -O - "
alias make="mim"

# minimalist autoenv version [https://github.com/hyperupcall/autoenv]
cd(){
  test -f $(pwd)/.env.leave && source $(pwd)/.env.leave     # cleanup environment
  command cd ${1:+"$@"} && {
    hook cd "$@"
    test -f $(pwd)/.env && { # setup environment / run scripts e.g.
      test "$(cat ~/.config/autoenv/prompt_cd)" = 1 && {
        if "$(confirm ".env detected, execute?")" = false; then return 0; fi 
      }
      source $(pwd)/.env 
    }
    ls                                          # list directories
  }
}

# start index.js if /dev/browser/js filesize is not great than 0
if [ ! -s /dev/browser/js ]; then
  chmod +x /mnt/root/index.js && /mnt/root/index.js | grep -v undefined
fi

# start index.html if /dev/browser/html filesize is not great than 0
if [ ! -s /dev/browser/html ]; then
  chmod +x /mnt/root/index.html && /mnt/root/index.html
fi

# uncomment to set location (3D scene file [with XR Fragments] ) 
#require https://xrfragment.org/index.glb 
#require https://coderofsalvation.github.io/xrsh-media/assets/background.glb