tv bash-fzf-history: use array instead of extglob

This commit is contained in:
tv 2019-02-05 11:53:31 +01:00 committed by lassulus
parent 72de16e0a4
commit 6cfbc67cb2

View File

@ -33,7 +33,8 @@ with import <stockholm/lib>;
]}' ]}'
__fzf_history__() ( __fzf_history__() (
result=$( IFS=$'\n'
result=( $(
HISTTIMEFORMAT= history | HISTTIMEFORMAT= history |
FZF_DEFAULT_OPTS="${toString [ FZF_DEFAULT_OPTS="${toString [
/* sh */ "--tac" /* sh */ "--tac"
@ -45,15 +46,18 @@ with import <stockholm/lib>;
/* sh */ "$FZF_DEFAULT_OPTS" /* sh */ "$FZF_DEFAULT_OPTS"
/* sh */ "+m" /* sh */ "+m"
]}" \ ]}" \
${pkgs.fzf}/bin/fzf ${pkgs.fzf}/bin/fzf |
) ${pkgs.gnused}/bin/sed '
/^ *[0-9]/{
s/^ *//
s/ \+/\n/;# index
}
'
) )
if test -n "$result"; then if test -n "$result"; then
shopt -s extglob key=''${result[0]}
index=''${result[1]}
key=''${result%%$'\n'*} command=''${result[2]}
line=''${result##*([^0-9])}
index=''${line%%[^0-9]*}
command=''${line##*([0-9 ])}
echo "$command${mark-prefix}$key" echo "$command${mark-prefix}$key"
else else