forked from deanrather/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
executable file
·58 lines (48 loc) · 1.94 KB
/
setup.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
#!/bin/bash
# setup.sh
# sets up dotfiles.sh to auto-load with the terminal
# TODO: better description
# Install packages
packages="$(cat ~/dotfiles/packages.txt)"
if apt-cache policy $packages | grep 'Installed: (none)' > /dev/null
then
echo "Installing:"
echo "$packages"
sudo apt-get update
sudo apt-get install -y $packages
fi
# Configure Git
if [ -z "$(git config --global user.name)" ]
then
echo -n "Git user name (The name to appear on your commits): "
read git_user_name
git config --global user.name "$git_user_name"
fi
if [ -z "$(git config --global user.email)" ]
then
echo -n "Git user email (The email to appear on your commits): "
read git_user_email
git config --global user.email "$git_user_email"
fi
git config --global include.path ~/dotfiles/git.conf
# Symlink config files
echo "Symlinking config files"
source ~/dotfiles/functions.sh
backup_remove ~/.tigrc && ln -s ~/dotfiles/tig.conf ~/.tigrc
backup_remove ~/.vimrc && ln -s ~/dotfiles/vim.conf ~/.vimrc
backup_remove ~/.tmux.conf && ln -s ~/dotfiles/tmux.conf ~/.tmux.conf
# Setup & symlink autoloads
echo "Making ~/.dotfiles-autolod dir, symlinking aliases and functions"
[ -d ~/dotfiles-autoload ] || mkdir ~/dotfiles-autoload
[ -e ~/dotfiles-autoload/functions.sh ] || ln -s ~/dotfiles/functions.sh ~/dotfiles-autoload/functions.sh
[ -e ~/dotfiles-autoload/aliases.sh ] || ln -s ~/dotfiles/aliases.sh ~/dotfiles-autoload/aliases.sh
[ -e ~/dotfiles-autoload/prompt.sh ] || ln -s ~/dotfiles/prompt.sh ~/dotfiles-autoload/prompt.sh
[ -e ~/dotfiles-autoload/banner.sh ] || ln -s ~/dotfiles/banner.sh ~/dotfiles-autoload/banner.sh
# Setup dotfiles to autoload
echo "Configuring Profile"
grep -q "dotfiles.sh" ~/.bashrc || echo -e "\n[ -f ~/dotfiles/dotfiles.sh ] && . ~/dotfiles/dotfiles.sh" >> ~/.bashrc
# Done!
echo "$(git config --global user.name) configured"
echo -en "see:\n\tdotfiles help\n\n"
# Reload profile
source ~/.profile