-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathsetup-startup-scripts.bash
More file actions
executable file
·93 lines (81 loc) · 3.9 KB
/
Copy pathsetup-startup-scripts.bash
File metadata and controls
executable file
·93 lines (81 loc) · 3.9 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
#!/usr/bin/env bash
echo "This script will set up the following files:
* Shells: zshrc, zshenv, login
* Editors: vimrc, vim directory
* Version Control: hgrc, gitconfig
This script does NOT set up any of the following:
* eclim, eclimrc
* gitignore
The vim directory will be symlinked; the others will import the files in the
config folder. That means that you just need to git push and git pull to make
changes.
If you want computer-specific settings (for instance, if you need a command to
behave differently on your work machine versus on your personal machine), put
the common things in the repository and leave per-machine things in your actual
dot files.
Note that some things in each file should be customized. To find a list of
those places, run the following command:
grep -n CUSTOMIZE *
Also note that gitignore and eclimrc don't support includes, so you'll need to
manually copy them.
For the sake of visibility, none of these are dot files. However, in your home
folder, they must be dot files.
"
# For instructions on how to do a confirmation like this, see
# http://stackoverflow.com/questions/1885525/how-do-i-prompt-a-user-for-confirmation-in-bash-script
read -r -p "This should just add a line to your files, but it could cause
unintended consequences. Are you sure you want to continue? [Y/n] " response
response=`echo $response | tr '[:upper:]' '[:lower:]'` # convert to lowercase; support old Bash
if [[ $response == y || $response == yes ]]; then
# Get the path of the config directory, which is the same as the directory
# from which this script was executed. From
# http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in
pushd `dirname $0` > /dev/null
CONFIG_PATH=`pwd`
popd > /dev/null
# TODO: tell the user what commands we're running as we run them. Tell the
# user when we're done.
# Append the command to source the relevant files in this repo to the actual
# dot files. Only add the line if the line doesn't already exist
if [ \( -z "`grep -s "source $CONFIG_PATH/zshrc" $HOME/.zshrc`" \) ]; then
echo "source $CONFIG_PATH/zshrc" >> $HOME/.zshrc
fi
if [ \( -z "`grep -s "source $CONFIG_PATH/zshenv" $HOME/.zshenv`" \) ]; then
echo "source $CONFIG_PATH/zshenv" >> $HOME/.zshenv
fi
if [ \( -z "`grep -s "source $CONFIG_PATH/vimrc" $HOME/.vimrc`" \) ]; then
echo "source $CONFIG_PATH/vimrc" >> $HOME/.vimrc
fi
if [ \( -z "`grep -s "%include $CONFIG_PATH/hgrc" $HOME/.hgrc`" \) ]; then
echo "%include $CONFIG_PATH/hgrc" >> $HOME/.hgrc
fi
if [ \( -z "`grep -s "source $CONFIG_PATH/login" $HOME/.login`" \) ]; then
echo "source $CONFIG_PATH/login" >> $HOME/.login
fi
if [ \( -z "`grep -s "$CONFIG_PATH/gitconfig" $HOME/.gitconfig`" \) ]; then
echo -e "[include]\n path = $CONFIG_PATH/gitconfig" >> $HOME/.gitconfig
fi
if [ \( -z "`grep -s "$CONFIG_PATH/screenrc" $HOME/.screenrc`" \) ]; then
echo -e "source $CONFIG_PATH/screenrc" >> $HOME/.screenrc
fi
# TODO: add option to copy over files even if there isn't an include directive
# Creates a symbolic link to the vim folder where backups, temp files,
# plugins, and other stuff is stored.
# If ~/.vim doesn't exist
if [ ! \( -d $HOME/.vim -o -L $HOME/.vim \) ]; then
ln -s $CONFIG_PATH/vim $HOME/.vim
# If we don't link to .vim, we still want the vimrc-etc folder to be linked.
# If ~/.vim/vimrc-etc doesn't exist
elif [ ! \( -d $HOME/.vim/vimrc-etc -o -L $HOME/.vim/vimrc-etc \) ]; then
ln -s $CONFIG_PATH/vim/vimrc-etc $HOME/.vim/vimrc-etc
fi
# Set up Vundle
if [[ ! -e $HOME/.vim/bundle/Vundle.vim ]]; then
git clone https://github.com/VundleVim/Vundle.vim.git $HOME/.vim/bundle/Vundle.vim
vim "+:PluginInstall" "+:q" "+:q"
fi
# Setup Solarized ls colors
if [[ ! -e $HOME/config-files/dircolors-solarized/dircolors.ansi-dark ]]; then
git clone https://github.com/seebi/dircolors-solarized $CONFIG_PATH/dircolors-solarized
fi
fi