From e2832cbe6cfb095dc2d7f71e199a7083a1a2ddbf Mon Sep 17 00:00:00 2001 From: Himadri Bhattacharjee <107522312+lavafroth@users.noreply.github.com> Date: Tue, 31 Mar 2026 10:43:28 +0530 Subject: [PATCH] init: initial helix notebook setup --- .envrc | 1 + .gitignore | 1 + .helix/config.toml | 3 +++ .state_manager.py | 19 +++++++++++++++++++ 4 files changed, 24 insertions(+) create mode 100644 .envrc create mode 100644 .gitignore create mode 100644 .helix/config.toml create mode 100644 .state_manager.py diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..92b2793 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.direnv diff --git a/.helix/config.toml b/.helix/config.toml new file mode 100644 index 0000000..bcc6eca --- /dev/null +++ b/.helix/config.toml @@ -0,0 +1,3 @@ +[keys.normal] +"C-r" = [":write", ":sh kitty @ send-text --match cmdline:python '%%run \"%{buffer_name}\"\n'"] +"C-a" = [":write", ":sh python .state_manager.py \"%{buffer_name}\"", "select_all", "delete_selection"] diff --git a/.state_manager.py b/.state_manager.py new file mode 100644 index 0000000..f915bc5 --- /dev/null +++ b/.state_manager.py @@ -0,0 +1,19 @@ +from pathlib import Path +from sys import argv +state = Path(".state") + +if len(argv) < 2: + exit() + +cell_path = Path(argv[1]) + +state_bytes = 0 + +if state.exists(): + state_bytes = state.read_bytes() + state_bytes = int.from_bytes(state_bytes) + 1 +state.write_bytes(state_bytes.to_bytes()) + +save_path = cell_path.with_stem(cell_path.stem + '_' + str(state_bytes)) +cell_path.rename(save_path) +