-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathdevicons-ls
executable file
·133 lines (120 loc) · 2 KB
/
devicons-ls
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
#!/bin/bash
# Author: Ryan L McIntyre
# Project: devicons-shell
function devicons_get_directory_symbol {
local symbol=""
echo "$symbol $1"
return 0
}
function devicons_get_filetype_symbol {
declare -A extensions=(
[txt]=e
[styl]=
[scss]=
[htm]=
[html]=
[slim]=
[ejs]=
[css]=
[less]=
[md]=
[markdown]=
[json]=
[js]=
[jsx]=
[rb]=
[php]=
[py]=
[pyc]=
[pyo]=
[pyd]=
[coffee]=
[mustache]=
[hbs]=
[conf]=
[ini]=
[yml]=
[bat]=
[jpg]=
[jpeg]=
[bmp]=
[png]=
[gif]=
[ico]=
[twig]=
[cpp]=
[c++]=
[cxx]=
[cc]=
[cp]=
[c]=
[hs]=
[lhs]=
[lua]=
[java]=
[sh]=
[fish]=
[ml]=λ
[mli]=λ
[diff]=
[db]=
[sql]=
[dump]=
[clj]=
[cljc]=
[cljs]=
[edn]=
[scala]=
[go]=
[dart]=
[xul]=
[sln]=
[suo]=
[pl]=
[pm]=
[t]=
[rss]=
[f#]=
[fsscript]=
[fsx]=
[fs]=
[fsi]=
[rs]=
[rlib]=
[d]=
[erl]=
[hrl]=
[vim]=
[ai]=
[psd]=
[psb]=
[ts]=
[jl]=
)
local filetype
local default=
local exist_check=1
local input=$1
local filename="$1"
# using ## for possibly more than one "." (get after last one):
local filetype="${filename##*.}"
if [ ! -z "$filetype" ] && [ ${extensions[$filetype]+$exist_check} ]; then
local symbol=${extensions[$filetype]}
else
local symbol=$default
fi
echo "$symbol $1"
return 0
}
# for now wrap piped portion so uses the same 'subshell'
# @todo fixme - dont use pipe
find $1 -maxdepth 1 -type f -printf "%P\n" | sort | { while read line; do
lines="$lines $(devicons_get_filetype_symbol $line) \n"
done
echo -en "$lines \n" | column -n
}
find $1 -maxdepth 1 -mindepth 1 -type d -printf "%P\n" | sort | { while read line; do
lines="$lines $(devicons_get_directory_symbol $line) \n"
done
echo -en "$lines \n" | column -n
}