From 7f4d93f4d24fd43c12f0308c07b0f6c78508f85a Mon Sep 17 00:00:00 2001 From: Jan Andrle Date: Wed, 20 Mar 2024 21:48:17 +0100 Subject: [PATCH] :zap: utils/bin updates (socky, njs, github-releases) --- .config/nodejsscript/nodejsscriptrc.mjs | 20 +++++++++++++++----- bin/github-releases.json | 22 +++++++++++----------- bin/socky.mjs | 7 ++++--- 3 files changed, 30 insertions(+), 19 deletions(-) diff --git a/.config/nodejsscript/nodejsscriptrc.mjs b/.config/nodejsscript/nodejsscriptrc.mjs index 3b8afa0..4034566 100644 --- a/.config/nodejsscript/nodejsscriptrc.mjs +++ b/.config/nodejsscript/nodejsscriptrc.mjs @@ -1,8 +1,3 @@ -/* --print/--echo aliases */ -Reflect.defineProperty($, "nosed", { get(){ return this.stdin.text(""); }, }); -Reflect.defineProperty($, "nojq", { get(){ return this.stdin.json(null); }, }); -Reflect.defineProperty($, "noawk", { get(){ return this.stdin.lines([]); }, }); - /* deprecated/fallback */ globalThis.cyclicLoop= function*(items){ if(!items) items= 'win32'===process.platform ? '|/-\\' : "⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏"; @@ -16,3 +11,18 @@ globalThis.cyclicLoop= function*(items){ Reflect.defineProperty($, "clipboard", { get(){ return s.$().run`xclip -o -selection clipboard`; } }) + +// /** Custom uncaughtException function */ +// export const uncaughtException= console.log; +// /** Place for custom code when script starts */ +// export function onscript(){} +/** Place for custom code when REPL starts (`--interactive`) */ +export function onrepl(){ + Reflect.defineProperty(s, "jq", { get(){ return file=> s.cat(file).xargs(JSON.parse); } }); +} +/** Place for custom code when eval starts (`--eval`/`--print`) */ +export function oneval(){ /* --print/--echo aliases */ + Reflect.defineProperty($, "nosed", { get(){ return this.stdin.text(""); }, }); + Reflect.defineProperty($, "nojq", { get(){ return this.stdin.json(null); }, }); + Reflect.defineProperty($, "noawk", { get(){ return this.stdin.lines([]); }, }); +} diff --git a/bin/github-releases.json b/bin/github-releases.json index 7b26781..439900c 100644 --- a/bin/github-releases.json +++ b/bin/github-releases.json @@ -108,9 +108,9 @@ "group": "nondev", "file_name": "upscayl", "exec": "yes", - "last_update": "2024-02-10T12:17:10Z", + "last_update": "2024-02-29T16:31:09Z", "downloads": "/home/jaandrle/bin/upscayl", - "version": "v2.9.9" + "version": "v2.10.0" }, { "repository": "RasmusLindroth/tut", @@ -152,9 +152,9 @@ "group": "nondev", "file_name": "fedistar", "exec": "yes", - "last_update": "2024-02-09T11:38:02Z", + "last_update": "2024-02-29T11:08:37Z", "downloads": "/home/jaandrle/bin/fedistar", - "version": "v1.8.4" + "version": "v1.9.0" }, { "repository": "ollama/ollama", @@ -163,9 +163,9 @@ "group": "ai", "file_name": "ollama", "exec": "yes", - "last_update": "2024-02-22T22:55:46Z", + "last_update": "2024-03-10T02:24:04Z", "downloads": "/home/jaandrle/bin/ollama", - "version": "v0.1.27" + "version": "v0.1.29" }, { "repository": "neovim/neovim", @@ -186,9 +186,9 @@ "group": "dev", "file_name": "escrcpy", "exec": "yes", - "last_update": "2023-12-27T01:18:21Z", + "last_update": "2024-03-13T03:05:48Z", "downloads": "/home/jaandrle/bin/escrcpy", - "version": "v1.16.8" + "version": "v1.17.3" }, { "repository": "drovp/drovp", @@ -208,9 +208,9 @@ "group": "ai", "file_name": "jan", "exec": "yes", - "last_update": "2024-02-26T03:30:36Z", + "last_update": "2024-03-11T06:34:40Z", "downloads": "/home/jaandrle/bin/jan", - "version": "v0.4.7" + "version": "v0.4.8" } ] -} +} \ No newline at end of file diff --git a/bin/socky.mjs b/bin/socky.mjs index 4a645d6..99c1e91 100755 --- a/bin/socky.mjs +++ b/bin/socky.mjs @@ -2,15 +2,16 @@ /* jshint esversion: 11,-W097, -W040, module: true, node: true, expr: true, undef: true *//* global echo, $, pipe, s, fetch, cyclicLoop */ $.api("") -.version("2024-03-07") +.version("2024-03-18") .command("silicon [file]", [ "Generovat obrázek s kódem pro sdílení na sociálních sítích. (alternativa k Carbon)", "Toto je jen drobný wrapper s mými defaultními parametry.", "Další nápověda viz `silicon --help`.", ]) + .option("--title", "Set window title (default: file name).") .option("--range", "Select lines from file in the form `start:end`") .option("--font-size, --fs", "Font size", 25) - .action(function silicon(file, { range, fs, ["font-size"]: _fs, _, ...args }){ + .action(function silicon(file, { title= file, range, fs, ["font-size"]: _fs, _, ...args }){ args= Object.assign({ theme: "OneHalfDark", font: `Ubuntu Mono =${fs}`, @@ -27,7 +28,7 @@ $.api("") const content= s.$().cat(file).toString().split(/\r?\n/).slice(...range.split(":").map(n=> parseInt(n)+1)); s.echo(content.join("\n")).to(from); } - s.run`silicon ${from} --output ${output} --window-title ${file} ${args}`; + s.run`silicon ${from} --output ${output} --window-title ${title} ${args}`; echo(`Generated ${output}`); if(from!== file) s.rm(from); $.exit(0);