♻️ refactor(fish): repos script

- better performance by using find instead of fd
- detect if your inside kitty, zellij or none
This commit is contained in:
Sergio Laín 2024-04-09 21:16:59 +02:00
parent c8cf35239c
commit 6772cbd166
No known key found for this signature in database
GPG key ID: 14C9B8080681777B

View file

@ -1,13 +1,21 @@
function repos --description 'Open Git directories in ~/Repos with fzf in a new Kitty tab' function repos --description 'Open Git directories in ~/Repos with fzf in a new Kitty tab'
set gfetch "gfetch -d churn contributors --no-color-palette --no-title" set gfetch "gfetch -d churn contributors --no-color-palette --no-title"
# set selected_dir (find ~/Repos -mindepth 2 -maxdepth 2 -type d -exec test -e '{}/.git' ';' -print -prune | fzf --preview "$gfetch {} && eza --long --header --icons --all --color=always --group-directories-first --hyperlink {}") set selected_dir (find ~/Repos -mindepth 2 -maxdepth 2 -type d -exec test -e '{}/.git' ';' -print -prune | fzf --preview "$gfetch {} && eza --long --header --icons --all --color=always --group-directories-first --hyperlink {}")
set selected_dir (fd --exact-depth 2 . ~/Repos/ | fzf --preview "$gfetch {} && eza --long --header --icons --all --color=always --group-directories-first --hyperlink {}")
if test -n "$selected_dir" if test -n "$selected_dir"
set tab_title (basename "$selected_dir") set tab_title (basename "$selected_dir")
set new_tab_cmd "kitty @ set-tab-title \"$tab_title\"; and cd $selected_dir; and $gfetch; and l" set new_tab_cmd = ""
eval $new_tab_cmd
end
commandline -f repaint if zellij ls | grep --quiet current
set new_tab_cmd "zellij action rename-tab \"$tab_title\"; and cd $selected_dir; and $gfetch; and l"
else if type -q kitty
set new_tab_cmd "kitty @ set-tab-title \"$tab_title\"; and cd $selected_dir; and $gfetch; and l"
else
set new_tab_cmd "cd $selected_dir; and $gfetch; and l"
end
eval $new_tab_cmd
commandline -f repaint
end
end end