From 15f403982576f1cd6c2e2910ed06765bc1649da2 Mon Sep 17 00:00:00 2001 From: gazorby Date: Sun, 2 Jan 2022 11:32:37 +0100 Subject: [PATCH 01/15] wip --- functions/_enhancd_cd_after.fish | 6 ++---- functions/_enhancd_entry_git_root.fish | 8 ++++++++ functions/_enhancd_filter_exclude.fish | 7 +++++-- functions/_enhancd_filter_exists.fish | 8 +++++--- functions/_enhancd_filter_interactive.fish | 4 ++-- functions/_enhancd_filter_limit.fish | 9 ++++---- functions/_enhancd_filter_reverse.fish | 5 +++++ functions/_enhancd_filter_unique.fish | 9 +++++--- functions/_enhancd_history_open.fish | 24 +++++++++++++++++----- functions/_enhancd_source_default.fish | 13 ++++++++++++ 10 files changed, 69 insertions(+), 24 deletions(-) create mode 100644 functions/_enhancd_entry_git_root.fish create mode 100644 functions/_enhancd_source_default.fish diff --git a/functions/_enhancd_cd_after.fish b/functions/_enhancd_cd_after.fish index e0d4e7e..9861844 100644 --- a/functions/_enhancd_cd_after.fish +++ b/functions/_enhancd_cd_after.fish @@ -1,11 +1,9 @@ function _enhancd_cd_after - # Don't split on newlines throughout this function: - set -l IFS "" - set -l list (_enhancd_history_update) if test -n "$list" - echo "$list" >"$ENHANCD_DIR/enhancd.log" + # echo "$list" >"$ENHANCD_DIR/enhancd.log" + set -Ux ENHANCD_DIRECTORIES $list end if test -n "$ENHANCD_HOOK_AFTER_CD" diff --git a/functions/_enhancd_entry_git_root.fish b/functions/_enhancd_entry_git_root.fish new file mode 100644 index 0000000..4cdbcbc --- /dev/null +++ b/functions/_enhancd_entry_git_root.fish @@ -0,0 +1,8 @@ +function _enhancd_entry_git_root + if git rev-parse --is-inside-work-tree > /dev/null 2>&1 + and test (git rev-parse --show-toplevel) != (pwd) + git rev-parse --show-toplevel 2> /dev/null | _enhancd_filter_exclude "true" + else + return + end +end diff --git a/functions/_enhancd_filter_exclude.fish b/functions/_enhancd_filter_exclude.fish index 47c3389..b5f585d 100644 --- a/functions/_enhancd_filter_exclude.fish +++ b/functions/_enhancd_filter_exclude.fish @@ -1,4 +1,7 @@ function _enhancd_filter_exclude - _enhancd_command_grep -v -x "$argv[1]" - ; or true + # _enhancd_command_grep -v -x "$argv[1]" + # echo "$input" | _enhancd_command_grep -v -x "$argv[1]"; or true + read --list --local input + set -l items (string match -v "$argv[1]" $input) + echo $items end diff --git a/functions/_enhancd_filter_exists.fish b/functions/_enhancd_filter_exists.fish index d5ae77e..096fbcd 100644 --- a/functions/_enhancd_filter_exists.fish +++ b/functions/_enhancd_filter_exists.fish @@ -1,8 +1,10 @@ function _enhancd_filter_exists - set -l line - while read line + read --list --local lines + set -l items + for line in $lines if test -d "$line" - echo "$line" + set -a items "$line" end end + echo $items end diff --git a/functions/_enhancd_filter_interactive.fish b/functions/_enhancd_filter_interactive.fish index a4063f1..13f1426 100644 --- a/functions/_enhancd_filter_interactive.fish +++ b/functions/_enhancd_filter_interactive.fish @@ -1,5 +1,5 @@ function _enhancd_filter_interactive - set -l stdin "$argv[1]" + read --local --list stdin if test -z "$stdin"; or test -p /dev/stdin read -z stdin @@ -38,7 +38,7 @@ function _enhancd_filter_interactive end case '*' - set -l selected (echo "$stdin" | eval "$filter") + set -l selected (for item in $stdin; echo $item; end | eval "$filter") if test -z "$selected" return 1 end diff --git a/functions/_enhancd_filter_limit.fish b/functions/_enhancd_filter_limit.fish index 6b179d3..da7971a 100644 --- a/functions/_enhancd_filter_limit.fish +++ b/functions/_enhancd_filter_limit.fish @@ -1,9 +1,8 @@ function _enhancd_filter_limit - set -l limit - if not set -q $argv[1] - set limit 10 - else + read --local --list items + set -l limit 10 + if set -q argv[1] set limit $argv[1] end - command head -n "$limit" + echo $items[1..$limit] end diff --git a/functions/_enhancd_filter_reverse.fish b/functions/_enhancd_filter_reverse.fish index fcd976e..2c134dc 100644 --- a/functions/_enhancd_filter_reverse.fish +++ b/functions/_enhancd_filter_reverse.fish @@ -8,3 +8,8 @@ function _enhancd_filter_reverse | _enhancd_command_awk -f "$ENHANCD_ROOT/lib/reverse.awk" \ 2>/dev/null end + +function _enhancd_filter_reverse + read --list --local str + echo $str[-1..1] +end diff --git a/functions/_enhancd_filter_unique.fish b/functions/_enhancd_filter_unique.fish index 145f10d..39a9da1 100644 --- a/functions/_enhancd_filter_unique.fish +++ b/functions/_enhancd_filter_unique.fish @@ -1,8 +1,11 @@ # _enhancd_filter_unique uniques a stdin contents function _enhancd_filter_unique + set -l items if test -n "$argv[1]"; and test -f "$argv[1]" - command cat "$argv[1]" + set -a items "$argv[1]" else - command cat <&0 - end | _enhancd_command_awk '!a[$0]++' 2>/dev/null + read --list items + end + set items (echo -e (string join '\n' $items) | _enhancd_command_awk '!a[$0]++' 2>/dev/null) + echo $items end diff --git a/functions/_enhancd_history_open.fish b/functions/_enhancd_history_open.fish index 7d371e5..44424f0 100644 --- a/functions/_enhancd_history_open.fish +++ b/functions/_enhancd_history_open.fish @@ -1,7 +1,21 @@ function _enhancd_history_open - if test -f $ENHANCD_DIR/enhancd.log - command cat "$ENHANCD_DIR/enhancd.log" - return $status - end - return 1 + # if test -f $ENHANCD_DIR/enhancd.log + # command cat "$ENHANCD_DIR/enhancd.log" + # return $status + # end + echo $ENHANCD_DIRECTORIES + # for item in $ENHANCD_DIRECTORIES + # echo "$item" + # end + + return $status + # return 1 +end + +function set_mem_var + set -e ENHANCD_DIRECTORIES + set -Ux ENHANCD_DIRECTORIES + while read -l line + set -a ENHANCD_DIRECTORIES "$line" + end < ~/.enhancd/enhancd.log end diff --git a/functions/_enhancd_source_default.fish b/functions/_enhancd_source_default.fish new file mode 100644 index 0000000..ad6c402 --- /dev/null +++ b/functions/_enhancd_source_default.fish @@ -0,0 +1,13 @@ +function _enhancd_source_default + if test "$ENHANCD_DISABLE_HOME" = 1 + echo "$HOME" + return 0 + end + set -l items + set -a items (_enhancd_entry_git_root) + if test -z $items[1] + set -e items[1] + end + set -a items (_enhancd_history_list) + echo $items | _enhancd_filter_interactive +end From e681cac109836d457da01732bbb47c97b890baae Mon Sep 17 00:00:00 2001 From: gazorby Date: Sat, 2 Sep 2023 20:32:06 +0200 Subject: [PATCH 02/15] refactor: sync with upstream, misc optimizations --- conf.d/enhancd.fish | 15 ++++++++---- functions/_enhancd_cd_after.fish | 4 +++- functions/_enhancd_cd_ready.fish | 3 ++- functions/_enhancd_filepath_walk.fish | 3 ++- functions/_enhancd_filter_exclude.fish | 6 ++--- functions/_enhancd_filter_interactive.fish | 17 +++++++++---- functions/_enhancd_filter_reverse.fish | 10 -------- functions/_enhancd_filter_unique.fish | 9 ++----- functions/_enhancd_history_exists.fish | 2 +- functions/_enhancd_history_open.fish | 9 ------- functions/_enhancd_history_update.fish | 11 ++++----- functions/_enhancd_source_home.fish | 5 ++-- functions/enhancd.fish | 28 ++++++++++++---------- 13 files changed, 58 insertions(+), 64 deletions(-) diff --git a/conf.d/enhancd.fish b/conf.d/enhancd.fish index 2b90142..0d9fa56 100644 --- a/conf.d/enhancd.fish +++ b/conf.d/enhancd.fish @@ -32,10 +32,6 @@ function __enhancd_install --on-event enhancd_install mkdir -p "$ENHANCD_DIR" end - if not test -f "$ENHANCD_DIR/enhancd.log" - touch "$ENHANCD_DIR/enhancd.log" - end - _enhancd_alias end @@ -58,7 +54,9 @@ function __enhancd_uninstall --on-event enhancd_uninstall set --erase ENHANCD_COMPLETION_BEHAVIOR set --erase ENHANCD_COMPLETION_KEYBIND set --erase ENHANCD_FILTER + set --erase ENHANCD_CURRENT_FILTER set --erase _ENHANCD_VERSION + set --erase _ENHANCD_READY end # alias to enhancd @@ -68,3 +66,12 @@ end # bindings bind \ef '_enhancd_complete' + +set -Ux ENHANCD_CURRENT_FILTER (_enhancd_helper_parse_filter_string "$ENHANCD_FILTER") + +# Migrate from file based to universal var +if test -z $ENHANCD_DIRECTORIES; and test -f "$ENHANCD_DIR/enhancd.log" + while read -l line + set -a ENHANCD_DIRECTORIES "$line" + end < "$ENHANCD_DIR/enhancd.log" +end diff --git a/functions/_enhancd_cd_after.fish b/functions/_enhancd_cd_after.fish index 9861844..f6e5da2 100644 --- a/functions/_enhancd_cd_after.fish +++ b/functions/_enhancd_cd_after.fish @@ -1,8 +1,10 @@ function _enhancd_cd_after + # Don't split on newlines throughout this function: + set -l IFS "" + set -l list (_enhancd_history_update) if test -n "$list" - # echo "$list" >"$ENHANCD_DIR/enhancd.log" set -Ux ENHANCD_DIRECTORIES $list end diff --git a/functions/_enhancd_cd_ready.fish b/functions/_enhancd_cd_ready.fish index d3731d6..cb039a7 100644 --- a/functions/_enhancd_cd_ready.fish +++ b/functions/_enhancd_cd_ready.fish @@ -1,5 +1,6 @@ function _enhancd_cd_ready _enhancd_helper_parse_filter_string "$ENHANCD_FILTER" 2 >/dev/null - ; and test -s $ENHANCD_DIR/enhancd.log + ; and test -n $ENHNCD_DIRECTORIES + ; and set -Ux _ENHANCD_READY 1 return $status end diff --git a/functions/_enhancd_filepath_walk.fish b/functions/_enhancd_filepath_walk.fish index bb1116a..55ca4c0 100644 --- a/functions/_enhancd_filepath_walk.fish +++ b/functions/_enhancd_filepath_walk.fish @@ -1,5 +1,6 @@ function _enhancd_filepath_walk - set -a dirs $PWD (_enhancd_filepath_get_parent_dirs) + _enhancd_filepath_get_parent_dirs | read --list --local dirs + set --prepend dirs $PWD for dir in $dirs command find "$dir" -maxdepth 1 -type d -name '\.*' -prune -o -type d -print diff --git a/functions/_enhancd_filter_exclude.fish b/functions/_enhancd_filter_exclude.fish index b5f585d..cb5b2ba 100644 --- a/functions/_enhancd_filter_exclude.fish +++ b/functions/_enhancd_filter_exclude.fish @@ -1,7 +1,5 @@ function _enhancd_filter_exclude - # _enhancd_command_grep -v -x "$argv[1]" - # echo "$input" | _enhancd_command_grep -v -x "$argv[1]"; or true read --list --local input - set -l items (string match -v "$argv[1]" $input) - echo $items + string match -v "$argv[1]" -- $input + ; or true end diff --git a/functions/_enhancd_filter_interactive.fish b/functions/_enhancd_filter_interactive.fish index 13f1426..1041b0b 100644 --- a/functions/_enhancd_filter_interactive.fish +++ b/functions/_enhancd_filter_interactive.fish @@ -1,7 +1,15 @@ function _enhancd_filter_interactive read --local --list stdin - if test -z "$stdin"; or test -p /dev/stdin + # If input separated by the null character + # only the first line has been read in stdin + if test (count $stdin) -eq 1 + set -l tmp $stdin + read -z --list stdin + set --prepend stdin $tmp + end + + if test -z "$stdin"; or test -p /dev/stdin; read -z stdin end @@ -10,8 +18,7 @@ function _enhancd_filter_interactive return 1 end - set -l filter (_enhancd_helper_parse_filter_string "$ENHANCD_FILTER") - set -l count (echo "$stdin" | _enhancd_command_grep -c "") + set -l count (count $stdin) if test "$ENHANCD_USE_ABBREV" = true function _enhancd_filter_interactive_abbrev @@ -26,7 +33,7 @@ function _enhancd_filter_interactive end end - set filter "_enhancd_filter_interactive_abbrev | $filter | _enhancd_filter_interactive_expand" + set filter "_enhancd_filter_interactive_abbrev | $ENHANCD_CURRENT_FILTER | _enhancd_filter_interactive_expand" end switch "$count" @@ -38,7 +45,7 @@ function _enhancd_filter_interactive end case '*' - set -l selected (for item in $stdin; echo $item; end | eval "$filter") + set -l selected (string join \n -- $stdin | eval "$ENHANCD_CURRENT_FILTER") if test -z "$selected" return 1 end diff --git a/functions/_enhancd_filter_reverse.fish b/functions/_enhancd_filter_reverse.fish index 2c134dc..460ffa7 100644 --- a/functions/_enhancd_filter_reverse.fish +++ b/functions/_enhancd_filter_reverse.fish @@ -1,14 +1,4 @@ # _enhancd_filter_reverse reverses a stdin contents -function _enhancd_filter_reverse - if test -n "$argv[1]"; and test -f "$argv[1]" - command cat "$argv[1]" - else - command cat <&0 - end \ - | _enhancd_command_awk -f "$ENHANCD_ROOT/lib/reverse.awk" \ - 2>/dev/null -end - function _enhancd_filter_reverse read --list --local str echo $str[-1..1] diff --git a/functions/_enhancd_filter_unique.fish b/functions/_enhancd_filter_unique.fish index 39a9da1..ca8ff56 100644 --- a/functions/_enhancd_filter_unique.fish +++ b/functions/_enhancd_filter_unique.fish @@ -1,11 +1,6 @@ # _enhancd_filter_unique uniques a stdin contents function _enhancd_filter_unique set -l items - if test -n "$argv[1]"; and test -f "$argv[1]" - set -a items "$argv[1]" - else - read --list items - end - set items (echo -e (string join '\n' $items) | _enhancd_command_awk '!a[$0]++' 2>/dev/null) - echo $items + read --list --local items + echo (string join \n -- $items | _enhancd_command_awk '!a[$0]++' 2>/dev/null) end diff --git a/functions/_enhancd_history_exists.fish b/functions/_enhancd_history_exists.fish index b090237..b0a0806 100644 --- a/functions/_enhancd_history_exists.fish +++ b/functions/_enhancd_history_exists.fish @@ -5,5 +5,5 @@ function _enhancd_history_exists set dir $argv[1] end - _enhancd_history_open | _enhancd_command_grep "$dir" ^/dev/null >/dev/null + _enhancd_history_open | string match -r -q "$dir" ^/dev/null >/dev/null end diff --git a/functions/_enhancd_history_open.fish b/functions/_enhancd_history_open.fish index 44424f0..c8b57ae 100644 --- a/functions/_enhancd_history_open.fish +++ b/functions/_enhancd_history_open.fish @@ -1,15 +1,6 @@ function _enhancd_history_open - # if test -f $ENHANCD_DIR/enhancd.log - # command cat "$ENHANCD_DIR/enhancd.log" - # return $status - # end echo $ENHANCD_DIRECTORIES - # for item in $ENHANCD_DIRECTORIES - # echo "$item" - # end - return $status - # return 1 end function set_mem_var diff --git a/functions/_enhancd_history_update.fish b/functions/_enhancd_history_update.fish index f1cba4e..a1b5dbd 100644 --- a/functions/_enhancd_history_update.fish +++ b/functions/_enhancd_history_update.fish @@ -1,10 +1,9 @@ function _enhancd_history_update - function sub - _enhancd_history_exists; or _enhancd_filepath_walk - _enhancd_history_open - echo "$HOME" - end - sub \ + set -l list + set -a list (_enhancd_history_exists; or _enhancd_filepath_walk) + set -a list (_enhancd_history_open) + set -a list "$HOME" + echo $list \ | _enhancd_filter_reverse \ | _enhancd_filter_unique \ | _enhancd_filter_reverse diff --git a/functions/_enhancd_source_home.fish b/functions/_enhancd_source_home.fish index 30740de..a708d3e 100644 --- a/functions/_enhancd_source_home.fish +++ b/functions/_enhancd_source_home.fish @@ -5,7 +5,8 @@ function _enhancd_source_home end begin - echo "$HOME" - _enhancd_history_list + set -l list (_enhancd_history_list) + set -a list "$HOME" + echo $list end | _enhancd_filter_unique end diff --git a/functions/enhancd.fish b/functions/enhancd.fish index b7e30fd..c640a1b 100644 --- a/functions/enhancd.fish +++ b/functions/enhancd.fish @@ -4,7 +4,8 @@ function enhancd set -l opts set -l code 0 - if not _enhancd_cd_ready + if test -z $_ENHANCD_READY + _enhancd_cd_ready if not set -q argv[1] _enhancd_cd_builtin "$HOME" else @@ -15,12 +16,16 @@ function enhancd # set indice to the first element set -l i 1 + set -l count_argv (count $argv) - while [ $i -le (count $argv) ] + while [ $i -le $count_argv ] switch $argv[$i] - case "--help" - _enhancd_ltsv_open \ - | _enhancd_command_awk -f "$ENHANCD_ROOT/lib/help.awk" + case "$ENHANCD_ARG_DOUBLE_DOT" + set -a args (_enhancd_source_parent_dirs | _enhancd_filter_interactive) + set code $status + + case '..' + set -a args ".." case "$ENHANCD_ARG_HYPHEN" # If a hyphen is passed as the argument, @@ -31,13 +36,6 @@ function enhancd case '-' set -a args "$OLDPWD" - case "$ENHANCD_ARG_DOUBLE_DOT" - set -a args (_enhancd_source_parent_dirs | _enhancd_filter_interactive) - set code $status - - case '..' - set -a args ".." - case "$ENHANCD_ARG_SINGLE_DOT" set -a args (_enhancd_sources_current_dirs | _enhancd_filter_interactive) set code $status @@ -89,6 +87,10 @@ function enhancd end + case "--help" + _enhancd_ltsv_open \ + | _enhancd_command_awk -f "$ENHANCD_ROOT/lib/help.awk" + case '*' set -a args (_enhancd_source_history "$argv[1]" | _enhancd_filter_interactive) @@ -96,7 +98,7 @@ function enhancd set i (math "$i + 1") end - switch (count $argv) + switch $count_argv case '0' set -a args (_enhancd_source_home | _enhancd_filter_interactive) set code $status From 5d67161cbea3abcb36efc0c9f952cf849af09179 Mon Sep 17 00:00:00 2001 From: gazorby Date: Sun, 3 Sep 2023 04:35:38 +0200 Subject: [PATCH 03/15] refactor: remove old functions --- functions/_enhancd_entry_git_root.fish | 8 -------- functions/_enhancd_source_default.fish | 13 ------------- 2 files changed, 21 deletions(-) delete mode 100644 functions/_enhancd_entry_git_root.fish delete mode 100644 functions/_enhancd_source_default.fish diff --git a/functions/_enhancd_entry_git_root.fish b/functions/_enhancd_entry_git_root.fish deleted file mode 100644 index 4cdbcbc..0000000 --- a/functions/_enhancd_entry_git_root.fish +++ /dev/null @@ -1,8 +0,0 @@ -function _enhancd_entry_git_root - if git rev-parse --is-inside-work-tree > /dev/null 2>&1 - and test (git rev-parse --show-toplevel) != (pwd) - git rev-parse --show-toplevel 2> /dev/null | _enhancd_filter_exclude "true" - else - return - end -end diff --git a/functions/_enhancd_source_default.fish b/functions/_enhancd_source_default.fish deleted file mode 100644 index ad6c402..0000000 --- a/functions/_enhancd_source_default.fish +++ /dev/null @@ -1,13 +0,0 @@ -function _enhancd_source_default - if test "$ENHANCD_DISABLE_HOME" = 1 - echo "$HOME" - return 0 - end - set -l items - set -a items (_enhancd_entry_git_root) - if test -z $items[1] - set -e items[1] - end - set -a items (_enhancd_history_list) - echo $items | _enhancd_filter_interactive -end From c53dc5e228198340c3949eb4ed765ec141c5e316 Mon Sep 17 00:00:00 2001 From: gazorby Date: Sun, 3 Sep 2023 04:38:50 +0200 Subject: [PATCH 04/15] style: formatting --- functions/_enhancd_filter_interactive.fish | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/_enhancd_filter_interactive.fish b/functions/_enhancd_filter_interactive.fish index 1041b0b..37b5c3c 100644 --- a/functions/_enhancd_filter_interactive.fish +++ b/functions/_enhancd_filter_interactive.fish @@ -9,7 +9,7 @@ function _enhancd_filter_interactive set --prepend stdin $tmp end - if test -z "$stdin"; or test -p /dev/stdin; + if test -z "$stdin"; or test -p /dev/stdin read -z stdin end From 15bac666993854577979ddce912016a8f5fe2d4a Mon Sep 17 00:00:00 2001 From: gazorby Date: Sun, 3 Sep 2023 04:57:11 +0200 Subject: [PATCH 05/15] fix: help message --- functions/enhancd.fish | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/functions/enhancd.fish b/functions/enhancd.fish index c640a1b..2b13eff 100644 --- a/functions/enhancd.fish +++ b/functions/enhancd.fish @@ -33,7 +33,7 @@ function enhancd set -a args (_enhancd_source_mru | _enhancd_filter_interactive) set code $status - case '-' + case - set -a args "$OLDPWD" case "$ENHANCD_ARG_SINGLE_DOT" @@ -47,11 +47,15 @@ function enhancd set -a args (_enhancd_source_home | _enhancd_filter_interactive) set code $status - case '--' + case -- set -a opts "$argv[1]" set -a args (_enhancd_source_history "$argv[2]" | _enhancd_filter_interactive) set code $status + case --help + _enhancd_ltsv_open \ + | _enhancd_command_awk -f "$ENHANCD_ROOT/lib/help.awk" + case '-*' '--*' if _enhancd_helper_is_default_flag "$argv[1]" set -a opts "$argv[1]" @@ -87,9 +91,6 @@ function enhancd end - case "--help" - _enhancd_ltsv_open \ - | _enhancd_command_awk -f "$ENHANCD_ROOT/lib/help.awk" case '*' set -a args (_enhancd_source_history "$argv[1]" | _enhancd_filter_interactive) @@ -99,13 +100,13 @@ function enhancd end switch $count_argv - case '0' + case 0 set -a args (_enhancd_source_home | _enhancd_filter_interactive) set code $status end switch "$code" - case '0' + case 0 _enhancd_cd_builtin $opts $args return $status case '*' From ee00b8eb17a5fa5466401b93a7c42f73f981700e Mon Sep 17 00:00:00 2001 From: gazorby Date: Sun, 3 Sep 2023 05:09:57 +0200 Subject: [PATCH 06/15] fix: hyphen mode --- functions/_enhancd_filter_exclude.fish | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/_enhancd_filter_exclude.fish b/functions/_enhancd_filter_exclude.fish index cb5b2ba..999cc62 100644 --- a/functions/_enhancd_filter_exclude.fish +++ b/functions/_enhancd_filter_exclude.fish @@ -1,5 +1,5 @@ function _enhancd_filter_exclude read --list --local input - string match -v "$argv[1]" -- $input - ; or true + echo (string match -v "$argv[1]" -- $input) + or true end From c2e5b9a0956d69b902d2eddfec9ff3dab7b186e5 Mon Sep 17 00:00:00 2001 From: gazorby Date: Sun, 3 Sep 2023 05:24:15 +0200 Subject: [PATCH 07/15] fix(help): config.ltsv not displayed --- functions/_enhancd_ltsv_open.fish | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/_enhancd_ltsv_open.fish b/functions/_enhancd_ltsv_open.fish index 2d22c3f..c0ba043 100644 --- a/functions/_enhancd_ltsv_open.fish +++ b/functions/_enhancd_ltsv_open.fish @@ -4,8 +4,8 @@ function _enhancd_ltsv_open set -a configs "$ENHANCD_DIR/config.ltsv" set -a configs "$HOME/.config/enhancd/config.ltsv" - for config in "$configs" - if test -f "$config" + for config in $configs + if test -f $config command cat "$config" end end From 2b4216174a3a695e565374d1ade10ce63fcd72f0 Mon Sep 17 00:00:00 2001 From: gazorby Date: Sun, 3 Sep 2023 05:53:02 +0200 Subject: [PATCH 08/15] fix: fuzzy search --- functions/_enhancd_filter_fuzzy.fish | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/functions/_enhancd_filter_fuzzy.fish b/functions/_enhancd_filter_fuzzy.fish index d80d152..fb9a9eb 100644 --- a/functions/_enhancd_filter_fuzzy.fish +++ b/functions/_enhancd_filter_fuzzy.fish @@ -1,9 +1,13 @@ function _enhancd_filter_fuzzy + read --list --local stdin if test -z "$argv[1]" - command cat <&0 + echo $stdin else - _enhancd_command_awk \ + set -l dirs ( + string join \n -- $stdin | _enhancd_command_awk \ -f "$ENHANCD_ROOT/lib/fuzzy.awk" \ -v search_string="$argv[1]" + ) + echo $dirs end end From 862722d658b25f899106a2bd4831a9f239f6d298 Mon Sep 17 00:00:00 2001 From: gazorby Date: Sun, 3 Sep 2023 15:14:58 +0200 Subject: [PATCH 09/15] fix(uninstall): remove ENHANCD_DIRECTORIES --- conf.d/enhancd.fish | 1 + 1 file changed, 1 insertion(+) diff --git a/conf.d/enhancd.fish b/conf.d/enhancd.fish index 0d9fa56..b9b32dc 100644 --- a/conf.d/enhancd.fish +++ b/conf.d/enhancd.fish @@ -41,6 +41,7 @@ function __enhancd_uninstall --on-event enhancd_uninstall set --erase ENHANCD_COMMAND set --erase ENHANCD_ROOT set --erase ENHANCD_DIR + set --erase ENHANCD_DIRECTORIES set --erase ENHANCD_ENABLE_DOUBLE_DOT set --erase ENHANCD_ENABLE_SINGLE_DOT set --erase ENHANCD_ENABLE_HYPHEN From 58085431109311797de1056596ea4b350b3f308f Mon Sep 17 00:00:00 2001 From: gazorby Date: Mon, 4 Sep 2023 17:25:34 +0200 Subject: [PATCH 10/15] feat: add piping capability --- conf.d/enhancd.fish | 8 ++- functions/_enhancd_cd_after.fish | 3 +- functions/_enhancd_command_awk.fish | 14 +--- functions/_enhancd_filepath_abs.fish | 2 +- .../_enhancd_filepath_get_parent_dirs.fish | 2 +- functions/_enhancd_filepath_split.fish | 2 +- functions/_enhancd_filepath_walk.fish | 3 +- functions/_enhancd_filter_exclude.fish | 5 +- functions/_enhancd_filter_exists.fish | 8 +-- functions/_enhancd_filter_fuzzy.fish | 8 +-- functions/_enhancd_filter_interactive.fish | 68 ++++++------------- functions/_enhancd_filter_limit.fish | 9 +-- functions/_enhancd_filter_replace.fish | 2 +- functions/_enhancd_filter_reverse.fish | 11 ++- functions/_enhancd_filter_unique.fish | 8 ++- functions/_enhancd_history_exists.fish | 3 +- functions/_enhancd_history_open.fish | 10 +-- functions/_enhancd_history_update.fish | 15 ++-- functions/_enhancd_ltsv_parse.fish | 14 ++-- functions/_enhancd_source_home.fish | 5 +- functions/enhancd.fish | 32 +++++---- 21 files changed, 98 insertions(+), 134 deletions(-) diff --git a/conf.d/enhancd.fish b/conf.d/enhancd.fish index b9b32dc..5e20256 100644 --- a/conf.d/enhancd.fish +++ b/conf.d/enhancd.fish @@ -27,6 +27,8 @@ function __enhancd_install --on-event enhancd_install # Set the filters if empty set -Ux ENHANCD_FILTER "fzy:fzf:peco:sk:zf" + set -Ux ENHANCD_AWK_CMD "awk" + # make a log file and a root directory if not test -d "$ENHANCD_DIR" mkdir -p "$ENHANCD_DIR" @@ -41,7 +43,6 @@ function __enhancd_uninstall --on-event enhancd_uninstall set --erase ENHANCD_COMMAND set --erase ENHANCD_ROOT set --erase ENHANCD_DIR - set --erase ENHANCD_DIRECTORIES set --erase ENHANCD_ENABLE_DOUBLE_DOT set --erase ENHANCD_ENABLE_SINGLE_DOT set --erase ENHANCD_ENABLE_HYPHEN @@ -56,6 +57,8 @@ function __enhancd_uninstall --on-event enhancd_uninstall set --erase ENHANCD_COMPLETION_KEYBIND set --erase ENHANCD_FILTER set --erase ENHANCD_CURRENT_FILTER + set --erase ENHANCD_DIRECTORIES + set --erase ENHANCD_AWK_CMD set --erase _ENHANCD_VERSION set --erase _ENHANCD_READY end @@ -69,9 +72,10 @@ end bind \ef '_enhancd_complete' set -Ux ENHANCD_CURRENT_FILTER (_enhancd_helper_parse_filter_string "$ENHANCD_FILTER") +set -Ux ENHANCD_AWK_CMD (_enhancd_command_awk) # Migrate from file based to universal var -if test -z $ENHANCD_DIRECTORIES; and test -f "$ENHANCD_DIR/enhancd.log" +if test -z "$ENHANCD_DIRECTORIES"; and test -f "$ENHANCD_DIR/enhancd.log" while read -l line set -a ENHANCD_DIRECTORIES "$line" end < "$ENHANCD_DIR/enhancd.log" diff --git a/functions/_enhancd_cd_after.fish b/functions/_enhancd_cd_after.fish index f6e5da2..c8ab575 100644 --- a/functions/_enhancd_cd_after.fish +++ b/functions/_enhancd_cd_after.fish @@ -2,8 +2,7 @@ function _enhancd_cd_after # Don't split on newlines throughout this function: set -l IFS "" - set -l list (_enhancd_history_update) - + set -l list (string split \n -- (_enhancd_history_update)) if test -n "$list" set -Ux ENHANCD_DIRECTORIES $list end diff --git a/functions/_enhancd_command_awk.fish b/functions/_enhancd_command_awk.fish index 44523d8..9b6b2ca 100644 --- a/functions/_enhancd_command_awk.fish +++ b/functions/_enhancd_command_awk.fish @@ -1,16 +1,8 @@ # Returns gawk if found, else awk function _enhancd_command_awk - set -l awk_cmd - if type -q gawk - set awk_cmd "gawk" + echo "gawk" else - set awk_cmd "awk" + echo "awk" end - - if set -q argv[1] - $awk_cmd $argv - else - $awk_cmd "" - end -end \ No newline at end of file +end diff --git a/functions/_enhancd_filepath_abs.fish b/functions/_enhancd_filepath_abs.fish index 12fd5a1..2361793 100644 --- a/functions/_enhancd_filepath_abs.fish +++ b/functions/_enhancd_filepath_abs.fish @@ -13,7 +13,7 @@ function _enhancd_filepath_abs return 1 end - _enhancd_command_awk \ + "$ENHANCD_AWK_CMD" \ -f "$ENHANCD_ROOT/lib/to_abspath.awk" \ -v cwd="$cwd" \ -v dir="$dir" diff --git a/functions/_enhancd_filepath_get_parent_dirs.fish b/functions/_enhancd_filepath_get_parent_dirs.fish index c46b6c1..948cd03 100644 --- a/functions/_enhancd_filepath_get_parent_dirs.fish +++ b/functions/_enhancd_filepath_get_parent_dirs.fish @@ -4,7 +4,7 @@ function _enhancd_filepath_get_parent_dirs set argv[1] "$PWD" end - _enhancd_command_awk \ + "$ENHANCD_AWK_CMD" \ -f "$ENHANCD_ROOT/lib/step_by_step.awk" \ -v dir="$argv[1]" end diff --git a/functions/_enhancd_filepath_split.fish b/functions/_enhancd_filepath_split.fish index 7292f04..67d28f2 100644 --- a/functions/_enhancd_filepath_split.fish +++ b/functions/_enhancd_filepath_split.fish @@ -4,7 +4,7 @@ function _enhancd_filepath_split set $argv[1] $PWD end - _enhancd_command_awk \ + "$ENHANCD_AWK_CMD" \ -f "$ENHANCD_ROOT/lib/split.awk" \ -v arg=$argv[1] end diff --git a/functions/_enhancd_filepath_walk.fish b/functions/_enhancd_filepath_walk.fish index 55ca4c0..bb1116a 100644 --- a/functions/_enhancd_filepath_walk.fish +++ b/functions/_enhancd_filepath_walk.fish @@ -1,6 +1,5 @@ function _enhancd_filepath_walk - _enhancd_filepath_get_parent_dirs | read --list --local dirs - set --prepend dirs $PWD + set -a dirs $PWD (_enhancd_filepath_get_parent_dirs) for dir in $dirs command find "$dir" -maxdepth 1 -type d -name '\.*' -prune -o -type d -print diff --git a/functions/_enhancd_filter_exclude.fish b/functions/_enhancd_filter_exclude.fish index 999cc62..47c3389 100644 --- a/functions/_enhancd_filter_exclude.fish +++ b/functions/_enhancd_filter_exclude.fish @@ -1,5 +1,4 @@ function _enhancd_filter_exclude - read --list --local input - echo (string match -v "$argv[1]" -- $input) - or true + _enhancd_command_grep -v -x "$argv[1]" + ; or true end diff --git a/functions/_enhancd_filter_exists.fish b/functions/_enhancd_filter_exists.fish index 096fbcd..d5ae77e 100644 --- a/functions/_enhancd_filter_exists.fish +++ b/functions/_enhancd_filter_exists.fish @@ -1,10 +1,8 @@ function _enhancd_filter_exists - read --list --local lines - set -l items - for line in $lines + set -l line + while read line if test -d "$line" - set -a items "$line" + echo "$line" end end - echo $items end diff --git a/functions/_enhancd_filter_fuzzy.fish b/functions/_enhancd_filter_fuzzy.fish index fb9a9eb..e946331 100644 --- a/functions/_enhancd_filter_fuzzy.fish +++ b/functions/_enhancd_filter_fuzzy.fish @@ -1,13 +1,9 @@ function _enhancd_filter_fuzzy - read --list --local stdin if test -z "$argv[1]" - echo $stdin + command cat <&0 else - set -l dirs ( - string join \n -- $stdin | _enhancd_command_awk \ + "$ENHANCD_AWK_CMD" \ -f "$ENHANCD_ROOT/lib/fuzzy.awk" \ -v search_string="$argv[1]" - ) - echo $dirs end end diff --git a/functions/_enhancd_filter_interactive.fish b/functions/_enhancd_filter_interactive.fish index 37b5c3c..c3cbb9c 100644 --- a/functions/_enhancd_filter_interactive.fish +++ b/functions/_enhancd_filter_interactive.fish @@ -1,54 +1,30 @@ function _enhancd_filter_interactive - read --local --list stdin + set -l filter "$ENHANCD_CURRENT_FILTER" + set -l before_cmd + set -l after_cmd - # If input separated by the null character - # only the first line has been read in stdin - if test (count $stdin) -eq 1 - set -l tmp $stdin - read -z --list stdin - set --prepend stdin $tmp - end - - if test -z "$stdin"; or test -p /dev/stdin - read -z stdin + if test "$ENHANCD_USE_ABBREV" = true + # Escape '/' for sed processing + set -l home_escaped (string replace -a '/' '\/' "$HOME") + set before_cmd sed 's/^'$home_escaped'/~/g' + set after_cmd sed 's/^~/'$home_escaped'/g' + else + set before_cmd cat + set after_cmd cat end - if test -z "$stdin" + read --line line_1 line_2 + if test -z "$line_1" -a -z "$line_2" echo "no entry" >&2 return 1 - end - - set -l count (count $stdin) - - if test "$ENHANCD_USE_ABBREV" = true - function _enhancd_filter_interactive_abbrev - while read -l line - string replace --regex "^$HOME" "~" "$line" - end - end - - function _enhancd_filter_interactive_expand - while read -l line - string replace --regex "^~" "$HOME" "$line" - end - end - - set filter "_enhancd_filter_interactive_abbrev | $ENHANCD_CURRENT_FILTER | _enhancd_filter_interactive_expand" - end - - switch "$count" - case '1' - if test -n "$stdin" - echo "$stdin" - else - return 1 - end - - case '*' - set -l selected (string join \n -- $stdin | eval "$ENHANCD_CURRENT_FILTER") - if test -z "$selected" - return 1 - end - echo "$selected" + else if test -n "$line_1" -a -z "$line_2" + echo "$line_1" + else + # Prepend the first two lines we read to stdin + begin + printf "$line_1\n$line_2\n" + cat + end | $before_cmd | $filter | $after_cmd + or return 1 end end diff --git a/functions/_enhancd_filter_limit.fish b/functions/_enhancd_filter_limit.fish index da7971a..6b179d3 100644 --- a/functions/_enhancd_filter_limit.fish +++ b/functions/_enhancd_filter_limit.fish @@ -1,8 +1,9 @@ function _enhancd_filter_limit - read --local --list items - set -l limit 10 - if set -q argv[1] + set -l limit + if not set -q $argv[1] + set limit 10 + else set limit $argv[1] end - echo $items[1..$limit] + command head -n "$limit" end diff --git a/functions/_enhancd_filter_replace.fish b/functions/_enhancd_filter_replace.fish index 6be44be..2018275 100644 --- a/functions/_enhancd_filter_replace.fish +++ b/functions/_enhancd_filter_replace.fish @@ -3,7 +3,7 @@ function _enhancd_filter_replace set -l old $argv[1] set -q argv[2] && set -l new $argv[2] - _enhancd_command_awk \ + "$ENHANCD_AWK_CMD" \ -v old="$old" \ -v new="$new" \ 'sub(old, new, $0) {print $0}' diff --git a/functions/_enhancd_filter_reverse.fish b/functions/_enhancd_filter_reverse.fish index 460ffa7..758858f 100644 --- a/functions/_enhancd_filter_reverse.fish +++ b/functions/_enhancd_filter_reverse.fish @@ -1,5 +1,12 @@ # _enhancd_filter_reverse reverses a stdin contents function _enhancd_filter_reverse - read --list --local str - echo $str[-1..1] + set -l lines + if test -n "$argv[1]"; and test -f "$argv[1]" + set lines "$argv[1]" + else + read -z --list lines + end + for line in $lines[-1..1] + echo $line + end end diff --git a/functions/_enhancd_filter_unique.fish b/functions/_enhancd_filter_unique.fish index ca8ff56..7a67381 100644 --- a/functions/_enhancd_filter_unique.fish +++ b/functions/_enhancd_filter_unique.fish @@ -1,6 +1,8 @@ # _enhancd_filter_unique uniques a stdin contents function _enhancd_filter_unique - set -l items - read --list --local items - echo (string join \n -- $items | _enhancd_command_awk '!a[$0]++' 2>/dev/null) + if test -n "$argv[1]"; and test -f "$argv[1]" + command cat "$argv[1]" + else + command cat <&0 + end | "$ENHANCD_AWK_CMD" '!a[$0]++' 2>/dev/null end diff --git a/functions/_enhancd_history_exists.fish b/functions/_enhancd_history_exists.fish index b0a0806..a4d5a47 100644 --- a/functions/_enhancd_history_exists.fish +++ b/functions/_enhancd_history_exists.fish @@ -4,6 +4,5 @@ function _enhancd_history_exists else set dir $argv[1] end - - _enhancd_history_open | string match -r -q "$dir" ^/dev/null >/dev/null + _enhancd_history_open | string match -r -q "$dir" end diff --git a/functions/_enhancd_history_open.fish b/functions/_enhancd_history_open.fish index c8b57ae..afe8592 100644 --- a/functions/_enhancd_history_open.fish +++ b/functions/_enhancd_history_open.fish @@ -1,12 +1,4 @@ function _enhancd_history_open - echo $ENHANCD_DIRECTORIES + string join \n -- $ENHANCD_DIRECTORIES return $status end - -function set_mem_var - set -e ENHANCD_DIRECTORIES - set -Ux ENHANCD_DIRECTORIES - while read -l line - set -a ENHANCD_DIRECTORIES "$line" - end < ~/.enhancd/enhancd.log -end diff --git a/functions/_enhancd_history_update.fish b/functions/_enhancd_history_update.fish index a1b5dbd..966a90a 100644 --- a/functions/_enhancd_history_update.fish +++ b/functions/_enhancd_history_update.fish @@ -1,11 +1,10 @@ function _enhancd_history_update - set -l list - set -a list (_enhancd_history_exists; or _enhancd_filepath_walk) - set -a list (_enhancd_history_open) - set -a list "$HOME" - echo $list \ - | _enhancd_filter_reverse \ - | _enhancd_filter_unique \ - | _enhancd_filter_reverse + begin + _enhancd_history_exists "$PWD"; or _enhancd_filepath_walk + _enhancd_history_open + echo "$HOME" + end | _enhancd_filter_reverse \ + | _enhancd_filter_unique \ + | _enhancd_filter_reverse _enhancd_filepath_current_dir end diff --git a/functions/_enhancd_ltsv_parse.fish b/functions/_enhancd_ltsv_parse.fish index 5c21158..ddd7065 100644 --- a/functions/_enhancd_ltsv_parse.fish +++ b/functions/_enhancd_ltsv_parse.fish @@ -5,14 +5,14 @@ function _enhancd_ltsv_parse set -l i 1 while [ $i -le (count argv) ] switch "$argv[$i]" - case "-q" + case -q set -l query $argv[(math "$i + 1")] shift - case "-v" - set -a args "-v" $argv[(math "$i + 1")] - case "-f" - set -a args "-f" "$ENHANCD_ROOT/lib/ltsv.awk" - set -a args "-f" $argv[(math "$i + 1")] + case -v + set -a args -v $argv[(math "$i + 1")] + case -f + set -a args -f "$ENHANCD_ROOT/lib/ltsv.awk" + set -a args -f $argv[(math "$i + 1")] set query "" end set i (math "$i + 1") @@ -26,5 +26,5 @@ function _enhancd_ltsv_parse end set -l awk_scripts "$ltsv_script $query" - _enhancd_command_awk $args "$awk_scripts" + "$ENHANCD_AWK_CMD" $args "$awk_scripts" end diff --git a/functions/_enhancd_source_home.fish b/functions/_enhancd_source_home.fish index a708d3e..30740de 100644 --- a/functions/_enhancd_source_home.fish +++ b/functions/_enhancd_source_home.fish @@ -5,8 +5,7 @@ function _enhancd_source_home end begin - set -l list (_enhancd_history_list) - set -a list "$HOME" - echo $list + echo "$HOME" + _enhancd_history_list end | _enhancd_filter_unique end diff --git a/functions/enhancd.fish b/functions/enhancd.fish index 2b13eff..666dde6 100644 --- a/functions/enhancd.fish +++ b/functions/enhancd.fish @@ -4,7 +4,7 @@ function enhancd set -l opts set -l code 0 - if test -z $_ENHANCD_READY + if test -z "$_ENHANCD_READY" _enhancd_cd_ready if not set -q argv[1] _enhancd_cd_builtin "$HOME" @@ -14,18 +14,18 @@ function enhancd return $status end + if not isatty + _enhancd_filter_interactive | read --line args + end + # set indice to the first element set -l i 1 - set -l count_argv (count $argv) - while [ $i -le $count_argv ] + while [ $i -le (count $argv) ] switch $argv[$i] - case "$ENHANCD_ARG_DOUBLE_DOT" - set -a args (_enhancd_source_parent_dirs | _enhancd_filter_interactive) - set code $status - - case '..' - set -a args ".." + case --help + _enhancd_ltsv_open \ + | "$ENHANCD_AWK_CMD" -f "$ENHANCD_ROOT/lib/help.awk" case "$ENHANCD_ARG_HYPHEN" # If a hyphen is passed as the argument, @@ -36,6 +36,13 @@ function enhancd case - set -a args "$OLDPWD" + case "$ENHANCD_ARG_DOUBLE_DOT" + set -a args (_enhancd_source_parent_dirs | _enhancd_filter_interactive) + set code $status + + case '..' + set -a args ".." + case "$ENHANCD_ARG_SINGLE_DOT" set -a args (_enhancd_sources_current_dirs | _enhancd_filter_interactive) set code $status @@ -52,10 +59,6 @@ function enhancd set -a args (_enhancd_source_history "$argv[2]" | _enhancd_filter_interactive) set code $status - case --help - _enhancd_ltsv_open \ - | _enhancd_command_awk -f "$ENHANCD_ROOT/lib/help.awk" - case '-*' '--*' if _enhancd_helper_is_default_flag "$argv[1]" set -a opts "$argv[1]" @@ -91,7 +94,6 @@ function enhancd end - case '*' set -a args (_enhancd_source_history "$argv[1]" | _enhancd_filter_interactive) @@ -99,7 +101,7 @@ function enhancd set i (math "$i + 1") end - switch $count_argv + switch (count $args) case 0 set -a args (_enhancd_source_home | _enhancd_filter_interactive) set code $status From 9e32cdee86b6bdff3d9b1375fad2c07bf7642ad5 Mon Sep 17 00:00:00 2001 From: gazorby Date: Mon, 4 Sep 2023 20:10:51 +0200 Subject: [PATCH 11/15] fix: readiness --- conf.d/enhancd.fish | 2 ++ functions/_enhancd_cd_ready.fish | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/conf.d/enhancd.fish b/conf.d/enhancd.fish index 5e20256..7b9a9cc 100644 --- a/conf.d/enhancd.fish +++ b/conf.d/enhancd.fish @@ -24,6 +24,8 @@ function __enhancd_install --on-event enhancd_install set -Ux _ENHANCD_VERSION (command cat "$root/VERSION") + set -Ux ENHANCD_DIRECTORIES + set -Ux ENHANCD_CURRENT_FILTER # Set the filters if empty set -Ux ENHANCD_FILTER "fzy:fzf:peco:sk:zf" diff --git a/functions/_enhancd_cd_ready.fish b/functions/_enhancd_cd_ready.fish index cb039a7..b6f31ca 100644 --- a/functions/_enhancd_cd_ready.fish +++ b/functions/_enhancd_cd_ready.fish @@ -1,6 +1,7 @@ function _enhancd_cd_ready - _enhancd_helper_parse_filter_string "$ENHANCD_FILTER" 2 >/dev/null - ; and test -n $ENHNCD_DIRECTORIES + test -n "$ENHANCD_AWK_CMD" + ; and test -n "$ENHANCD_CURRENT_FILTER" + ; and test -n "$ENHANCD_DIRECTORIES" ; and set -Ux _ENHANCD_READY 1 return $status end From 66d1075ba47a0f3c0f05b55747f7f3267b42e04e Mon Sep 17 00:00:00 2001 From: gazorby Date: Tue, 5 Sep 2023 18:35:57 +0200 Subject: [PATCH 12/15] fix(filter): fix filter parsing when using options --- functions/_enhancd_helper_parse_filter_string.fish | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/functions/_enhancd_helper_parse_filter_string.fish b/functions/_enhancd_helper_parse_filter_string.fish index 1850ff4..fe555d6 100644 --- a/functions/_enhancd_helper_parse_filter_string.fish +++ b/functions/_enhancd_helper_parse_filter_string.fish @@ -11,7 +11,8 @@ function _enhancd_helper_parse_filter_string while test -n "$str" for item in (string split ':' $str) - if _enhancd_command_which "$item" + set -l cmd (string split ' ' -- "$item") + if _enhancd_command_which (string trim -- "$cmd[1]") echo $item return 0 else From f71aa886cd5d4686c66ef2bc39ad204719813531 Mon Sep 17 00:00:00 2001 From: gazorby Date: Tue, 5 Sep 2023 18:50:23 +0200 Subject: [PATCH 13/15] fix: fix history update --- functions/_enhancd_history_update.fish | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/_enhancd_history_update.fish b/functions/_enhancd_history_update.fish index 966a90a..055ca1e 100644 --- a/functions/_enhancd_history_update.fish +++ b/functions/_enhancd_history_update.fish @@ -1,6 +1,6 @@ function _enhancd_history_update begin - _enhancd_history_exists "$PWD"; or _enhancd_filepath_walk + _enhancd_history_exists; or _enhancd_filepath_walk _enhancd_history_open echo "$HOME" end | _enhancd_filter_reverse \ From ed9d17c740bd7748764b061c10517ead107d8a18 Mon Sep 17 00:00:00 2001 From: gazorby Date: Thu, 7 Sep 2023 18:53:02 +0200 Subject: [PATCH 14/15] fix(fish): alt+f not triggering the filter --- functions/_enhancd_complete.fish | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/functions/_enhancd_complete.fish b/functions/_enhancd_complete.fish index 32030ba..bd74b00 100644 --- a/functions/_enhancd_complete.fish +++ b/functions/_enhancd_complete.fish @@ -1,7 +1,9 @@ function _enhancd_complete - set -l query (_enhancd_source_home)/ + set -l query (_enhancd_source_home | _enhancd_filter_interactive) + if test -n "$query" commandline -t "$query" end - commandline -f repaint + + commandline --functions repaint end From 48197e4826c2a3013d9e497dac7f0d82c6d6686a Mon Sep 17 00:00:00 2001 From: gazorby Date: Sat, 9 Sep 2023 19:49:43 +0200 Subject: [PATCH 15/15] fix(complete): commandline option --- functions/_enhancd_complete.fish | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/_enhancd_complete.fish b/functions/_enhancd_complete.fish index bd74b00..31115f4 100644 --- a/functions/_enhancd_complete.fish +++ b/functions/_enhancd_complete.fish @@ -5,5 +5,5 @@ function _enhancd_complete commandline -t "$query" end - commandline --functions repaint + commandline -f repaint end