♻️ refactor(bin): repos script ported to bash language
This commit is contained in:
parent
168e84314b
commit
d1c8a7d702
2 changed files with 28 additions and 29 deletions
|
@ -1,29 +0,0 @@
|
|||
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 selected_dir (find ~/Repos -mindepth 1 -maxdepth 1 -type d -exec test -e '{}/.git' ';' -print -prune | fzf --preview "$gfetch {} && eza --long --header --icons --all --color=always --group-directories-first --hyperlink {}")
|
||||
|
||||
if test -n "$selected_dir"
|
||||
set tab_title (basename "$selected_dir")
|
||||
set new_tab_cmd = ""
|
||||
|
||||
if type -q tmux
|
||||
if set -q TMUX
|
||||
set new_tab_cmd "tmux new-session -ds \"$tab_title\" -c \"$selected_dir\"; and tmux switch-client -t \"$tab_title\""
|
||||
else
|
||||
set new_tab_cmd "tmux new-session -s \"$tab_title\" -c \"$selected_dir\""
|
||||
end
|
||||
else if type -q zellij
|
||||
if zellij ls | grep --quiet current
|
||||
set new_tab_cmd "zellij action rename-tab \"$tab_title\"; and cd $selected_dir; and $gfetch; and l"
|
||||
end
|
||||
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
|
28
.local/bin/repos
Executable file
28
.local/bin/repos
Executable file
|
@ -0,0 +1,28 @@
|
|||
#!/bin/bash
|
||||
|
||||
gfetch="gfetch -d churn contributors --no-color-palette --no-title"
|
||||
eza="eza --long --header --icons --all --color=always --group-directories-first --hyperlink"
|
||||
selected_dir=$(find ~/repos -mindepth 1 -maxdepth 1 -type d | fzf --preview "$gfetch {} && $eza {}")
|
||||
|
||||
if [[ -n "$selected_dir" ]]; then
|
||||
tab_title=$(basename "$selected_dir")
|
||||
new_tab_cmd=""
|
||||
|
||||
if command -v tmux &>/dev/null; then
|
||||
if command -v tmuxp &>/dev/null && [[ -f "$selected_dir/.tmuxp.yaml" ]]; then
|
||||
new_tab_cmd="tmuxp load \"$selected_dir\""
|
||||
elif [[ -n "$TMUX" ]]; then
|
||||
new_tab_cmd="tmux new-session -ds \"$tab_title\" -c \"$selected_dir\"; tmux switch-client -t \"$tab_title\""
|
||||
else
|
||||
new_tab_cmd="tmux new-session -s \"$tab_title\" -c \"$selected_dir\""
|
||||
fi
|
||||
elif command -v kitty &>/dev/null; then
|
||||
new_tab_cmd="kitty @ set-tab-title \"$tab_title\"; cd \"$selected_dir\"; $gfetch; l"
|
||||
else
|
||||
new_tab_cmd="cd \"$selected_dir\"; $gfetch; l"
|
||||
fi
|
||||
|
||||
eval "$new_tab_cmd"
|
||||
|
||||
tput reset
|
||||
fi
|
Loading…
Add table
Reference in a new issue