1
0
dotfiles/.config/zsh/alias/ls.zsh

58 lines
1.1 KiB
Bash
Raw Permalink Normal View History

2021-03-21 18:25:10 +03:00
#!/bin/zsh
if [ -z "${LS_COLORS}" ] ; then
(( $+commands[dircolors] )) && eval "$(dircolors -b)"
fi
case "${ZSHU[os_family]}" in
2024-01-27 00:10:58 +03:00
bsd | darwin ) export LSCOLORS="Gxfxcxdxbxegedabagacad" ;;
2021-03-21 18:25:10 +03:00
esac
2021-12-07 02:46:50 +03:00
z-alt-ls() {
2021-03-21 18:25:10 +03:00
local -a a
2022-07-19 02:41:45 +03:00
local n
2021-03-21 18:25:10 +03:00
a=( ${(@s:|:)1} )
[ ${#a} = 0 ] && a=( "$1" )
2022-07-19 02:41:45 +03:00
n=${#a}
2021-03-21 18:25:10 +03:00
[ -z "$1" ] && n=0
case "$n" in
2024-01-27 00:10:58 +03:00
0 ) ;;
* )
z-alt-set-static \
'ls|-d .' \
"$1" \
"LS_OPTIONS='' command"
2021-12-07 02:46:50 +03:00
;;
2021-03-21 18:25:10 +03:00
esac
}
LS_GNU='--color=tty --group-directories-first'
case "${ZSHU[os_type]}" in
2024-01-27 00:10:58 +03:00
linux* ) alt="ls ${LS_GNU}|ls" ;;
netbsd* ) alt="gls ${LS_GNU}|ls" ;;
openbsd* ) alt="gls ${LS_GNU}|colorls -G|ls" ;;
freebsd* ) alt="gls ${LS_GNU}|ls -G|ls" ;;
darwin* ) alt="gls ${LS_GNU}|ls -G|ls" ;;
* ) alt="ls ${LS_GNU}|ls" ;;
2021-03-21 18:25:10 +03:00
esac
2021-12-07 02:46:50 +03:00
z-alt-ls "${alt}"
unset -f z-alt-ls
2021-03-21 18:25:10 +03:00
unset alt LS_GNU
[ -n "${LS_COLORS}" ] && zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
case "${ZSHU[os_family]}" in
2024-01-27 00:10:58 +03:00
linux ) alias l='ls -lhF ' ;;
bsd ) alias l='ls -lhIF ' ;;
2021-03-21 18:25:10 +03:00
esac
alias ll='ls -lAF '
case "${ZSHU[os_family]}" in
2024-01-27 00:10:58 +03:00
linux ) alias lll='ls -lAn --full-time ' ;;
bsd ) alias lll='ls -lAnT ' ;;
2021-03-21 18:25:10 +03:00
esac