forked from briancain/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·116 lines (102 loc) · 2.8 KB
/
install.sh
File metadata and controls
executable file
·116 lines (102 loc) · 2.8 KB
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#! /bin/bash
# Brian Cain
#
# A simple bash script for setting up
# an Operating System with my dotfiles
# Function to determine package manager
function determine_package_manager() {
which yum > /dev/null && {
echo "yum"
export OSPACKMAN="yum"
return;
}
which apt-get > /dev/null && {
echo "apt-get"
export OSPACKMAN="aptget"
return;
}
which brew > /dev/null && {
echo "homebrew"
export OSPACKMAN="homebrew"
return;
}
}
# Adds a symbolic link to files in ~/.dotfiles
# to your home directory.
function symlink_files() {
ignoredfiles=(LICENSE readme.md install.sh get-omzsh.sh zsh-theme)
for f in $(ls -d *); do
if [[ ${ignoredfiles[@]} =~ $f ]]; then
echo "Skipping $f ..."
else
link_file $f
fi
done
}
# symlink a file
# arguments: filename
function link_file(){
echo "linking ~/.$1"
if ! $(ln -s "$PWD/$1" "$HOME/.$1"); then
echo "Replace file '~/.$1'?"
read -p "[Y/n]?: " Q_REPLACE_FILE
if [[ $Q_REPLACE_FILE != 'n' ]]; then
replace_file $1
fi
fi
}
# replace file
# arguments: filename
function replace_file() {
echo "replacing ~/.$1"
ln -sf "$PWD/$1" "$HOME/.$1"
}
function setup_git() {
echo 'Setting up git config...'
read -p 'Enter Github username: ' GIT_USER
git config --global user.name "$GIT_USER"
read -p 'Enter email: ' GIT_EMAIL
git config --global user.email $GIT_EMAIL
git config --global core.editor vim
git config --global color.ui true
git config --global color.diff auto
git config --global color.status auto
git config --global color.branch auto
# extras
git config --global alias.lg log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)%an%Creset' --abbrev-commit
}
echo "Setting up Operating System..."
set -e
(
determine_package_manager
# general package array
declare -a packages=('vim' 'git' 'tree' 'htop' 'wget' 'curl')
if [[ $OSPACKMAN == "homebrew" ]]; then
echo "Using Homebrew to install packages..."
brew update
declare -a macpackages=('findutils' 'macvim' 'the_silver_searcher')
brew install "${packages[@]}" "${macpackages[@]}"
elif [[ "$OSPACKMAN" == "yum" ]]; then
echo "Using yum to install packages...."
sudo yum install "${packages[@]}" zsh
elif [[ "$OSPACKMAN" == "aptget" ]]; then
echo "Using apt-get to install packages...."
sudo apt-get install "${packages[@]}" zsh
else
echo "Could not determine package manager. Exiting..."
exit 1
fi
echo "Installing oh-my-zsh"
source get-omzsh.sh
echo "Installing dotfiles"
symlink_files
echo "Installing vim vundles..."
vim +BundleInstall +qall
echo "Changing shells to ZSH"
chsh -s /bin/zsh
# clean up env vars
unset OSPACKMAN
echo "Operating System setup complete."
echo "Reloading session"
exec zsh
)