-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathls.plugin.zsh
136 lines (111 loc) · 2.63 KB
/
ls.plugin.zsh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/usr/bin/env zsh
# Standarized $0 handling, following:
# https://z-shell.github.io/zsh-plugin-assessor/Zsh-Plugin-Standard
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
0="${${(M)0:#/*}:-$PWD/$0}"
local _DIRNAME="${0:h}"
# Remove any existing alias of ls
if [[ $(alias ls) ]]; then
unalias ls
fi
if [[ -z "$ZSH_LS_BACKEND" ]]; then
if [[ ! -z "$ZSH_LS_PREFER_LS" ]]; then
ZSH_LS_BACKEND='ls'
elif (( $+commands[lsd] )); then
ZSH_LS_BACKEND='lsd'
elif (( $+commands[eza] )); then
ZSH_LS_BACKEND='eza'
elif (( $+commands[exa] )); then
ZSH_LS_BACKEND='exa'
else
ZSH_LS_BACKEND='ls'
fi
fi
if [[ "$ZSH_LS_BACKEND" == "lsd" ]]; then
typeset -g lsd_params; lsd_params=()
function ls() {
lsd ${lsd_params} $@
}
compdef ls=lsd
function l() {
lsd ${lsd_params} $@
}
compdef l=lsd
function la() {
lsd -a ${lsd_params} $@
}
compdef la=lsd
function ll() {
lsd --header --long ${lsd_params} $@
}
compdef ll=lsd
function lt() {
lsd --tree ${lsd_params} $@
}
compdef lt=lsd
elif [[ "$ZSH_LS_BACKEND" == "exa" || "$ZSH_LS_BACKEND" == "eza" ]]; then
typeset -g exa_params; exa_params=('--icons' '--classify' '--group-directories-first' '--time-style=long-iso' '--group' '--color=auto')
if ((! ${+ZSH_LS_DISABLE_GIT})); then
exa_params+=('--git')
fi
function ls() {
$ZSH_LS_BACKEND ${exa_params} $@
}
compdef ls=$ZSH_LS_BACKEND
function l() {
$ZSH_LS_BACKEND --git-ignore ${exa_params} $@
}
compdef l=$ZSH_LS_BACKEND
function la() {
$ZSH_LS_BACKEND -a ${exa_params} $@
}
compdef la=$ZSH_LS_BACKEND
function ll() {
$ZSH_LS_BACKEND --header --long ${exa_params} $@
}
compdef ll=$ZSH_LS_BACKEND
function lt() {
$ZSH_LS_BACKEND --tree ${exa_params} $@
}
compdef lt=$ZSH_LS_BACKEND
else
typeset -g _ls
_ls=(=ls)
if (( $+commands[gls] )); then
_ls=(=gls)
fi
typeset -g _ls_params
_ls_params=('-hF' '--group-directories-first' '--time-style=+%Y-%m-%d %H:%M' '--quoting-style=literal')
if ${_ls[@]} --hyperlink >/dev/null 2>&1 ; then
_ls_params+=('--hyperlink')
fi
if [[ "$CLICOLOR" != "0" && -z "$NO_COLOR" ]]; then
_ls_params+=('--color')
fi
if (( $+commands[grc] )); then
_grc=('grc' "--config=${_DIRNAME}/conf.ls" )
fi
function ls() {
$_ls ${_ls_params} -C $@
}
compdef ls=ls
function l() {
$_ls ${_ls_params} -C $@
}
compdef l=ls
function la() {
$_ls ${_ls_params} -C -A $@
}
compdef la=ls
function ll() {
if [[ "$CLICOLOR" != "0" ]]; then
$_grc $_ls ${_ls_params} -l $@
else
$_ls -l $@
fi
}
compdef ll=ls
function lt() {
tree $@
}
fi