-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpretty_clear_tool.sh
More file actions
executable file
·137 lines (97 loc) · 2.01 KB
/
Copy pathpretty_clear_tool.sh
File metadata and controls
executable file
·137 lines (97 loc) · 2.01 KB
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
# /+====================+\
# || Pretty clear ! ||
# \+====================+/
#
# Clear the screen and add a header at the top
# Header that you can customise with options
#
#
# By default, it does :
# - Clean the console
# - put a ls -l as header at the top
#
#
# There are optional arguments :
#
# - -l : a lighter header
# - -a : a heavier header with more informations, takes priority over -l
# - -m : execute a make after the pretty clear, when working in C/C++ for example
# - -g : show you the branches and status of the current git repository
#
#--------------------------------------------------------------------------------
#
# Made by :
# - Gély léandre :: https://github.com/Zaynn-lea
#
# Date :
# started : 06 / 11 / 24
# last updated : 13 / 05 / 25
#!/bin/bash
# Options variables
is_all=0
is_light=0
has_git=0
has_make=0
# Parser to take care of the parameters
# takes care of multi-char options, single-char options and standards parameters, in this order
# I had to do the parcer myself since I wasn't able to do it using getopts
for arg in "$@"
do
if [[ ${arg:0:1} = '-' ]]
then
for (( i=1 ; i<${#arg} ; i++ ))
do
case ${arg:$i:1} in
(a) is_all=1 ;;
(l) is_light=1 ;;
(g) has_git=1 ;;
(m) has_make=1 ;;
esac
done
fi
done
# +------------------+
# | Main script : |
# +------------------+
ls_options='-lh'
if [[ $is_light -eq 1 ]]
then
ls_options=''
fi
if [[ $is_all -eq 1 ]]
then
ls_options='-ahilF'
fi
clear
echo ""
max_line_length=$(( $(ls ${ls_options} | sed -e 's/.*/|| &\t/g' | wc -L) - 2 ))
line=''
for (( i=0 ; i<${max_line_length} ; i++ ))
do
line='-'${line}
done
if [[ $is_all -eq 1 ]]
then
echo -e $(tty)'\t\t'${USER}
fi
if [[ $is_light -eq 1 && $is_all -ne 1 ]]
then
ls ${ls_options} --color=always
else
echo "++"${line}
ls ${ls_options} --color=always | sed -e 's/.*/|| &/g'
echo "++"${line}
fi
if [[ $has_git -eq 1 ]]
then
echo ''
git branch
git status
fi
if [[ $has_make -eq 1 ]]
then
echo ''
make
fi
echo ""
exit 0