Skip to content

Commit 517e126

Browse files
committed
Ask to download a dircolors in every cases
Before, a warning was printed when a dircolors was found, and asked if the user wanted to download a solarized compatible one. Now, asks to download a dircolors even when none is already installed.
1 parent 24231fb commit 517e126

File tree

1 file changed

+41
-20
lines changed

1 file changed

+41
-20
lines changed

src/dircolors.sh

+41-20
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,15 @@ dl_dircolors() {
2323
copy_dicolors() {
2424
if [ "$1" != 1 ]
2525
then return
26-
elif [ -f "$DIRCOLORS_DIR/dircolors" ]
26+
else
2727
eval dl_dircolors
2828
dl_ok=$?
29-
then if [ $dl_ok ]
30-
then mv "$DIRCOLORS_DIR/dircolors" "$DIRCOLORS_DIR/dircolors.old"
31-
echo -e "$DIRCOLORS_DIR/dircolors already exists, renaming it to"
32-
echo "dircolors.old"
29+
if [ $dl_ok ]
30+
then if [ -f "$DIRCOLORS_DIR/dircolors" ]
31+
then mv "$DIRCOLORS_DIR/dircolors" "$DIRCOLORS_DIR/dircolors.old"
32+
echo -e "$DIRCOLORS_DIR/dircolors already exists, renaming it to"
33+
echo "dircolors.old"
34+
fi
3335
fi
3436
fi
3537
cp "$DIRCOLORS_SOLARIZED/dircolors" "$DIRCOLORS_DIR/dircolors"
@@ -45,23 +47,44 @@ copy_dicolors() {
4547
echo
4648
}
4749

50+
msg_create_dircolors() {
51+
echo -en "A dircolors adapted to solarized can be automatically "
52+
echo -en "downloaded.\n"
53+
echo
54+
echo -en "1) Download seebi' dircolors-solarized: "
55+
echo -en "https://github.com/seebi/dircolors-solarized\n"
56+
echo
57+
echo -en "2) [DEFAULT] I don't need any dircolors.\n"
58+
}
59+
60+
msg_already_existing_dircolors() {
61+
echo -en "A dircolors already exists in $DIRCOLORS_DIR, but can be "
62+
echo -en "incompatible with the solarized color scheme causing some colors "
63+
echo -en "problems when doing a \"ls\".\n"
64+
echo
65+
echo -en "1) Replace the actual dircolors by seebi' "
66+
echo -en "dircolors-solarized: "
67+
echo -en "https://github.com/seebi/dircolors-solarized (the actual "
68+
echo -en "dircolors will be keeped as backup).\n"
69+
echo
70+
echo -en "2) [DEFAULT] I am awared about this potentiall problem and will "
71+
echo -en "check my dircolors (default path: ~/.dir_colors/dircolors) "
72+
echo -en "in case of conflict.\n"
73+
}
74+
4875
interactive_dircolors() {
76+
already_existing_dircolors=$1
4977
noselect=true
5078
while $noselect
5179
do
5280
echo
53-
echo -en "A dircolors already exists, but can be incompatible with the "
54-
echo -en "solarized color scheme causing some colors problems when doing "
55-
echo -en "a \"ls\".\n"
56-
echo
57-
echo -en "1) Replace the actual dircolors by seebi' "
58-
echo -en "dircolors-solarized: "
59-
echo -en "https://github.com/seebi/dircolors-solarized (the actual "
60-
echo -en "dircolors will be keeped as backup).\n"
61-
echo
62-
echo -en "2) [DEFAULT] I am awared about this potentiall problem and will "
63-
echo -en "check my dircolors (default path: ~/.dir_colors/dircolors) "
64-
echo -en "in case of conflict.\n"
81+
82+
if $already_existing_dircolors
83+
then msg_already_existing_dircolors
84+
else
85+
msg_create_dircolors
86+
fi
87+
6588
echo
6689
read -p "Enter your choice : [2] " selection
6790
selection=${selection:-2}
@@ -82,9 +105,7 @@ check_dircolors() {
82105
if [ -d "$DIRCOLORS_DIR" ]
83106
then [ "$(ls -A $DIRCOLORS_DIR)" ] && nonempty=true || nonempty=false
84107
fi
85-
if [ $nonempty = true ]
86-
then interactive_dircolors
87-
fi
108+
interactive_dircolors $nonempty
88109
return $(! $nonempty)
89110
}
90111

0 commit comments

Comments
 (0)