fpf-cli 1.6.39 → 1.6.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/fpf +102 -14
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -102,5 +102,10 @@ Installed packages are marked with `*` in the result list.
|
|
|
102
102
|
- Set `FPF_LOADING_INDICATOR=0` to disable the pre-search loading indicator.
|
|
103
103
|
- `FPF_RELOAD_MIN_CHARS`: minimum query length before live reload (default `2`)
|
|
104
104
|
- `FPF_RELOAD_DEBOUNCE`: reload debounce seconds (default `0.12`)
|
|
105
|
+
- `FPF_DYNAMIC_RELOAD_BYPASS_QUERY_CACHE=1`: force uncached reload queries (legacy behavior); default `0` uses query cache during reloads
|
|
106
|
+
- `FPF_ENABLE_QUERY_CACHE`: `auto` (default), `1`, or `0` (`auto` enables query cache for `apt`, `brew`, `pacman`, and `bun`)
|
|
107
|
+
- `FPF_QUERY_CACHE_TTL`: default query-cache TTL seconds for heavy manager caches (default `300`)
|
|
108
|
+
- `FPF_APT_QUERY_CACHE_TTL`, `FPF_BREW_QUERY_CACHE_TTL`, `FPF_PACMAN_QUERY_CACHE_TTL`: per-manager query-cache TTL overrides
|
|
109
|
+
- `FPF_BUN_QUERY_CACHE_TTL`: Bun query-cache TTL (default `900`)
|
|
105
110
|
- `FPF_DISABLE_INSTALLED_CACHE=1` disables installed-package marker cache
|
|
106
111
|
- `FPF_INSTALLED_CACHE_TTL`: installed-package marker cache freshness window in seconds (default `300`, set `0` to always refresh)
|
package/fpf
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
set -euo pipefail
|
|
4
4
|
|
|
5
5
|
SCRIPT_NAME="fpf"
|
|
6
|
-
SCRIPT_VERSION="1.6.
|
|
6
|
+
SCRIPT_VERSION="1.6.41"
|
|
7
7
|
TMP_ROOT="${TMPDIR:-/tmp}/fpf"
|
|
8
8
|
SESSION_TMP_ROOT=""
|
|
9
9
|
HELP_FILE=""
|
|
@@ -25,6 +25,77 @@ query_cache_flags() {
|
|
|
25
25
|
printf "%s" "query_limit=${FPF_QUERY_RESULT_LIMIT:-0};per_manager_limit=${FPF_QUERY_PER_MANAGER_LIMIT:-40};no_query_limit=${FPF_NO_QUERY_RESULT_LIMIT:-120};no_query_npm_limit=${FPF_NO_QUERY_NPM_LIMIT:-120}"
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
query_cache_default_enabled_for_manager() {
|
|
29
|
+
local manager="$1"
|
|
30
|
+
|
|
31
|
+
case "${manager}" in
|
|
32
|
+
apt|brew|pacman|bun)
|
|
33
|
+
return 0
|
|
34
|
+
;;
|
|
35
|
+
*)
|
|
36
|
+
return 1
|
|
37
|
+
;;
|
|
38
|
+
esac
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
query_cache_ttl_seconds_for_manager() {
|
|
42
|
+
local manager="$1"
|
|
43
|
+
local default_ttl="${FPF_QUERY_CACHE_TTL:-300}"
|
|
44
|
+
local manager_ttl="0"
|
|
45
|
+
|
|
46
|
+
if ! [[ "${default_ttl}" =~ ^[0-9]+$ ]]; then
|
|
47
|
+
default_ttl=300
|
|
48
|
+
fi
|
|
49
|
+
|
|
50
|
+
case "${manager}" in
|
|
51
|
+
bun)
|
|
52
|
+
manager_ttl="${FPF_BUN_QUERY_CACHE_TTL:-900}"
|
|
53
|
+
if ! [[ "${manager_ttl}" =~ ^[0-9]+$ ]]; then
|
|
54
|
+
manager_ttl=900
|
|
55
|
+
fi
|
|
56
|
+
;;
|
|
57
|
+
apt)
|
|
58
|
+
manager_ttl="${FPF_APT_QUERY_CACHE_TTL:-${default_ttl}}"
|
|
59
|
+
if ! [[ "${manager_ttl}" =~ ^[0-9]+$ ]]; then
|
|
60
|
+
manager_ttl="${default_ttl}"
|
|
61
|
+
fi
|
|
62
|
+
;;
|
|
63
|
+
brew)
|
|
64
|
+
manager_ttl="${FPF_BREW_QUERY_CACHE_TTL:-${default_ttl}}"
|
|
65
|
+
if ! [[ "${manager_ttl}" =~ ^[0-9]+$ ]]; then
|
|
66
|
+
manager_ttl="${default_ttl}"
|
|
67
|
+
fi
|
|
68
|
+
;;
|
|
69
|
+
pacman)
|
|
70
|
+
manager_ttl="${FPF_PACMAN_QUERY_CACHE_TTL:-${default_ttl}}"
|
|
71
|
+
if ! [[ "${manager_ttl}" =~ ^[0-9]+$ ]]; then
|
|
72
|
+
manager_ttl="${default_ttl}"
|
|
73
|
+
fi
|
|
74
|
+
;;
|
|
75
|
+
*)
|
|
76
|
+
manager_ttl=0
|
|
77
|
+
;;
|
|
78
|
+
esac
|
|
79
|
+
|
|
80
|
+
printf "%s" "${manager_ttl}"
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
dynamic_reload_query_cache_bypass_value() {
|
|
84
|
+
local bypass_setting="${FPF_DYNAMIC_RELOAD_BYPASS_QUERY_CACHE:-0}"
|
|
85
|
+
|
|
86
|
+
bypass_setting="$(trim_whitespace "${bypass_setting}")"
|
|
87
|
+
bypass_setting="$(printf "%s" "${bypass_setting}" | tr '[:upper:]' '[:lower:]')"
|
|
88
|
+
|
|
89
|
+
case "${bypass_setting}" in
|
|
90
|
+
1|true|yes|on)
|
|
91
|
+
printf "1"
|
|
92
|
+
;;
|
|
93
|
+
*)
|
|
94
|
+
printf "0"
|
|
95
|
+
;;
|
|
96
|
+
esac
|
|
97
|
+
}
|
|
98
|
+
|
|
28
99
|
log() {
|
|
29
100
|
printf "%s\n" "$*" >&2
|
|
30
101
|
}
|
|
@@ -2493,8 +2564,10 @@ manager_search_entries_uncached() {
|
|
|
2493
2564
|
manager_search_entries() {
|
|
2494
2565
|
local manager="$1"
|
|
2495
2566
|
local query="$2"
|
|
2496
|
-
local query_cache_enabled="
|
|
2497
|
-
local
|
|
2567
|
+
local query_cache_enabled="0"
|
|
2568
|
+
local query_cache_setting="${FPF_ENABLE_QUERY_CACHE:-auto}"
|
|
2569
|
+
local query_cache_ttl="0"
|
|
2570
|
+
local bun_cache_ttl="900"
|
|
2498
2571
|
local bypass_query_cache="${FPF_BYPASS_QUERY_CACHE:-0}"
|
|
2499
2572
|
local flags
|
|
2500
2573
|
local key
|
|
@@ -2507,19 +2580,28 @@ manager_search_entries() {
|
|
|
2507
2580
|
initialize_cache_root
|
|
2508
2581
|
|
|
2509
2582
|
flags="$(query_cache_flags)"
|
|
2583
|
+
query_cache_setting="$(trim_whitespace "${query_cache_setting}")"
|
|
2584
|
+
query_cache_setting="$(printf "%s" "${query_cache_setting}" | tr '[:upper:]' '[:lower:]')"
|
|
2585
|
+
query_cache_ttl="$(query_cache_ttl_seconds_for_manager "${manager}")"
|
|
2510
2586
|
|
|
2511
|
-
if
|
|
2512
|
-
bun_cache_ttl=
|
|
2587
|
+
if [[ "${manager}" == "bun" ]]; then
|
|
2588
|
+
bun_cache_ttl="${query_cache_ttl}"
|
|
2513
2589
|
fi
|
|
2514
2590
|
|
|
2515
2591
|
case "${bypass_query_cache}" in
|
|
2516
2592
|
1|true|yes|on)
|
|
2517
|
-
query_cache_enabled="0"
|
|
2518
2593
|
;;
|
|
2519
2594
|
*)
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2595
|
+
case "${query_cache_setting}" in
|
|
2596
|
+
1|true|yes|on)
|
|
2597
|
+
query_cache_enabled="1"
|
|
2598
|
+
;;
|
|
2599
|
+
auto|"")
|
|
2600
|
+
if query_cache_default_enabled_for_manager "${manager}"; then
|
|
2601
|
+
query_cache_enabled="1"
|
|
2602
|
+
fi
|
|
2603
|
+
;;
|
|
2604
|
+
esac
|
|
2523
2605
|
;;
|
|
2524
2606
|
esac
|
|
2525
2607
|
|
|
@@ -2558,7 +2640,7 @@ manager_search_entries() {
|
|
|
2558
2640
|
fi
|
|
2559
2641
|
|
|
2560
2642
|
if [[ "${query_cache_enabled}" == "1" && -s "${cache_file}" ]]; then
|
|
2561
|
-
if [[ "${
|
|
2643
|
+
if [[ "${query_cache_ttl}" -eq 0 ]] || cache_is_fresh_with_ttl "${key}" "${query_cache_ttl}"; then
|
|
2562
2644
|
cat "${cache_file}"
|
|
2563
2645
|
return
|
|
2564
2646
|
fi
|
|
@@ -3125,6 +3207,7 @@ build_dynamic_reload_command() {
|
|
|
3125
3207
|
local script_path="${BASH_SOURCE[0]}"
|
|
3126
3208
|
local min_chars="${FPF_RELOAD_MIN_CHARS:-2}"
|
|
3127
3209
|
local reload_debounce="${FPF_RELOAD_DEBOUNCE:-0.12}"
|
|
3210
|
+
local bypass_query_cache="1"
|
|
3128
3211
|
|
|
3129
3212
|
if ! [[ "${min_chars}" =~ ^[0-9]+$ ]]; then
|
|
3130
3213
|
min_chars=2
|
|
@@ -3134,14 +3217,16 @@ build_dynamic_reload_command() {
|
|
|
3134
3217
|
reload_debounce=0.12
|
|
3135
3218
|
fi
|
|
3136
3219
|
|
|
3220
|
+
bypass_query_cache="$(dynamic_reload_query_cache_bypass_value)"
|
|
3221
|
+
|
|
3137
3222
|
if [[ "${script_path}" != /* ]]; then
|
|
3138
3223
|
script_path="$(pwd)/${script_path}"
|
|
3139
3224
|
fi
|
|
3140
3225
|
|
|
3141
3226
|
if [[ -n "${manager_override}" ]]; then
|
|
3142
|
-
printf 'q={q}; if [ ${#q} -lt %s ]; then cat %q; else sleep %s; FPF_SKIP_INSTALLED_MARKERS=1 FPF_BYPASS_QUERY_CACHE
|
|
3227
|
+
printf 'q={q}; if [ ${#q} -lt %s ]; then cat %q; else sleep %s; FPF_SKIP_INSTALLED_MARKERS=1 FPF_BYPASS_QUERY_CACHE=%s FPF_IPC_MANAGER_OVERRIDE=%q FPF_IPC_FALLBACK_FILE=%q %q --feed-search --manager %q -- "$q" 2>/dev/null || cat %q; fi' "${min_chars}" "${fallback_file}" "${reload_debounce}" "${bypass_query_cache}" "${manager_override}" "${fallback_file}" "${script_path}" "${manager_override}" "${fallback_file}"
|
|
3143
3228
|
else
|
|
3144
|
-
printf 'q={q}; if [ ${#q} -lt %s ]; then cat %q; else sleep %s; FPF_SKIP_INSTALLED_MARKERS=1 FPF_BYPASS_QUERY_CACHE
|
|
3229
|
+
printf 'q={q}; if [ ${#q} -lt %s ]; then cat %q; else sleep %s; FPF_SKIP_INSTALLED_MARKERS=1 FPF_BYPASS_QUERY_CACHE=%s FPF_IPC_MANAGER_OVERRIDE= FPF_IPC_FALLBACK_FILE=%q %q --feed-search -- "$q" 2>/dev/null || cat %q; fi' "${min_chars}" "${fallback_file}" "${reload_debounce}" "${bypass_query_cache}" "${fallback_file}" "${script_path}" "${fallback_file}"
|
|
3145
3230
|
fi
|
|
3146
3231
|
}
|
|
3147
3232
|
|
|
@@ -3152,6 +3237,7 @@ build_dynamic_reload_command_for_query() {
|
|
|
3152
3237
|
local script_path="${BASH_SOURCE[0]}"
|
|
3153
3238
|
local min_chars="${FPF_RELOAD_MIN_CHARS:-2}"
|
|
3154
3239
|
local reload_debounce="${FPF_RELOAD_DEBOUNCE:-0.12}"
|
|
3240
|
+
local bypass_query_cache="1"
|
|
3155
3241
|
|
|
3156
3242
|
if ! [[ "${min_chars}" =~ ^[0-9]+$ ]]; then
|
|
3157
3243
|
min_chars=2
|
|
@@ -3161,6 +3247,8 @@ build_dynamic_reload_command_for_query() {
|
|
|
3161
3247
|
reload_debounce=0.12
|
|
3162
3248
|
fi
|
|
3163
3249
|
|
|
3250
|
+
bypass_query_cache="$(dynamic_reload_query_cache_bypass_value)"
|
|
3251
|
+
|
|
3164
3252
|
if [[ "${script_path}" != /* ]]; then
|
|
3165
3253
|
script_path="$(pwd)/${script_path}"
|
|
3166
3254
|
fi
|
|
@@ -3171,9 +3259,9 @@ build_dynamic_reload_command_for_query() {
|
|
|
3171
3259
|
fi
|
|
3172
3260
|
|
|
3173
3261
|
if [[ -n "${manager_override}" ]]; then
|
|
3174
|
-
printf 'sleep %s; FPF_SKIP_INSTALLED_MARKERS=1 FPF_BYPASS_QUERY_CACHE
|
|
3262
|
+
printf 'sleep %s; FPF_SKIP_INSTALLED_MARKERS=1 FPF_BYPASS_QUERY_CACHE=%s FPF_IPC_MANAGER_OVERRIDE=%q FPF_IPC_FALLBACK_FILE=%q %q --feed-search --manager %q -- %q 2>/dev/null || cat %q' "${reload_debounce}" "${bypass_query_cache}" "${manager_override}" "${fallback_file}" "${script_path}" "${manager_override}" "${query_value}" "${fallback_file}"
|
|
3175
3263
|
else
|
|
3176
|
-
printf 'sleep %s; FPF_SKIP_INSTALLED_MARKERS=1 FPF_BYPASS_QUERY_CACHE
|
|
3264
|
+
printf 'sleep %s; FPF_SKIP_INSTALLED_MARKERS=1 FPF_BYPASS_QUERY_CACHE=%s FPF_IPC_MANAGER_OVERRIDE= FPF_IPC_FALLBACK_FILE=%q %q --feed-search -- %q 2>/dev/null || cat %q' "${reload_debounce}" "${bypass_query_cache}" "${fallback_file}" "${script_path}" "${query_value}" "${fallback_file}"
|
|
3177
3265
|
fi
|
|
3178
3266
|
}
|
|
3179
3267
|
|