diff options
author | Toby Vincent <tobyv13@gmail.com> | 2022-08-22 15:48:53 -0500 |
---|---|---|
committer | Toby Vincent <tobyv13@gmail.com> | 2022-08-22 15:49:40 -0500 |
commit | 16d72d5369f269a7c0fe70fa5767b3803d62b4ea (patch) | |
tree | 86abcbe138a325c1be8e9300423e8c4b0a2be198 /zsh | |
parent | 4f23d5bb19eb20ad3420f9b2d3af3e3b9e64d95e (diff) |
feat(zsh): add shell fn for using rga + fzf
Diffstat (limited to 'zsh')
-rw-r--r-- | zsh/.config/zsh/.zshrc | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/zsh/.config/zsh/.zshrc b/zsh/.config/zsh/.zshrc index 32cc41b..36c6c64 100644 --- a/zsh/.config/zsh/.zshrc +++ b/zsh/.config/zsh/.zshrc @@ -67,5 +67,19 @@ command -v fd >/dev/null 2&>1 && _fzf_compgen_dir() { fd --type d --hidden --follow --exclude ".git" . "$1" } +command -v rga >/dev/null 2&>1 && rgi() { + RG_PREFIX="rga --files-with-matches" + local file + file="$( + FZF_DEFAULT_COMMAND="$RG_PREFIX '$1'" \ + fzf --sort --preview="[[ ! -z {} ]] && rga --pretty --context 5 {q} {}" \ + --phony -q "$1" \ + --bind "change:reload:$RG_PREFIX {q}" \ + --preview-window="70%:wrap" + )" && + echo "opening $file" && + xdg-open "$file" +} + command -v starship >/dev/null 2&>1 && source <(starship init zsh) command -v sheldon >/dev/null 2&>1 && source <(sheldon source) |