Skip to content

Commit

Permalink
Add a non-interactive install of dircolors
Browse files Browse the repository at this point in the history
--install-dircolors to install dircolors without any question
--skip-dircolors will skip the dircolors install

Also valid for set_{dark,light}.sh
  • Loading branch information
aruhier committed Oct 11, 2016
1 parent 517e126 commit bc87d17
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 18 deletions.
17 changes: 16 additions & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ show_help() {
echo " Color scheme to be used (will be asked otherwise)"
echo " -p profile, --profile profile, --profile profile"
echo " Gnome Terminal profile to overwrite (will be asked otherwise)"
echo " --install-dircolors, --skip-dircolors"
echo " Do or skip the dircolors installation in a non interactive mode"
}

validate_scheme() {
Expand Down Expand Up @@ -145,6 +147,12 @@ do
profile=$2
shift
;;
--install-dircolors )
install_dircolors=true
;;
--skip-dircolors )
install_dircolors=false
;;
esac
shift
done
Expand Down Expand Up @@ -174,4 +182,11 @@ else
fi

set_profile_colors $profile $scheme
check_dircolors || warning_message_dircolors

if [ -n "$install_dircolors" ]
then if "$install_dircolors"
then copy_dircolors
fi
else
check_dircolors || warning_message_dircolors
fi
2 changes: 1 addition & 1 deletion set_dark.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash

dir=`dirname "$0"`
source $dir/src/set_theme_default_profile.sh dark $1
source $dir/src/set_theme_default_profile.sh dark $*
2 changes: 1 addition & 1 deletion set_light.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash

dir=`dirname "$0"`
source $dir/src/set_theme_default_profile.sh light $1
source $dir/src/set_theme_default_profile.sh light $*
29 changes: 15 additions & 14 deletions src/dircolors.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,19 @@ dl_dircolors() {
return 0
}

copy_dicolors() {
if [ "$1" != 1 ]
then return
else
eval dl_dircolors
dl_ok=$?
if [ $dl_ok ]
then if [ -f "$DIRCOLORS_DIR/dircolors" ]
then mv "$DIRCOLORS_DIR/dircolors" "$DIRCOLORS_DIR/dircolors.old"
echo -e "$DIRCOLORS_DIR/dircolors already exists, renaming it to"
echo "dircolors.old"
fi
copy_dircolors() {
eval dl_dircolors
dl_ok=$?
if [ $dl_ok ]
then if [ -f "$DIRCOLORS_DIR/dircolors" ]
then mv "$DIRCOLORS_DIR/dircolors" "$DIRCOLORS_DIR/dircolors.old"
echo -e "$DIRCOLORS_DIR/dircolors already exists, renaming it to"
echo "dircolors.old"
fi
fi

cp "$DIRCOLORS_SOLARIZED/dircolors" "$DIRCOLORS_DIR/dircolors"

echo
echo "The new dircolors have been installed to $DIRCOLORS_DIR/dircolors."
echo
Expand Down Expand Up @@ -89,15 +87,18 @@ interactive_dircolors() {
read -p "Enter your choice : [2] " selection
selection=${selection:-2}

if [ "$selection" -gt 2 -o "$selection" -lt 1 ]
if [[ "$selection" -gt 2 || "$selection" -lt 1 ]]
then echo "$selection is not a valid entry. Please Restart"
echo
noselect=true
else
noselect=false
fi
done
copy_dicolors $selection

if [ "$selection" == 1 ]
then copy_dircolors
fi
}

check_dircolors() {
Expand Down
4 changes: 3 additions & 1 deletion src/set_theme_default_profile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@ get_default_profile() {
echo $profile_name
}

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

0 comments on commit bc87d17

Please sign in to comment.