From 24fb458ba8b6574d22b5c3bd5796321d9aca3eee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20La=C3=ADn?= Date: Sun, 17 Sep 2023 12:13:02 +0200 Subject: [PATCH] Use sd and ripgrep for some fish functions. Changed fish functions to repaint the command line as well --- .config/fish/functions/cdzi.fish | 2 ++ .config/fish/functions/fgit.fish | 6 ++---- .config/fish/functions/repos.fish | 9 ++------- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/.config/fish/functions/cdzi.fish b/.config/fish/functions/cdzi.fish index ff3f5b68..47a09aab 100644 --- a/.config/fish/functions/cdzi.fish +++ b/.config/fish/functions/cdzi.fish @@ -3,5 +3,7 @@ function cdzi --description 'Open directories from zoxide in a new Kitty tab' if test -n "$selected_dir" cd $selected_dir + else + commandline -f repaint end end diff --git a/.config/fish/functions/fgit.fish b/.config/fish/functions/fgit.fish index d15ab449..a6419484 100644 --- a/.config/fish/functions/fgit.fish +++ b/.config/fish/functions/fgit.fish @@ -1,9 +1,7 @@ function fgit --description 'List forgit options with fzf' - set selected_command (functions | grep -o 'forgit::[^ ]*' | cut -d ':' -f 2- | sed 's/^://' | fzf) + set selected_command (functions | rg -o 'forgit::[^ ]*' | cut -d ':' -f 2- | sd '^:' '' | fzf) if [ -n "$selected_command" ] eval "forgit::$selected_command" - else - echo "Command selection canceled" - return end + commandline -f repaint end diff --git a/.config/fish/functions/repos.fish b/.config/fish/functions/repos.fish index f6e069fd..cb27da7f 100644 --- a/.config/fish/functions/repos.fish +++ b/.config/fish/functions/repos.fish @@ -2,18 +2,13 @@ function repos --description 'Open Git directories in ~/Repos with fzf in a new set selected_category (echo -e "Personal\nClass\nWork\nCommunity" | fzf --prompt "Select category: ") if test -n "$selected_category" - set selected_dir (fd --type d --base-directory ~/Repos/"$selected_category"/ -H '^\.git$' | sed 's/\/\.git\/$//' | fzf) + set selected_dir (fd --type d --base-directory ~/Repos/"$selected_category"/ -H '^\.git$' -d 3 | sd '\.git/' '' | fzf) if test -n "$selected_dir" set tab_title (basename "$selected_dir") set new_tab_cmd "kitty @ launch --type=tab --tab-title \"$tab_title\" ~/Repos/$selected_category/$selected_dir" eval $new_tab_cmd - else - echo "No directory selected" - return end - else - echo "No category selected" - return end + commandline -f repaint end