Commit dfa9fbfd1c9ddf4e5bc42543d438485e845b4d97
1 parent
99ac89e01a
Exists in
master
auto download sublime package manager
Showing 1 changed file with 2 additions and 0 deletions Inline Diff
link.sh
View file @
dfa9fbf
#!/usr/bin/env bash | 1 | 1 | #!/usr/bin/env bash | |
2 | 2 | |||
# the dir this script is in | 3 | 3 | # the dir this script is in | |
cwd="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | 4 | 4 | cwd="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | |
5 | 5 | |||
#helper functions | 6 | 6 | #helper functions | |
function link { | 7 | 7 | function link { | |
target=$1 | 8 | 8 | target=$1 | |
src=$2 | 9 | 9 | src=$2 | |
if [ -L $src ]; | 10 | 10 | if [ -L $src ]; | |
then | 11 | 11 | then | |
rm $src | 12 | 12 | rm $src | |
fi | 13 | 13 | fi | |
mkdir -p `dirname $src` | 14 | 14 | mkdir -p `dirname $src` | |
echo "Creating symlink for $src" | 15 | 15 | echo "Creating symlink for $src" | |
ln -sf $target $src | 16 | 16 | ln -sf $target $src | |
} | 17 | 17 | } | |
18 | 18 | |||
function downloadSubmodules { | 19 | 19 | function downloadSubmodules { | |
dir=$1 | 20 | 20 | dir=$1 | |
if [ -e $dir/submodules ]; | 21 | 21 | if [ -e $dir/submodules ]; | |
then | 22 | 22 | then | |
while read l; | 23 | 23 | while read l; | |
do | 24 | 24 | do | |
if [ -n "$l" ]; | 25 | 25 | if [ -n "$l" ]; | |
then | 26 | 26 | then | |
read -a array <<< $l | 27 | 27 | read -a array <<< $l | |
if [ ! -e $dir/${array[1]} ]; | 28 | 28 | if [ ! -e $dir/${array[1]} ]; | |
then | 29 | 29 | then | |
git clone ${array[0]} $dir/${array[1]} | 30 | 30 | git clone ${array[0]} $dir/${array[1]} | |
else | 31 | 31 | else | |
echo "Updating git repo ${array[1]}" | 32 | 32 | echo "Updating git repo ${array[1]}" | |
git --git-dir=$dir/${array[1]}/.git pull | 33 | 33 | git --git-dir=$dir/${array[1]}/.git pull | |
fi | 34 | 34 | fi | |
fi | 35 | 35 | fi | |
done < $dir/submodules | 36 | 36 | done < $dir/submodules | |
fi | 37 | 37 | fi | |
} | 38 | 38 | } | |
39 | 39 | |||
40 | 40 | |||
#config functions | 41 | 41 | #config functions | |
function vim { | 42 | 42 | function vim { | |
echo "Linking vim" | 43 | 43 | echo "Linking vim" | |
downloadSubmodules $cwd/vim | 44 | 44 | downloadSubmodules $cwd/vim | |
link $cwd/vim/vimrc ~/.vimrc | 45 | 45 | link $cwd/vim/vimrc ~/.vimrc | |
link $cwd/vim/vim ~/.vim | 46 | 46 | link $cwd/vim/vim ~/.vim | |
} | 47 | 47 | } | |
48 | 48 | |||
function conky { | 49 | 49 | function conky { | |
echo "Linking conky" | 50 | 50 | echo "Linking conky" | |
link $cwd/conky/conkyrc ~/.conkyrc | 51 | 51 | link $cwd/conky/conkyrc ~/.conkyrc | |
} | 52 | 52 | } | |
53 | 53 | |||
#can not be called git, conflicts with download submodules | 54 | 54 | #can not be called git, conflicts with download submodules | |
function git_config { | 55 | 55 | function git_config { | |
echo "Linking git" | 56 | 56 | echo "Linking git" | |
for file in $(ls $cwd/git); | 57 | 57 | for file in $(ls $cwd/git); | |
do | 58 | 58 | do | |
link $cwd/git/$file ~/.$file | 59 | 59 | link $cwd/git/$file ~/.$file | |
done | 60 | 60 | done | |
} | 61 | 61 | } | |
62 | 62 | |||
function shell { | 63 | 63 | function shell { | |
echo "Linking shell" | 64 | 64 | echo "Linking shell" | |
for file in $(ls $cwd/shell); | 65 | 65 | for file in $(ls $cwd/shell); | |
do | 66 | 66 | do | |
link $cwd/shell/$file ~/.$file | 67 | 67 | link $cwd/shell/$file ~/.$file | |
done | 68 | 68 | done | |
} | 69 | 69 | } | |
70 | 70 | |||
function tmux { | 71 | 71 | function tmux { | |
echo "Linking tmux" | 72 | 72 | echo "Linking tmux" | |
link $cwd/tmux/tmux.conf ~/.tmux.conf | 73 | 73 | link $cwd/tmux/tmux.conf ~/.tmux.conf | |
} | 74 | 74 | } | |
75 | 75 | |||
function xscreensaver { | 76 | 76 | function xscreensaver { | |
echo "Linking xscreensaver" | 77 | 77 | echo "Linking xscreensaver" | |
link $cwd/xscreensaver/xscreensaver ~/.xscreensaver | 78 | 78 | link $cwd/xscreensaver/xscreensaver ~/.xscreensaver | |
} | 79 | 79 | } | |
80 | 80 | |||
function awesome { | 81 | 81 | function awesome { | |
echo "Linking awesome" | 82 | 82 | echo "Linking awesome" | |
downloadSubmodules $cwd/awesome | 83 | 83 | downloadSubmodules $cwd/awesome | |
link $cwd/awesome/awesome ~/.config/awesome | 84 | 84 | link $cwd/awesome/awesome ~/.config/awesome | |
} | 85 | 85 | } | |
86 | 86 | |||
function openbox { | 87 | 87 | function openbox { | |
echo "Linking openbox" | 88 | 88 | echo "Linking openbox" | |
link $cwd/openbox/openbox ~/.config/openbox | 89 | 89 | link $cwd/openbox/openbox ~/.config/openbox | |
} | 90 | 90 | } | |
91 | 91 | |||
function terminator { | 92 | 92 | function terminator { | |
echo "Linking terminator" | 93 | 93 | echo "Linking terminator" | |
link $cwd/terminator/terminator ~/.config/terminator | 94 | 94 | link $cwd/terminator/terminator ~/.config/terminator | |
} | 95 | 95 | } | |
96 | 96 | |||
function tint2 { | 97 | 97 | function tint2 { | |
echo "Linking tint2" | 98 | 98 | echo "Linking tint2" | |
link $cwd/tint2/tint2 ~/.config/tint2 | 99 | 99 | link $cwd/tint2/tint2 ~/.config/tint2 | |
} | 100 | 100 | } | |
101 | 101 | |||
function sublime { | 102 | 102 | function sublime { | |
echo "Linking Sublime Text" | 103 | 103 | echo "Linking Sublime Text" | |
link $cwd/sublime-text-3/User ~/.config/sublime-text-3/Packages/User | 104 | 104 | link $cwd/sublime-text-3/User ~/.config/sublime-text-3/Packages/User | |
105 | echo "Downloading Package Manager PLugin" | |||
106 | wget -P ~/.config/sublime-text-3/Installed\ Packages/ https://sublime.wbond.net/Package%20Control.sublime-package | |||
} | 105 | 107 | } | |
106 | 108 | |||
function scripts { | 107 | 109 | function scripts { | |
#DO NOTHING | 108 | 110 | #DO NOTHING | |
echo "Skipping scripts" | 109 | 111 | echo "Skipping scripts" | |
} | 110 | 112 | } | |
111 | 113 | |||
function run { | 112 | 114 | function run { | |
if [ $1 == "git" ]; | 113 | 115 | if [ $1 == "git" ]; | |
then | 114 | 116 | then | |
c="git_config" | 115 | 117 | c="git_config" | |
elif [ $1 == "sublime-text-3" ]; | 116 | 118 | elif [ $1 == "sublime-text-3" ]; | |
then | 117 | 119 | then | |
c="sublime" | 118 | 120 | c="sublime" | |
else | 119 | 121 | else | |
c=$1 | 120 | 122 | c=$1 | |
fi | 121 | 123 | fi | |
eval ${c} | 122 | 124 | eval ${c} | |
} | 123 | 125 | } | |
124 | 126 |