From 127207830ac01eb3a49619d8ce1612a31a047b73 Mon Sep 17 00:00:00 2001 From: stuebinm Date: Fri, 15 Mar 2024 17:09:35 +0100 Subject: home: i have officially lost control of all the git repos so I added a command to search though them :) Should help whenever I'm not sure if I have cloned something already. Intended usage is something like `cd (git where)`. It might be useful to extend this so it doesn't assume everything has a remote called `origin', but looks like my only three git repos which don't have one (and which are not my own) where cloned via heartwood/radicle, and I'm unlikely to need those again tbh. … tbh, it might also be worth it to add a mass-fetch command? So much of what I've cloned is just old stuff lying around … --- home/home-minimal.nix | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'home') diff --git a/home/home-minimal.nix b/home/home-minimal.nix index c265218..d6488a5 100644 --- a/home/home-minimal.nix +++ b/home/home-minimal.nix @@ -70,6 +70,15 @@ end fd $pattern | fzf --preview="glow {} --style=dark" --bind ctrl-j:preview-down,ctrl-k:preview-up,ctrl-alt-j:preview-page-down,ctrl-alt-k:preview-page-up ''; + git-where.body = '' + set gits (fd "^\\.git\$" -H) + for git in $gits + # .git may be a file (e.g. in case of standalone worktrees) + if test -d $git && contains origin (git --git-dir $git remote) + echo (git -C $git -C .. rev-parse --show-toplevel) (git --git-dir $git remote get-url origin) + end + end | fzf --preview 'git -C {1} show --no-show-signature --color=always' | cut -f1 -d" " + ''; }; }; @@ -93,6 +102,7 @@ log.showSignature = true; init.defaultBranch = "main"; alias.search = "!git log --format='tformat:%h %cs %s' --no-show-signature | fzf --multi --preview 'git show {+1}|bat -p -lpatch --color=always' | cut -f1 -d\" \" | wl-copy -n && wl-paste"; + alias.where = "!fish -c git-where"; merge.conflictStyle = "zdiff3"; push.autoSetupRemote = true; commit.verbose = true; -- cgit v1.2.3