From 5d7dbfa0d727f67c991a14c7081481519de96fd7 Mon Sep 17 00:00:00 2001 From: p1r473 Date: Tue, 30 Apr 2024 12:49:15 -0400 Subject: [PATCH 1/2] Update auto-ls.zsh --- auto-ls.zsh | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/auto-ls.zsh b/auto-ls.zsh index 5d44462..7053c80 100755 --- a/auto-ls.zsh +++ b/auto-ls.zsh @@ -17,6 +17,8 @@ if (( ! ${+AUTO_LS_PATH} )); then AUTO_LS_PATH=true fi +# Initialize auto-ls activation flag +typeset -g AUTO_LS_INIT_COMPLETE=false auto-ls-ls () { ls --color=auto -a @@ -31,9 +33,13 @@ auto-ls-git-status () { auto-ls () { # Possible invocation sources: - # 1. Called from `chpwd_functions` – show file list - # 2. Called by another ZLE plugin (like `dirhistory`) through `zle accept-line` – show file list - # 3. Called by ZLE itself – only should file list if prompt was empty + # 1. Called from `chpwd_functions` – show file list + # 2. Called by another ZLE plugin (like `dirhistory`) through `zle accept-line` – show file list + # 3. Called by ZLE itself – only should file list if prompt was empty + # Initialize only after setup is complete and only continue if enabled + if [[ $AUTO_LS_INIT_COMPLETE == false || $AUTO_LS_CHPWD == false ]]; then + return + fi if ! zle \ || { [[ ${WIDGET} != accept-line ]] && [[ ${LASTWIDGET} != .accept-line ]] }\ || { [[ ${WIDGET} == accept-line ]] && [[ $#BUFFER -eq 0 ]] }; then @@ -44,7 +50,9 @@ auto-ls () { eval $cmd else # Otherwise run auto-ls function - auto-ls-$cmd + if [[ $BUFFER ]]; then + auto-ls-$cmd + fi fi done zle && zle .accept-line @@ -58,7 +66,7 @@ auto-ls () { echo && zle redisplay elif [[ ${WIDGET} != accept-line ]] && [[ ${LASTWIDGET} == .accept-line ]]; then # Hack to make only 2 lines appear after `dirlist` navigation - # (Uses a VT100 escape sequence to move curser up one line…) + # (Uses a VT100 escape sequence to move curser up one line…) tput cuu 1 else zle .accept-line From 6a9ade42b38075154d0c640f5aff336f0390d6d0 Mon Sep 17 00:00:00 2001 From: p1r473 Date: Tue, 30 Apr 2024 14:26:10 -0400 Subject: [PATCH 2/2] Update auto-ls.zsh --- auto-ls.zsh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/auto-ls.zsh b/auto-ls.zsh index 7053c80..a35e42d 100755 --- a/auto-ls.zsh +++ b/auto-ls.zsh @@ -40,6 +40,7 @@ auto-ls () { if [[ $AUTO_LS_INIT_COMPLETE == false || $AUTO_LS_CHPWD == false ]]; then return fi + if ! zle \ || { [[ ${WIDGET} != accept-line ]] && [[ ${LASTWIDGET} != .accept-line ]] }\ || { [[ ${WIDGET} == accept-line ]] && [[ $#BUFFER -eq 0 ]] }; then @@ -50,7 +51,7 @@ auto-ls () { eval $cmd else # Otherwise run auto-ls function - if [[ $BUFFER ]]; then + if [[ $BUFFER == cd\ * ]] || [[ $BUFFER == autojump\ * ]] || [[ $BUFFER == j\ * ]] || [[ $BUFFER == z\ * ]] || [[ $BUFFER == wd\ * ]] || [[ $BUFFER == fasd\ * ]]; then auto-ls-$cmd fi fi