feat: ability to set program for zinit ls to use (#221)

A user can now specify a program via the `$ZINIT[LIST_COMMAND]`
variable. Additionally, it will first check for `exa` and fallback to
tree if this variable is not set.

e.g., use exa or any `tree`-esque program in `zinit ls`.

Closes #170

Signed-off-by: Vladislav Doster <mvdoster@gmail.com>
This commit is contained in:
vladislav doster 2022-04-25 01:00:47 -05:00 committed by GitHub
parent 421855b933
commit bad7af3ae2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 32 additions and 19 deletions

View file

@ -1028,6 +1028,7 @@ ## Customizing Paths
| ZINIT\[PLUGINS_DIR\] | Override single working directory for plugins, e.g. "/opt/zsh/zinit/plugins" |
| ZINIT\[COMPLETIONS_DIR\] | As above, but for completion files, e.g. "/opt/zsh/zinit/root_completions" |
| ZINIT\[SNIPPETS_DIR\] | As above, but for snippets |
| ZINIT\[LIST_COMMAND\] | Command to use for displaying a directory tree (e.g., `ls --tree`, `tree`, etc.) |
| ZINIT\[ZCOMPDUMP_PATH\] | Path to `.zcompdump` file, with the file included (i.e. its name can be different) |
| ZINIT\[COMPINIT_OPTS\] | Options for `compinit` call (i.e. done by `zicompinit`), use to pass -C to speed up loading |
| ZINIT\[MUTE_WARNINGS\] | If set to `1`, then mutes some of the Zinit warnings, specifically the `plugin already registered` warning |

View file

@ -865,7 +865,7 @@ ____
FUNCTION: .zinit-ls [[[
____
Has 19 line(s). Doesn't call other functions.
Has 20 line(s). Doesn't call other functions.
Uses feature(s): _setopt_

View file

@ -90,7 +90,7 @@ DETAILS
Script Body
~~~~~~~~~~~
Has 217 line(s). Calls functions:
Has 227 line(s). Calls functions:
Script-Body
|-- +zinit-message

View file

@ -3,12 +3,23 @@
@test 'nnn' {
run zinit light-mode for jarun/nnn
zinit cd jarun/nnn
run PREFIX=$ZPFX make install
assert $state equals 0
local nnn="$ZPFX/bin/nnn"
assert "$nnn" is_executable
$nnn -V
assert $state equals 0
run PREFIX=$ZPFX make install; assert $state equals 0
local nnn="$ZPFX/bin/nnn"; assert $nnn is_executable
$nnn -V; assert $state equals 0
}
@test 'pipes' {
run zinit light-mode for @pipeseroni/pipes.sh
zinit cd pipeseroni/pipes.sh
run make PREFIX=$ZPFX install; assert $state equals 0
local pipes="$ZPFX/bin/pipes.sh"; assert $pipes is_executable
$pipes -v; assert $state equals 0
}
@test 'tree' {
run zinit light-mode for Old-Man-Programmer/tree
zinit cd Old-Man-Programmer/tree
run make PREFIX=$ZPFX install; assert $state equals 0
local tree="$ZPFX/bin/tree"; assert $tree is_executable
$tree -v; assert $state equals 0
}
# @test 'zsh_bin' {
# run zinit as'null' sbin'bin/zsh' for @romkatv/zsh-bin
@ -18,15 +29,5 @@
# $zsh_static --help
# assert $state equals 0
# }
@test 'pipes' {
run zinit light-mode for @pipeseroni/pipes.sh
zinit cd pipeseroni/pipes.sh
run make PREFIX=$ZPFX install
assert $state equals 0
local pipes="$ZPFX/bin/pipes.sh"
assert "$pipes" is_executable
$pipes -v
assert $state equals 0
}
# vim:ft=zsh:sw=4:sts=4:et:foldmarker={,}:foldmethod=marker

View file

@ -3246,7 +3246,8 @@ EOF
setopt localoptions extendedglob nokshglob noksharrays
builtin cd -q "${ZINIT[SNIPPETS_DIR]}"
local -a list
list=( "${(f@)"$(LANG=en_US.utf-8 tree -L 3 --charset utf-8)"}" )
local -x LANG=en_US.utf-8
list=( "${(f@)"$(${=ZINIT[LIST_COMMAND]})"}" )
# Oh-My-Zsh single file
list=( "${list[@]//(#b)(https--github.com--(ohmyzsh|robbyrussel)l--oh-my-zsh--raw--master(--)(#c0,1)(*))/$ZINIT[col-info]Oh-My-Zsh$ZINIT[col-error]${match[2]/--//}$ZINIT[col-pname]${match[3]//--/$ZINIT[col-error]/$ZINIT[col-pname]} $ZINIT[col-info](single-file)$ZINIT[col-rst] ${match[1]}}" )
# Oh-My-Zsh SVN

View file

@ -57,6 +57,16 @@ if [[ -z ${ZINIT[HOME_DIR]} ]]; then
fi
fi
if [[ -z ${ZINIT[LIST_COMMAND]} ]]; then
if (( ${+commands[exa]} )); then
ZINIT[LIST_COMMAND]='exa --color=always --tree --icons -L3'
elif (( ${+commands[tree]} )); then
ZINIT[LIST_COMMAND]='tree -L 3 -C --charset utf-8'
else
ZINIT[LIST_COMMAND]='ls --tree'
fi
fi
ZINIT[ice-list]="svn|proto|from|teleid|bindmap|cloneopts|id-as|depth|if|wait|load|\
unload|blockf|pick|bpick|src|as|ver|silent|lucid|notify|mv|cp|\
atinit|atclone|atload|atpull|nocd|run-atpull|has|cloneonly|make|\