added lsd

This commit is contained in:
2020-01-26 15:08:34 +01:00
parent 3ab57f209d
commit da5855133d
6 changed files with 528 additions and 0 deletions

@ -0,0 +1,68 @@
#compdef lsd
autoload -U is-at-least
_lsd() {
typeset -A opt_args
typeset -a _arguments_options
local ret=1
if is-at-least 5.2; then
_arguments_options=(-s -S -C)
else
_arguments_options=(-s -C)
fi
local context curcontext="$curcontext" state line
_arguments "${_arguments_options[@]}" \
'*--color=[When to use terminal colours]: :(always auto never)' \
'*--icon=[When to print the icons]: :(always auto never)' \
'*--icon-theme=[Whether to use fancy or unicode icons]: :(fancy unicode)' \
'--depth=[Stop recursing into directories after reaching specified depth]' \
'*--size=[How to display size]: :(default short bytes)' \
'*--date=[How to display date]: :(date relative)' \
'*--group-dirs=[Sort the directories then the files]: :(none first last)' \
'*--blocks=[Specify the blocks that will be displayed and in what order]: :(permission user group size date name)' \
'*-a[Do not ignore entries starting with .]' \
'*--all[Do not ignore entries starting with .]' \
'*-A[Do not list implied . and ..]' \
'*--almost-all[Do not list implied . and ..]' \
'*-F[Append indicator (one of */=>@|) at the end of the file names]' \
'*--classify[Append indicator (one of */=>@|) at the end of the file names]' \
'*-l[Display extended file metadata as a table]' \
'*--long[Display extended file metadata as a table]' \
'*-1[Display one entry per line]' \
'*--oneline[Display one entry per line]' \
'(--tree)*-R[Recurse into directories]' \
'(--tree)*--recursive[Recurse into directories]' \
'-h[For ls compatibility purposes ONLY, currently set by default]' \
'--human-readable[For ls compatibility purposes ONLY, currently set by default]' \
'(-R --recursive)*--tree[Recurse into directories and present the result as a tree]' \
'(-a --all -A --almost-all --depth -R --recursive --tree)-d[Display directories themselves, and not their contents]' \
'(-a --all -A --almost-all --depth -R --recursive --tree)--directory-only[Display directories themselves, and not their contents]' \
'*--total-size[Display the total size of directories]' \
'*-t[Sort by time modified]' \
'*--timesort[Sort by time modified]' \
'*-S[Sort by size]' \
'*--sizesort[Sort by size]' \
'*-r[Reverse the order of the sort]' \
'*--reverse[Reverse the order of the sort]' \
'--classic[Enable classic mode (no colors or icons)]' \
'*--no-symlink[Do not display symlink target]' \
'--help[Prints help information]' \
'-V[Prints version information]' \
'--version[Prints version information]' \
'::FILE:_files' \
&& ret=0
}
(( $+functions[_lsd_commands] )) ||
_lsd_commands() {
local commands; commands=(
)
_describe -t commands 'lsd commands' commands "$@"
}
_lsd "$@"

@ -0,0 +1,73 @@
_lsd() {
local i cur prev opts cmds
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
cmd=""
opts=""
for i in ${COMP_WORDS[@]}
do
case "${i}" in
lsd)
cmd="lsd"
;;
*)
;;
esac
done
case "${cmd}" in
lsd)
opts=" -a -A -F -l -1 -R -h -d -t -S -r -V --all --almost-all --classify --long --oneline --recursive --human-readable --tree --directory-only --total-size --timesort --sizesort --reverse --classic --no-symlink --help --version --color --icon --icon-theme --depth --size --date --group-dirs --blocks <FILE>... "
if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
fi
case "${prev}" in
--color)
COMPREPLY=($(compgen -W "always auto never" -- ${cur}))
return 0
;;
--icon)
COMPREPLY=($(compgen -W "always auto never" -- ${cur}))
return 0
;;
--icon-theme)
COMPREPLY=($(compgen -W "fancy unicode" -- ${cur}))
return 0
;;
--depth)
COMPREPLY=($(compgen -f ${cur}))
return 0
;;
--size)
COMPREPLY=($(compgen -W "default short bytes" -- ${cur}))
return 0
;;
--date)
COMPREPLY=($(compgen -W "date relative" -- ${cur}))
return 0
;;
--group-dirs)
COMPREPLY=($(compgen -W "none first last" -- ${cur}))
return 0
;;
--blocks)
COMPREPLY=($(compgen -W "permission user group size date name" -- ${cur}))
return 0
;;
*)
COMPREPLY=()
;;
esac
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
;;
esac
}
complete -F _lsd -o bashdefault -o default lsd

@ -0,0 +1,25 @@
complete -c lsd -n "__fish_use_subcommand" -l color -d 'When to use terminal colours' -r -f -a "always auto never"
complete -c lsd -n "__fish_use_subcommand" -l icon -d 'When to print the icons' -r -f -a "always auto never"
complete -c lsd -n "__fish_use_subcommand" -l icon-theme -d 'Whether to use fancy or unicode icons' -r -f -a "fancy unicode"
complete -c lsd -n "__fish_use_subcommand" -l depth -d 'Stop recursing into directories after reaching specified depth'
complete -c lsd -n "__fish_use_subcommand" -l size -d 'How to display size' -r -f -a "default short bytes"
complete -c lsd -n "__fish_use_subcommand" -l date -d 'How to display date' -r -f -a "date relative"
complete -c lsd -n "__fish_use_subcommand" -l group-dirs -d 'Sort the directories then the files' -r -f -a "none first last"
complete -c lsd -n "__fish_use_subcommand" -l blocks -d 'Specify the blocks that will be displayed and in what order' -r -f -a "permission user group size date name"
complete -c lsd -n "__fish_use_subcommand" -s a -l all -d 'Do not ignore entries starting with .'
complete -c lsd -n "__fish_use_subcommand" -s A -l almost-all -d 'Do not list implied . and ..'
complete -c lsd -n "__fish_use_subcommand" -s F -l classify -d 'Append indicator (one of */=>@|) at the end of the file names'
complete -c lsd -n "__fish_use_subcommand" -s l -l long -d 'Display extended file metadata as a table'
complete -c lsd -n "__fish_use_subcommand" -s 1 -l oneline -d 'Display one entry per line'
complete -c lsd -n "__fish_use_subcommand" -s R -l recursive -d 'Recurse into directories'
complete -c lsd -n "__fish_use_subcommand" -s h -l human-readable -d 'For ls compatibility purposes ONLY, currently set by default'
complete -c lsd -n "__fish_use_subcommand" -l tree -d 'Recurse into directories and present the result as a tree'
complete -c lsd -n "__fish_use_subcommand" -s d -l directory-only -d 'Display directories themselves, and not their contents'
complete -c lsd -n "__fish_use_subcommand" -l total-size -d 'Display the total size of directories'
complete -c lsd -n "__fish_use_subcommand" -s t -l timesort -d 'Sort by time modified'
complete -c lsd -n "__fish_use_subcommand" -s S -l sizesort -d 'Sort by size'
complete -c lsd -n "__fish_use_subcommand" -s r -l reverse -d 'Reverse the order of the sort'
complete -c lsd -n "__fish_use_subcommand" -l classic -d 'Enable classic mode (no colors or icons)'
complete -c lsd -n "__fish_use_subcommand" -l no-symlink -d 'Do not display symlink target'
complete -c lsd -n "__fish_use_subcommand" -l help -d 'Prints help information'
complete -c lsd -n "__fish_use_subcommand" -s V -l version -d 'Prints version information'