xrsh-buildroot/buildroot-v86/board/v86/rootfs_overlay/etc/profile

71 lines
2.2 KiB
Plaintext
Raw Normal View History

export HOME=/root
export PATH=$PATH:/etc:~/bin
2024-09-11 14:58:31 +02:00
# source URL data from v86 (file created by v86 during boot)
test -f /mnt/profile.browser && source /mnt/profile.browser
2024-09-11 14:58:31 +02:00
# source xrsh env
source /etc/profile.xrsh
# source shell functions
source /etc/profile.sh
2024-09-15 11:18:36 +02:00
# source user shell defaults
test -f ~/.profile && source ~/.profile
2024-09-11 14:58:31 +02:00
# source js functions
2024-09-13 18:55:12 +02:00
test -f /etc/profile.js && chmod +x /etc/profile.js && /etc/profile.js | grep -v undefined
2024-09-11 14:58:31 +02:00
2024-09-15 11:18:36 +02:00
# source user js functions
test -f ~/.profile.js && chmod +x ~/.profile.js && ~/.profile.js | grep -v undefined
2024-09-11 14:58:31 +02:00
## forward not-found commands to javascript (via jsh)
command_not_found_handle(){
echo "[!] '$1' not found, did you mean $1(...) (javascript?)"
test -n "$ONBOARDING" && echo "[i] type 'help' for handy commands"
2024-09-15 11:18:36 +02:00
test -n "$ONBOARDING" || help_tips
2024-09-11 14:58:31 +02:00
}
2024-09-15 11:18:36 +02:00
help_tips(){
2024-09-11 14:58:31 +02:00
echo ""
echo 'TIPS'
echo '----'
echo 'text editors ' "type '<vi|mg|nano> <textfile>'"
echo 'programming languages ' "type 'ls ~/bin/helloworld*'"
echo 'run 64bit linux app ' "type 'blink <x86_64 binary>'"
2024-09-11 14:58:31 +02:00
echo 'js run ' "type 'js 'alert(\"hello\")'"
echo 'js console.log: ' "type 'console document.baseURI"
echo 'js function as cmd: ' "type 'alias $1=\"jsh $1\"' to run '$1 yo' as $1('yo')"
echo 'js inspect: ' "type 'js \"return document.baseURI\"'"
echo 'js console mute: ' "type 'echo 0 > /dev/browser/tty' to disable"
2024-09-11 14:58:31 +02:00
echo 'js capture console: ' "type 'tail -f /dev/browser/console'"
echo 'jsh<->sh hooks: ' "type 'chmod +x ~/hook.d/*/* && alert helloworld'"
echo 'include file into page' "type 'require <url.js|css>'"
echo ''
2024-09-15 11:18:36 +02:00
echo 'type "help" or "man xrsh" to read the full manual'
2024-09-11 14:58:31 +02:00
ONBOARDING=1
}
export TERM=xterm-256color
2024-09-13 18:55:12 +02:00
export PS1="\[\033[38;5;165m\]> \[\033[0m\]"
2024-09-11 14:58:31 +02:00
2024-09-15 11:18:36 +02:00
# aliases
alias ls='ls -ha -w100'
# interactive login
[[ -t 0 ]] && {
test -n "$STY" || {
2024-09-13 18:55:12 +02:00
resize # call twice
resize # otherwise COLUMNS/ROWS is 0
# add URL-hash as extra screen session
test -z "$HASH" || {
grep 'screen -t #' /root/.screenrc || {
2024-09-15 11:18:36 +02:00
echo "screen -t xrsh+URL 3 /bin/sh -c '${HASH}; sh'" | sed "s/'#/'/g" >> /root/.screenrc
2024-09-13 18:55:12 +02:00
}
}
screen -Aa -R -T screen-256color -c /root/.screenrc
}
2024-09-13 18:55:12 +02:00
test -n "$STY" && cat /etc/motd
}