summaryrefslogtreecommitdiffstats
path: root/tv/5pkgs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2019-02-05 11:53:31 +0100
committertv <tv@krebsco.de>2019-02-05 11:53:31 +0100
commit56d8366cfd011a0079ad731438f48280edfcbdca (patch)
treed07b78bdff8dc508ef94a42ed1232796c91ebbd8 /tv/5pkgs
parentb7ced221a53c2fc95f630348cf5c7befd0c4a904 (diff)
tv bash-fzf-history: use array instead of extglob
Diffstat (limited to 'tv/5pkgs')
-rw-r--r--tv/5pkgs/simple/bash-fzf-history.nix22
1 files changed, 13 insertions, 9 deletions
diff --git a/tv/5pkgs/simple/bash-fzf-history.nix b/tv/5pkgs/simple/bash-fzf-history.nix
index e9a21b95d..8b3fe9e58 100644
--- a/tv/5pkgs/simple/bash-fzf-history.nix
+++ b/tv/5pkgs/simple/bash-fzf-history.nix
@@ -33,7 +33,8 @@ with import <stockholm/lib>;
]}'
__fzf_history__() (
- result=$(
+ IFS=$'\n'
+ result=( $(
HISTTIMEFORMAT= history |
FZF_DEFAULT_OPTS="${toString [
/* sh */ "--tac"
@@ -45,15 +46,18 @@ with import <stockholm/lib>;
/* sh */ "$FZF_DEFAULT_OPTS"
/* 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
- shopt -s extglob
-
- key=''${result%%$'\n'*}
- line=''${result##*([^0-9])}
- index=''${line%%[^0-9]*}
- command=''${line##*([0-9 ])}
+ key=''${result[0]}
+ index=''${result[1]}
+ command=''${result[2]}
echo "$command${mark-prefix}$key"
else