From 2afe4b3aba96cab12842b7eaa319709e08e0398b Mon Sep 17 00:00:00 2001 From: Eduard Tolosa Date: Sat, 26 Jul 2025 22:23:57 -0500 Subject: [PATCH] (feat): add BASED_EXCLUDED_PATHS to exclude directories from history There are cases where you want to exclude some paths from being indexed. E.g: `..`, `/tmp/*`, and others. --- completions/based.fish | 1 + functions/__based_log.fish | 9 +++++++++ functions/__based_reset_state.fish | 1 + 3 files changed, 11 insertions(+) diff --git a/completions/based.fish b/completions/based.fish index 5ac30c6..0a999d6 100644 --- a/completions/based.fish +++ b/completions/based.fish @@ -3,4 +3,5 @@ complete -c based -n __fish_use_subcommand -f -a init -d "Initialize the Based d complete -c based -n __fish_use_subcommand -f -a import -d "Import Fish history into Based" complete -c based -n __fish_use_subcommand -f -a stats -d "Show Based statistics" complete -c based -n __fish_use_subcommand -f -a reset -d "Reset Based state" +complete -c based -n __fish_use_subcommand -f -a maintenance -d "Perform database maintenance" complete -c based -n __fish_use_subcommand -f -a help -d "Show help message" diff --git a/functions/__based_log.fish b/functions/__based_log.fish index 074bd5f..bc1550e 100644 --- a/functions/__based_log.fish +++ b/functions/__based_log.fish @@ -13,6 +13,15 @@ function __based_log --on-event fish_preexec return end + # Check if path should be excluded + if set -q BASED_EXCLUDED_PATHS + for excluded_pattern in $BASED_EXCLUDED_PATHS + if string match -q $excluded_pattern $path + return + end + end + end + set cmd (string replace -a "'" "''" -- $cmd) set path (string replace -a "'" "''" -- $path) diff --git a/functions/__based_reset_state.fish b/functions/__based_reset_state.fish index 65ff5d5..b9c0981 100644 --- a/functions/__based_reset_state.fish +++ b/functions/__based_reset_state.fish @@ -3,5 +3,6 @@ function __based_reset_state # Unset all variables related to Based state set -e BASED_NO_CONFIRMATION set -e BASED_NO_FUZZY + set -e BASED_EXCLUDED_PATHS echo "Based state has been reset." end