feat(bin): increment the zoxide score in the dev script

This commit is contained in:
Sergio Laín 2024-10-03 14:55:30 +02:00
parent 02023736e7
commit 6805877c40
No known key found for this signature in database
GPG key ID: 8429B2EE312F8150

View file

@ -2,7 +2,7 @@
# Constants # Constants
gfetch="gfetch -d churn contributors --no-color-palette --no-title" gfetch="gfetch -d churn contributors --no-color-palette --no-title"
eza="eza --header --icons --all --color=always --group-directories-first --hyperlink" ls="eza --header --icons --all --color=always --group-directories-first --hyperlink"
projects_dir="$HOME/dev" projects_dir="$HOME/dev"
projects_command="find $projects_dir -mindepth 2 -maxdepth 2 -type d" projects_command="find $projects_dir -mindepth 2 -maxdepth 2 -type d"
fzf_command="fzf --height=100%" fzf_command="fzf --height=100%"
@ -19,9 +19,10 @@ yaml_config() {
tmuxp_load() { tmuxp_load() {
if [[ -n "$TMUX" ]]; then if [[ -n "$TMUX" ]]; then
tmuxp load -d "$selected_dir" tmuxp load -d "$selected_dir"
zoxide_score
else else
tmuxp load "$selected_dir" tmuxp load "$selected_dir"
zoxide_score
fi fi
tmux switch-client -t "$tab_title" tmux switch-client -t "$tab_title"
} }
@ -38,6 +39,8 @@ handle_tmuxp() {
if [[ -n "$yaml_file" ]]; then if [[ -n "$yaml_file" ]]; then
yaml_config "$XDG_CONFIG_HOME/tmuxp/$yaml_file.yaml" "$selected_dir" yaml_config "$XDG_CONFIG_HOME/tmuxp/$yaml_file.yaml" "$selected_dir"
tmuxp_load tmuxp_load
else
handle_tmux
fi fi
fi fi
fi fi
@ -50,13 +53,15 @@ handle_tmux() {
else else
tmux new-session -s "$tab_title" -c "$selected_dir" tmux new-session -s "$tab_title" -c "$selected_dir"
fi fi
zoxide_score
} }
handle_kitty() { handle_kitty() {
kitty @ set-tab-title "$tab_title" kitty @ set-tab-title "$tab_title"
cd "$selected_dir" cd "$selected_dir"
zoxide_score
$gfetch $gfetch
$eza $ls
} }
handle_editor() { handle_editor() {
@ -67,11 +72,15 @@ handle_editor() {
fi fi
} }
zoxide_score() {
zoxide add "$selected_dir"
}
selected_dir=$($projects_command | $fzf_command --prompt='Select a directory: ' \ selected_dir=$($projects_command | $fzf_command --prompt='Select a directory: ' \
--header='CTRL-P: Projects / CTRL-Z: Zoxide' \ --header='CTRL-P: Projects / CTRL-Z: Zoxide' \
--bind "ctrl-p:reload($projects_command)" \ --bind "ctrl-p:reload($projects_command)" \
--bind "ctrl-z:reload(zoxide query -l)" \ --bind "ctrl-z:reload(zoxide query -l)" \
--preview "$gfetch {} 2>&1 | grep -v 'Error: Could not find a git repository in' || true && $eza {} || $eza {}") --preview "$gfetch {} 2>&1 | grep -v 'Error: Could not find a git repository in' || true && $ls {} || $ls {}")
tab_title=$(basename "$selected_dir") tab_title=$(basename "$selected_dir")
@ -89,5 +98,6 @@ if [[ -n "$selected_dir" ]]; then
fi fi
else else
$EDITOR -r "$selected_dir" $EDITOR -r "$selected_dir"
zoxide_score
fi fi
fi fi