(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.
This commit is contained in:
Eduard Tolosa 2025-07-26 22:23:57 -05:00
parent 0206728145
commit 2afe4b3aba
3 changed files with 11 additions and 0 deletions

View file

@ -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"

View file

@ -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)

View file

@ -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