Add fx bootstrap.sh and copy-paste command on the live page
This commit is contained in:
@@ -0,0 +1,35 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Fetches f() and fx() (plus all default sources) into a temp dir and
|
||||||
|
# sources them into your CURRENT shell -- no git, no cloning.
|
||||||
|
#
|
||||||
|
# Run with eval so sourcing happens in your real shell, not a subshell
|
||||||
|
# that vanishes when the script exits:
|
||||||
|
#
|
||||||
|
# eval "$(curl -fsSL https://huggingface.co/spaces/Daveswo/self-healing-autopoietic-shell/raw/main/contrib/fx/bootstrap.sh)"
|
||||||
|
#
|
||||||
|
# After that: f and fx are ready to use in this shell session. To keep
|
||||||
|
# them in every new shell, add the same eval line to your rc file.
|
||||||
|
|
||||||
|
_base="https://huggingface.co/spaces/Daveswo/self-healing-autopoietic-shell/raw/main"
|
||||||
|
_dir="${TMPDIR:-/tmp}/self-healing-shell-$$"
|
||||||
|
mkdir -p "$_dir/sources.d" 2>/dev/null
|
||||||
|
|
||||||
|
_fetch_ok=1
|
||||||
|
curl -fsSL "$_base/src/f.sh" -o "$_dir/f.sh" || _fetch_ok=0
|
||||||
|
curl -fsSL "$_base/contrib/fx/fx.sh" -o "$_dir/fx.sh" || _fetch_ok=0
|
||||||
|
for s in 10-known.sh 20-history.sh 30-selfdiag.sh 40-pathfuzzy.sh 50-thefuck.sh 90-team-shared.sh; do
|
||||||
|
curl -fsSL "$_base/contrib/fx/sources.d/$s" -o "$_dir/sources.d/$s" || _fetch_ok=0
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "$_fetch_ok" != 1 ]; then
|
||||||
|
echo "bootstrap: fetch failed, check your connection" >&2
|
||||||
|
else
|
||||||
|
chmod +x "$_dir"/*.sh "$_dir"/sources.d/*.sh 2>/dev/null
|
||||||
|
FX_SOURCES_DIR="$_dir/sources.d"
|
||||||
|
export FX_SOURCES_DIR
|
||||||
|
. "$_dir/f.sh"
|
||||||
|
. "$_dir/fx.sh"
|
||||||
|
echo "f() and fx() are ready in this shell. Try: fx <command-that-might-fail>"
|
||||||
|
fi
|
||||||
|
|
||||||
|
unset _base _dir _fetch_ok s
|
||||||
+52
-1
@@ -20,6 +20,26 @@
|
|||||||
}
|
}
|
||||||
h1{font-size:1.4rem; margin:0 0 .4rem; font-weight:600;}
|
h1{font-size:1.4rem; margin:0 0 .4rem; font-weight:600;}
|
||||||
header p{color:var(--dim); margin:.2rem 0; font-size:.92rem;}
|
header p{color:var(--dim); margin:.2rem 0; font-size:.92rem;}
|
||||||
|
.runbox{
|
||||||
|
max-width:900px; margin:0 auto 1.5rem; padding:0 1.5rem;
|
||||||
|
}
|
||||||
|
.runbox-label{font-size:.78rem; text-transform:uppercase; letter-spacing:.06em; color:var(--dim); margin-bottom:.4rem;}
|
||||||
|
.runbox-cmd{
|
||||||
|
display:flex; align-items:stretch; gap:0; background:var(--panel);
|
||||||
|
border:1px solid var(--accent); border-radius:8px; overflow:hidden;
|
||||||
|
}
|
||||||
|
.runbox-cmd code{
|
||||||
|
flex:1; padding:.75rem .9rem; font-size:.82rem; overflow-x:auto;
|
||||||
|
white-space:pre; color:var(--ok);
|
||||||
|
}
|
||||||
|
.runbox-cmd button{
|
||||||
|
flex-shrink:0; background:var(--accent); border:0; color:#0b0d10;
|
||||||
|
font:inherit; font-weight:600; font-size:.8rem; padding:0 1.1rem; cursor:pointer;
|
||||||
|
}
|
||||||
|
.runbox-cmd button:hover{opacity:.9;}
|
||||||
|
.runbox-cmd button.copied{background:var(--ok);}
|
||||||
|
.runbox-note{color:var(--dim); font-size:.8rem; margin-top:.5rem; line-height:1.5;}
|
||||||
|
.runbox-note code{background:#171b22; padding:.05rem .3rem; border-radius:4px;}
|
||||||
main{max-width:900px; margin:0 auto; padding:0 1.5rem 3rem; display:grid; gap:1.25rem; grid-template-columns:1fr; }
|
main{max-width:900px; margin:0 auto; padding:0 1.5rem 3rem; display:grid; gap:1.25rem; grid-template-columns:1fr; }
|
||||||
@media (min-width:760px){ main{grid-template-columns: 1.3fr .9fr;} }
|
@media (min-width:760px){ main{grid-template-columns: 1.3fr .9fr;} }
|
||||||
.panel{
|
.panel{
|
||||||
@@ -70,9 +90,18 @@
|
|||||||
<header>
|
<header>
|
||||||
<h1>🔁 Self-Healing Autopoietic Shell</h1>
|
<h1>🔁 Self-Healing Autopoietic Shell</h1>
|
||||||
<p>A shell function that learns from its own failures — run a command, teach it a fix when it fails, and it never fails that way again.</p>
|
<p>A shell function that learns from its own failures — run a command, teach it a fix when it fails, and it never fails that way again.</p>
|
||||||
<p class="dim">This is a live simulation of <code>f()</code> running entirely in your browser. Try a command below.</p>
|
<p class="dim">The simulation below is a browser mockup, not a real shell — this page is static, so nothing here can actually execute anything. To run the real thing in your real shell:</p>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
|
<div class="runbox">
|
||||||
|
<div class="runbox-label">run this in your terminal — no git clone needed</div>
|
||||||
|
<div class="runbox-cmd">
|
||||||
|
<code id="bootstrapCmd">eval "$(curl -fsSL https://huggingface.co/spaces/Daveswo/self-healing-autopoietic-shell/raw/main/contrib/fx/bootstrap.sh)"</code>
|
||||||
|
<button id="copyBtn" type="button">copy</button>
|
||||||
|
</div>
|
||||||
|
<div class="runbox-note">fetches <code>f()</code>, <code>fx()</code>, and all default fix-sources into a temp dir and sources them into your <em>current</em> shell — add the same line to your rc file to keep it every session.</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<main>
|
<main>
|
||||||
<div class="panel">
|
<div class="panel">
|
||||||
<h2>Simulated shell</h2>
|
<h2>Simulated shell</h2>
|
||||||
@@ -244,6 +273,28 @@
|
|||||||
print('// try: cat needs-fix.txt', 'dim');
|
print('// try: cat needs-fix.txt', 'dim');
|
||||||
print('// it will fail once — teach it a fix like: echo hello > needs-fix.txt', 'dim');
|
print('// it will fail once — teach it a fix like: echo hello > needs-fix.txt', 'dim');
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
(function(){
|
||||||
|
const btn = document.getElementById('copyBtn');
|
||||||
|
const codeEl = document.getElementById('bootstrapCmd');
|
||||||
|
if(!btn || !codeEl) return;
|
||||||
|
btn.addEventListener('click', async () => {
|
||||||
|
try{
|
||||||
|
await navigator.clipboard.writeText(codeEl.textContent);
|
||||||
|
}catch(e){
|
||||||
|
const range = document.createRange();
|
||||||
|
range.selectNode(codeEl);
|
||||||
|
window.getSelection().removeAllRanges();
|
||||||
|
window.getSelection().addRange(range);
|
||||||
|
document.execCommand('copy');
|
||||||
|
window.getSelection().removeAllRanges();
|
||||||
|
}
|
||||||
|
const original = btn.textContent;
|
||||||
|
btn.textContent = 'copied';
|
||||||
|
btn.classList.add('copied');
|
||||||
|
setTimeout(() => { btn.textContent = original; btn.classList.remove('copied'); }, 1500);
|
||||||
|
});
|
||||||
|
})();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
Reference in New Issue
Block a user