-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-config.sh
executable file
·135 lines (111 loc) · 3.79 KB
/
install-config.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
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/bin/bash
#
# Create symlinks that point to these configuration files from the
# expected locations
#
set -euo pipefail
# the directory that contains all setup files
CONFIG_DIR="$HOME/config"
OVERWRITE_EXISTING_FILES="YES"
# helper functions
# usage is similar to cp or ln:
# install-config foo bar/baz
#
# creates a link to foo at bar/baz. Creates bar if not present.
# DELETES baz if present and replaces it with a link to foo.
#
# $1 the source file
# $2 the destination
function install-config()
{
local SOURCE="$1"
local TARGET="$2"
if [ ! -e "$SOURCE" ] ; then
echo "warning: $SOURCE" does not exist
return
fi
local TARGET_DIR
TARGET_DIR=$(dirname "$TARGET")
if [ ! -d "$TARGET_DIR" ] ; then
mkdir -p "$TARGET_DIR"
fi
if [ ! -d "$TARGET_DIR" ] ; then
echo dir "$TARGET_DIR" does not exit and could not be created
exit 1
fi
if [ -e "$TARGET" ] && [ "$OVERWRITE_EXISTING_FILES" != "YES" ] ; then
echo "$TARGET" exists
exit 1
fi
if [ -e "$TARGET" ] ; then
echo "deleteing old $TARGET"
rm -f "$TARGET"
fi
if [ -e "$TARGET" ] ; then
echo "error: unable to delete $TARGET"
exit 1
fi
echo symlinking "$TARGET" to "$SOURCE"
ln -s "$SOURCE" "$TARGET"
}
if [ "$OVERWRITE_EXISTING_FILES" == "YES" ] ; then
echo "warning: may overwrite existing files. press ctrl-d to exit now"
read || exit
fi
if [ ! -d "$CONFIG_DIR" ] ; then
echo "CONFIG_DIR (\"$CONFIG_DIR\") not found"
fi
# basics
install-config "$CONFIG_DIR"/bash.d/bashrc ~/.bashrc
install-config "$CONFIG_DIR"/dir-colors ~/.dir_colors
install-config "$CONFIG_DIR"/tmux.conf ~/.tmux.conf
install-config "$CONFIG_DIR"/gitconfig ~/.gitconfig
# X
install-config "$CONFIG_DIR"/x-modmap ~/.Xmodmap
# editors: vim
mkdir -p ~/.vim
install-config "$CONFIG_DIR"/vim.d/vimrc ~/.vimrc
install-config "$CONFIG_DIR"/vim.d/vim-colors-solarized/colors/solarized.vim ~/.vim/colors/solarized.vim
# editors: emacs
mkdir -p ~/.emacs.d
install-config "$CONFIG_DIR"/emacs.d/init.el ~/.emacs.d/init.el
install-config "$CONFIG_DIR"/emacs.d/snippets ~/.emacs.d/snippets
install-config "$CONFIG_DIR"/emacs.d/lisp ~/.emacs.d/lisp
# custom folder names
install-config "$CONFIG_DIR"/user-dirs ~/.config/user-dirs.dirs
# terminals
install-config "$CONFIG_DIR"/Xresources ~/.Xresources
# mutt
mkdir -p ~/.mutt
install-config "$CONFIG_DIR"/mutt.d/muttrc ~/.mutt/muttrc
install-config "$CONFIG_DIR"/mutt.d/color-solarized-dark ~/.mutt/color-solarized-dark
install-config "$CONFIG_DIR"/mutt.d/mailcap ~/.mutt/mailcap
# irssi
mkdir -p ~/.irssi
install-config "$CONFIG_DIR"/irssi.d/irssi-colors-solarized/solarized-universal.theme ~/.irssi/solarized-universal.theme
install-config "$CONFIG_DIR"/irssi.d/config ~/.irssi/config
# awesome
mkdir -p ~/.config/awesome
install-config "$CONFIG_DIR"/awesome.d/rc.lua ~/.config/awesome/rc.lua
install-config "$CONFIG_DIR"/awesome.d/awesome-solarized ~/.config/awesome/themes/awesome-solarized
# omnisharp
install-config "$CONFIG_DIR"/omnisharp.d ~/.omnisharp
# firefox
install-config "$CONFIG_DIR"/vimperatorrc ~/.vimperatorrc
# gdb
install-config "$CONFIG_DIR"/gdbinit ~/.gdbinit
# dictionary
install-config "$CONFIG_DIR"/dictionary ~/.hunspell_en_US
install-config "$CONFIG_DIR"/dictionary ~/.hunspell_en_CA
# mbsync
# mbsyncrc is a work-specific configuration
echo "Please run:"
echo sudo cp [email protected] [email protected] /etc/systemd/system/
echo sudo systemctl enable [email protected]
# keybindings
# Free up calcualtor key, will need to rebind it to emacs manually
gsettings set org.gnome.settings-daemon.plugins.media-keys calculator "['']"
gsettings set org.gnome.settings-daemon.plugins.media-keys calculator-static "['']"
if [[ -d "${HOME}/config-work" ]]; then
"${HOME}"/config-work/install-config.sh
fi