scriptlib

This commit is contained in:
Jana Dönszelmann 2025-08-25 14:04:31 +02:00
parent ddb92ea0c5
commit 816c61985d
No known key found for this signature in database
5 changed files with 67 additions and 19 deletions

View file

@ -12,7 +12,7 @@ let
"cp-ser" = cp-media "ser" "shows";
"cp-ani" = cp-media "ani" "anime";
"dumpasm" = "${pkgs.custom.dumpasm}/bin/dumpasm";
"p" = calc;
"p" = builtins.trace calc calc;
"s" = "systemctl";
"j" = "journalctl";
"ju" = "journalctl -u";

View file

@ -1,22 +1,11 @@
{ pkgs, ... }:
{
calc = "${pkgs.python313}/bin/python -i ${pkgs.writeText "init.py" ''
from math import *;
# import numpy as np
kilo = 1000
mega = 1000 * kilo
giga = 1000 * mega
tera = 1000 * giga
peta = 1000 * tera
b = 1
kib = 1024
mib = 1024 * kib
gib = 1024 * mib
tib = 1024 * gib
pib = 1024 * tib
import sys
sys.path.append("${../../scriptlib}")
sys.path.append("${pkgs.python313Packages.numpy}/lib/python3.13/site-packages/")
from scriptlib import *
''} ";
cp-media =
name: media:

View file

@ -33,7 +33,6 @@
# diff-editor = "${pkgs.meld}/bin/meld";
};
# core.fsmonitor = "${pkgs.watchman}/bin/watchman";
core.fsmonitor = "watchman";
core.watchman.register-snapshot-trigger = true;
@ -60,7 +59,7 @@
"--from"
"closest_bookmark(@-)"
"--to"
"@-"
"@"
];
catchup = [
"rebase"
@ -70,6 +69,15 @@
"tronk()"
"--skip-emptied"
];
move = [
"rebase"
"-r"
];
mdiff = [
"diff"
"--from"
"tronk()"
];
};
templates = {
@ -119,7 +127,7 @@
git = {
push-bookmark-prefix = "jdonszelmann/";
private-commits = "description(glob:'wip:*')";
private-commits = "description(glob:'wip:*') | description(glob:'trial:*')";
write-change-id-header = true;
fetch = [

50
scriptlib/scriptlib.py Normal file
View file

@ -0,0 +1,50 @@
from math import *;
import numpy as np
from pathlib import Path
import subprocess
import os
from pprint import pprint
from itertools import *
Path.__repr__ = lambda i: f"p'{str(i)}'"
kilo = 1000
mega = 1000 * kilo
giga = 1000 * mega
tera = 1000 * giga
peta = 1000 * tera
b = 1
kib = 1024
mib = 1024 * kib
gib = 1024 * mib
tib = 1024 * gib
pib = 1024 * tib
inch = 0.0254
yard = 0.9144
def cwd():
return Path.cwd()
def ls(d = None):
if d is None:
d = cwd()
return list(Path(d).iterdir())
def glob(expr):
return list(cwd().glob(expr))
def run(cmd, only_stdout=True):
res = subprocess.run(cmd, capture_output=True, text=True, shell=True)
if only_stdout:
return str(res.stdout)
else:
return res
def cat(file):
return open(file, "r").read()
print_ = print
print = pprint

View file

@ -0,0 +1 @@
Ptmux;_Ga=d,q=2,d=a\\