Commit 48e846ecfff8
Changed files (3)
home
common
dev
pkgs
repo-find
home/common/dev/gh-news.nix
@@ -1,7 +1,9 @@
-{ ... }:
+{ pkgs, ... }:
{
imports = [ ../../modules/gh-news.nix ];
+ home.packages = [ pkgs.repo-find ];
+
programs.gh-news = {
enable = true;
enableNotifications = true;
@@ -15,6 +17,28 @@
default_preview_mode = "vertical";
repos_collapsed = false;
auto_mark_read = false;
+
+ actions = [
+ {
+ name = "Open in lazypr";
+ command = "lazypr {url}";
+ interactive = true;
+ }
+ {
+ name = "Copy URL";
+ command = "echo -n {url} | wl-copy";
+ }
+ {
+ name = "Open lazyworktree";
+ command = "cd $(repo-find {full_name}) && lazyworktree";
+ interactive = true;
+ }
+ {
+ name = "Create worktree from PR";
+ command = "cd $(repo-find {full_name}) && lazyworktree create --from-pr $(echo {url} | grep -oE 'pull/[0-9]+' | grep -oE '[0-9]+')";
+ interactive = true;
+ }
+ ];
};
};
}
pkgs/repo-find/default.nix
@@ -0,0 +1,35 @@
+{
+ writeShellScriptBin,
+}:
+
+writeShellScriptBin "repo-find" ''
+ # Find a local git repository given owner/repo
+ # Tries multiple common path patterns
+
+ if [ -z "$1" ]; then
+ echo "Usage: repo-find <owner/repo>" >&2
+ exit 1
+ fi
+
+ full_name="$1"
+ owner="''${full_name%%/*}"
+ repo="''${full_name##*/}"
+
+ # Paths to try in order
+ paths=(
+ "$HOME/src/github.com/$full_name"
+ "$HOME/src/$full_name"
+ "$HOME/src/$owner/$repo"
+ "$HOME/src/$repo"
+ )
+
+ for path in "''${paths[@]}"; do
+ if [ -d "$path" ]; then
+ echo "$path"
+ exit 0
+ fi
+ done
+
+ echo "Repository $full_name not found locally" >&2
+ exit 1
+''
pkgs/default.nix
@@ -28,6 +28,7 @@ in
arr = pkgs.callPackage ../tools/arr { };
download-kiwix-zim = pkgs.callPackage ../tools/download-kiwix-zim { };
cliphist-cleanup = pkgs.callPackage ./cliphist-cleanup { };
+ repo-find = pkgs.callPackage ./repo-find { };
toggle-color-scheme = pkgs.callPackage ./toggle-color-scheme { };
homepage = pkgs.callPackage ./homepage { inherit globals; };
audible-converter = pkgs.callPackage ./audible-converter { };