Skip to content

Commit bc87d17

Browse files
committed
Add a non-interactive install of dircolors
--install-dircolors to install dircolors without any question --skip-dircolors will skip the dircolors install Also valid for set_{dark,light}.sh
1 parent 517e126 commit bc87d17

5 files changed

+36
-18
lines changed

install.sh

+16-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ show_help() {
1818
echo " Color scheme to be used (will be asked otherwise)"
1919
echo " -p profile, --profile profile, --profile profile"
2020
echo " Gnome Terminal profile to overwrite (will be asked otherwise)"
21+
echo " --install-dircolors, --skip-dircolors"
22+
echo " Do or skip the dircolors installation in a non interactive mode"
2123
}
2224

2325
validate_scheme() {
@@ -145,6 +147,12 @@ do
145147
profile=$2
146148
shift
147149
;;
150+
--install-dircolors )
151+
install_dircolors=true
152+
;;
153+
--skip-dircolors )
154+
install_dircolors=false
155+
;;
148156
esac
149157
shift
150158
done
@@ -174,4 +182,11 @@ else
174182
fi
175183

176184
set_profile_colors $profile $scheme
177-
check_dircolors || warning_message_dircolors
185+
186+
if [ -n "$install_dircolors" ]
187+
then if "$install_dircolors"
188+
then copy_dircolors
189+
fi
190+
else
191+
check_dircolors || warning_message_dircolors
192+
fi

set_dark.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env bash
22

33
dir=`dirname "$0"`
4-
source $dir/src/set_theme_default_profile.sh dark $1
4+
source $dir/src/set_theme_default_profile.sh dark $*

set_light.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env bash
22

33
dir=`dirname "$0"`
4-
source $dir/src/set_theme_default_profile.sh light $1
4+
source $dir/src/set_theme_default_profile.sh light $*

src/dircolors.sh

+15-14
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,19 @@ dl_dircolors() {
2020
return 0
2121
}
2222

23-
copy_dicolors() {
24-
if [ "$1" != 1 ]
25-
then return
26-
else
27-
eval dl_dircolors
28-
dl_ok=$?
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
23+
copy_dircolors() {
24+
eval dl_dircolors
25+
dl_ok=$?
26+
if [ $dl_ok ]
27+
then if [ -f "$DIRCOLORS_DIR/dircolors" ]
28+
then mv "$DIRCOLORS_DIR/dircolors" "$DIRCOLORS_DIR/dircolors.old"
29+
echo -e "$DIRCOLORS_DIR/dircolors already exists, renaming it to"
30+
echo "dircolors.old"
3531
fi
3632
fi
33+
3734
cp "$DIRCOLORS_SOLARIZED/dircolors" "$DIRCOLORS_DIR/dircolors"
35+
3836
echo
3937
echo "The new dircolors have been installed to $DIRCOLORS_DIR/dircolors."
4038
echo
@@ -89,15 +87,18 @@ interactive_dircolors() {
8987
read -p "Enter your choice : [2] " selection
9088
selection=${selection:-2}
9189

92-
if [ "$selection" -gt 2 -o "$selection" -lt 1 ]
90+
if [[ "$selection" -gt 2 || "$selection" -lt 1 ]]
9391
then echo "$selection is not a valid entry. Please Restart"
9492
echo
9593
noselect=true
9694
else
9795
noselect=false
9896
fi
9997
done
100-
copy_dicolors $selection
98+
99+
if [ "$selection" == 1 ]
100+
then copy_dircolors
101+
fi
101102
}
102103

103104
check_dircolors() {

src/set_theme_default_profile.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,7 @@ get_default_profile() {
1616
echo $profile_name
1717
}
1818

19+
SCHEME=$1
1920
PROFILE=${2:-"$(get_default_profile)"}
20-
$dir/install.sh -s $1 -p "$PROFILE"
21+
shift; shift
22+
$dir/install.sh -s "$SCHEME" -p "$PROFILE" $*

0 commit comments

Comments
 (0)