forked from sirthias/BlueForest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
updateOrDeploy.sh
executable file
·89 lines (83 loc) · 2.21 KB
/
updateOrDeploy.sh
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
#!/bin/bash
# updateOrDeploy.sh - updates or deploys the BlueForest.xml.
#
# Copies the BlueForest.xml from/to the current users IntelliJ config
# colors directory.
#
# Works for MacOSX, Linux and windows (using cygwin/mingw)
#
# Set "mode" environment variable to "update" to update, otherwise
# deploy is assumed.
# set up possible directory locations
export dirs
# mac locations
if [ -d ~/Library ]
then
dirs+=" $HOME/Library/Preferences/IntelliJIdea"
dirs+=" $HOME/Library/Preferences/IdeaIC"
fi
# linux locations
if [ -d ~ ]
then
dirs+=" $HOME/.IntelliJIdea"
dirs+=" $HOME/.IdeaIC"
dirs+=" $HOME/.IdeaIC14"
dirs+=" $HOME/.IdeaIC15"
fi
# cygwin locations
if [ ! -z $USERPROFILE ]
then
dirs+=" $USERPROFILE/.IntelliJIdea"
dirs+=" $USERPROFILE/.IdeaIC"
fi
function copy_color_file {
if [ "$mode" = "update" ]
then
echo "Copying BlueForest.{xml, icls} from $1 to $PWD"
cp -i $1/BlueForest.xml $1/BlueForest.icls .
else
echo "Copying BlueForest.{xml, icls} to $1"
cp -i BlueForest.xml BlueForest.icls $1
fi
lastInstallDir=$1
}
# potential directories picked, check for different versions,
# copy to all matches, stale preference structures may exist
for dirName in $dirs
do
typeset old_ifs=$IFS
#IFS=$'\n'
typeset only_dir=${dirName%/*}
typeset only_name=${dirName##*/}
if [[ -e "${only_dir}" ]]
then
for baseDir in $(find ${only_dir} -maxdepth 1 -type d -name "${only_name}[0-9]*")
do
configDir="${baseDir}/config"
colorDir="${configDir}/colors"
dir="${baseDir}/colors"
if [ -e "$colorDir" ]
then
echo $colorDir
copy_color_file $colorDir
elif [ -e "$dir" ]
then
echo $dir
copy_color_file $dir
elif [ -e "$configDir" ]
then
# creating new empty color directory
mkdir $colorDir
echo $colorDir
copy_color_file $colorDir
fi
done
fi
IFS=$old_ifs
done
# No IntelliJ found, exit
if [ -z $lastInstallDir ]
then
echo "IntelliJ directory was not found"
exit 1
fi