From 648bed832f6749aaeb6879e33014511951c00744 Mon Sep 17 00:00:00 2001 From: Randall Winkhart Date: Wed, 8 Mar 2023 23:00:53 -0500 Subject: [PATCH] Made Bash completions significantly faster, temporarily ensure recursive globbing is enabled Former-commit-id: c974ce1e0cb0198094d6ece325ab3216f1925f36 Former-commit-id: 762562fbbdb298f4b13210d0014a942b430c1197 --- extra/sshyp-completion.bash | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/extra/sshyp-completion.bash b/extra/sshyp-completion.bash index f33c9cc..638498a 100755 --- a/extra/sshyp-completion.bash +++ b/extra/sshyp-completion.bash @@ -2,11 +2,12 @@ _path_gen() { local sshyp_path="$HOME/.local/share/sshyp" - local sshyp_path_length="$(("${#sshyp_path}" + 1))" - full_paths=(~/.local/share/sshyp/**/*.gpg) + local glob_status=$(shopt -p globstar) + [ -z "${glob_status##*u*}" ] && shopt -s globstar # if recursive globbing is disabled, enable it + full_paths=("$sshyp_path"/**/*.gpg) + $glob_status # set recursive globbing to user default for path in "${full_paths[@]}"; do - trimmed_path=$(echo ${path%????} | cut -c"$sshyp_path_length"-) - trimmed_paths+=("$trimmed_path") + trimmed_paths+=("${path:${#sshyp_path}:-4}") done } &&