From c194e373e1c4ab3d445931103491024170ebc5a3 Mon Sep 17 00:00:00 2001 From: Alex Povel Date: Wed, 6 Mar 2024 13:51:52 +0100 Subject: [PATCH] feat: `wf`, function to find & edit files --- home/.zshrc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/home/.zshrc b/home/.zshrc index cd3b7e1..55c9e0a 100644 --- a/home/.zshrc +++ b/home/.zshrc @@ -60,6 +60,13 @@ add-zsh-hook chpwd print_readme # example. Works with Tab completion. alias rr='git rev-parse --show-toplevel 2>/dev/null || pwd' +wf() { + # "`w`here `f`ile": which files contain the given regex? + local editor=${EDITOR:-vim} + # `--open-tty` for https://unix.stackexchange.com/a/732101 + rg --files-with-matches "$1" | fzf | xargs --no-run-if-empty --open-tty "$editor" +} + pullall() { gh auth status 1>/dev/null 2>&1 || gh auth login