finetuned shell-env + codemirror + added filemanager
This commit is contained in:
parent
04b5621249
commit
b3cdc74578
File diff suppressed because it is too large
Load Diff
|
@ -17,5 +17,6 @@
|
|||
Please hook up your (bluetooth) keyboard to use xrsh.
|
||||
Use [38;5;129mCtrl+a+0/1/2/3/..[38;5;165m to switch terminals.
|
||||
Use [38;5;129mCtrl+a+c[38;5;165m to create a new terminal.
|
||||
Use [38;5;129m'save'[38;5;165m to save session (survives tab-close)
|
||||
Happy hacking! \o/
|
||||
|
||||
|
|
|
@ -37,15 +37,22 @@ prompt(){
|
|||
|
||||
console(){
|
||||
js 'return '$1
|
||||
printf "\n"
|
||||
}
|
||||
|
||||
# usage: require <url|file>
|
||||
#
|
||||
# info: adds javascript/css url/script to DOM
|
||||
require(){
|
||||
file=$(basename "$1")
|
||||
js '(async () => {
|
||||
await AFRAME.utils.require({"'$file'": "'$1'"})
|
||||
})()'
|
||||
})(); return ""'
|
||||
}
|
||||
|
||||
# usage: man <topic>
|
||||
#
|
||||
# info: simple manual viewer
|
||||
man(){
|
||||
test "$1" = xrsh && {
|
||||
cat /root/manual.md | less
|
||||
|
@ -53,8 +60,23 @@ man(){
|
|||
}
|
||||
help(){ man xrsh; }
|
||||
|
||||
# usage: infinite ./runmydaemon
|
||||
#
|
||||
# info: will run daemon forever (restarts when quit)
|
||||
infinite(){
|
||||
while sleep 1s; do
|
||||
"$@"
|
||||
done
|
||||
}
|
||||
|
||||
# usage: wait_for sleep 5s
|
||||
#
|
||||
# info: will print dots while waiting for process to end
|
||||
wait_for(){
|
||||
dotting(){ while sleep 1s; do printf "."; done; }
|
||||
dotting &
|
||||
PID=$!
|
||||
"$@"
|
||||
kill -9 $PID
|
||||
printf "\n"
|
||||
}
|
||||
|
|
|
@ -2,6 +2,12 @@
|
|||
|
||||
test -d /dev/browser || {
|
||||
|
||||
move_root_to_9pfs(){
|
||||
test -d /mnt/root && return 0
|
||||
mv /root /mnt/.
|
||||
ln -fs /mnt/root /root
|
||||
}
|
||||
|
||||
setup_links(){
|
||||
ln -fs /etc/motd ~/.motd
|
||||
ln -fs /mnt/profile.browser ~/.profile.browser
|
||||
|
@ -37,21 +43,22 @@ test -d /dev/browser || {
|
|||
cat /dev/ttyS1 | xargs -I{} /bin/sh -c 'source /etc/profile; logger "isoterminal.exec({})"; {}'
|
||||
}
|
||||
|
||||
setup_reflect_index_html(){
|
||||
# listen for writes to index.html and send them to DOM
|
||||
inotifyd echo /root/index.html | awk '/^w / { system("cat "$2" | grep -vE \"^#!\" > /dev/browser/html") }'
|
||||
}
|
||||
|
||||
setup_reflect_index_js(){
|
||||
# listen for writes to index.js and send them to DOM
|
||||
inotifyd echo /root/index.js | awk '/^w / { system("cat "$2" | grep -vE \"^#!\" > /dev/browser/js") }'
|
||||
setup_listen_homedir(){
|
||||
sleep 4 # wait for inode of /mnt/root to become live (due to move_root_to_9pfs)
|
||||
inotifyd echo /mnt/root | awk '
|
||||
|
||||
# listen for writes to rootdir and send them to DOM
|
||||
/^[we] \/mnt\/root index\.html/ { system("cat "$2"/"$3" | grep -vE \"^#!\" > /dev/browser/html") }
|
||||
/^[we] \/mnt\/root index\.js/ { system("cat "$2"/"$3" | grep -vE \"^#!\" > /dev/browser/js") }
|
||||
|
||||
'
|
||||
}
|
||||
|
||||
move_root_to_9pfs
|
||||
setup_browser_dev
|
||||
setup_links
|
||||
setup_network
|
||||
setup_overlayfs
|
||||
setup_incoming_cmds &
|
||||
setup_reflect_index_html &
|
||||
setup_reflect_index_js &
|
||||
setup_listen_homedir &
|
||||
}
|
||||
|
|
|
@ -33,6 +33,6 @@ term xterm-256color
|
|||
defbce on # use current bg color for erased chars
|
||||
|
||||
# setup windows
|
||||
screen -t manual 0 /bin/sh -c '/bin/infinite help'
|
||||
screen -t logs 1 /bin/sh -c '/bin/infinite tail -n1 -f /dev/browser/console /var/log/messages'
|
||||
screen -t manual 0 /bin/sh --noprofile --norc -c '/bin/infinite help'
|
||||
screen -t logs 1 /bin/sh --noprofile --norc -c '/bin/infinite tail -n1 -f /dev/browser/console /var/log/messages'
|
||||
screen -t xrsh 2
|
||||
|
|
|
@ -1,4 +1,25 @@
|
|||
#!/bin/sh
|
||||
source /etc/profile.sh
|
||||
require 'com/codemirror.js' # add <script src="com/codemirror.js"></script> to dom
|
||||
echo '<a-entity codemirror grabbable></a-entity>' >> /dev/browser/html
|
||||
#!/bin/js
|
||||
|
||||
(async function(){
|
||||
|
||||
await AFRAME.utils.require({
|
||||
codemirrorjs: "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.58.1/codemirror.js",
|
||||
codemirrorcss: "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.35.0/codemirror.css",
|
||||
cmtheme: "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.35.0/theme/shadowfox.css"
|
||||
})
|
||||
|
||||
await AFRAME.utils.require({
|
||||
cmxml: "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.35.0/mode/xml/xml.js",
|
||||
cmjavascript: "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.35.0/mode/javascript/javascript.js",
|
||||
cmcss: "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.35.0/mode/css/css.js",
|
||||
highlight: "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.35.0/mode/htmlmixed/htmlmixed.js",
|
||||
codemirrorAF: "com/codemirror.js"
|
||||
})
|
||||
|
||||
document.querySelector("a-entity#root").innerHTML += `<a-entity codemirror='file: ${args[1]}'></a-entity>`
|
||||
|
||||
})()
|
||||
|
||||
return "" // empty stdout(put)
|
||||
|
||||
// for shellscript-equivalent see bin/codemirror
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
#!/bin/sh
|
||||
source /etc/profile.sh
|
||||
|
||||
require 'https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.58.1/codemirror.js'
|
||||
require 'https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.35.0/codemirror.css'
|
||||
require 'https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.35.0/theme/shadowfox.css'
|
||||
require 'com/codemirror.js'
|
||||
|
||||
echo "<a-entity codemirror='file: $1'></a-entity>" >> /dev/browser/html
|
||||
|
||||
# for js-equivalent see bin/codemirror
|
|
@ -1,4 +1,13 @@
|
|||
#!/bin/js
|
||||
const isoterminal = document.querySelector('[isoterminal]').components.isoterminal.isoterminal
|
||||
isoterminal.save()
|
||||
return "[OK] xrsh state saved\n"
|
||||
#!/bin/sh
|
||||
source /etc/profile.sh
|
||||
|
||||
javascript='
|
||||
const isoterminal = document.querySelector("[isoterminal]").components.isoterminal.isoterminal
|
||||
isoterminal.save()
|
||||
return "[OK] xrsh state saved\n"
|
||||
'
|
||||
|
||||
echo "[OK] triggering ~/hook.d/save/* scripts"
|
||||
hook save
|
||||
echo "[..] please wait.."
|
||||
js "$javascript"
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
#!/bin/js
|
||||
// /bin/filemanager => browser play mp3
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/sh
|
||||
echo "[OK] hook.d/save/tolog: reporting save to OS"
|
||||
logger "state was saved at $(date)"
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Loading…
Reference in New Issue