Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update auto-ls.zsh #21

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions auto-ls.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -31,9 +33,14 @@ 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
Expand All @@ -44,7 +51,9 @@ auto-ls () {
eval $cmd
else
# Otherwise run auto-ls function
auto-ls-$cmd
if [[ $BUFFER == cd\ * ]] || [[ $BUFFER == autojump\ * ]] || [[ $BUFFER == j\ * ]] || [[ $BUFFER == z\ * ]] || [[ $BUFFER == wd\ * ]] || [[ $BUFFER == fasd\ * ]]; then
auto-ls-$cmd
fi
fi
done
zle && zle .accept-line
Expand All @@ -58,7 +67,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
Expand Down