From 92282c479550994105c10c5b64034d22a5af23a0 Mon Sep 17 00:00:00 2001 From: John D Pell Date: Fri, 24 Sep 2021 00:39:07 -0700 Subject: [PATCH] plugin/percol: `shellcheck` & `shfmt` According to `shellcheck`, the `_tac` alias simply doesn't work. At all. Ever. See SC2262 and SC2263. --- clean_files.txt | 1 + plugins/available/percol.plugin.bash | 21 ++++++++------------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/clean_files.txt b/clean_files.txt index 2242ef5e..cf8d082a 100644 --- a/clean_files.txt +++ b/clean_files.txt @@ -92,6 +92,7 @@ plugins/available/hub.plugin.bash plugins/available/jump.plugin.bash plugins/available/node.plugin.bash plugins/available/nodenv.plugin.bash +plugins/available/percol.plugin.bash plugins/available/plenv.plugin.bash plugins/available/pyenv.plugin.bash plugins/available/rbenv.plugin.bash diff --git a/plugins/available/percol.plugin.bash b/plugins/available/percol.plugin.bash index cc83683e..97986ccf 100644 --- a/plugins/available/percol.plugin.bash +++ b/plugins/available/percol.plugin.bash @@ -16,23 +16,18 @@ about-plugin 'Search&Select history with percol' _command_exists percol || return if [[ ${BASH_VERSINFO[0]} -lt 4 ]]; then - _log_warning "You have to upgrade Bash to Bash v4.x to use the 'percol' plugin." - _log_warning "Your current Bash version is $BASH_VERSION." - return + _log_warning "You have to upgrade Bash to Bash v4.x to use the 'percol' plugin." + _log_warning "Your current Bash version is $BASH_VERSION." + return else - bind -x '"\C-r": _replace_by_history' + bind -x '"\C-r": _replace_by_history' fi function _replace_by_history() { local HISTTIMEFORMAT= # Ensure we can parse history properly - if _command_exists tac - then - alias _tac=tac - else - alias _tac="tail -r" - fi #TODO: "${histlines[@]/*( )+([[:digit:]])*( )/}" - local l="$(history | _tac | sed -e 's/^\ *[0-9]*\ *//' | percol --query "${READLINE_LINE:-}")" - READLINE_LINE="${l}" - READLINE_POINT=${#l} + local l + l="$(history | tail -r | sed -e 's/^\ *[0-9]*\ *//' | percol --query "${READLINE_LINE:-}")" + READLINE_LINE="${l}" + READLINE_POINT=${#l} }