/
setup.sh
executable file
·127 lines (105 loc) · 3.71 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
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
#!/usr/bin/env bash
set -e
cd "$(dirname "$0")" || exit
_is_xdg() {
local _XDG_CONFIG_DIRS=${XDG_CONFIG_DIRS:-/etc/xdg:/foo/bar};
local OIFS="$IFS"
IFS=':'
local xdg_config_dirs=(${_XDG_CONFIG_DIRS});
IFS="$OIFS"
[[ -d ${xdg_config_dirs[0]} ]]
}
if _is_xdg ; then is_xdg=true ; else is_xdg=false ; fi
if [[ "$(uname)" == "Darwin" ]] ; then IS_OSX=true; else IS_OSX=false; fi
o() {
echo "$@"
"$@"
}
if $is_xdg ; then
: ${XDG_CONFIG_HOME:=$HOME/.config}
# Move this dir into XDG_CONFIG_HOME, and then symlink back to the old spot
if [[ "$PWD" != "$XDG_CONFIG_HOME/dotfiles" ]] ; then
echo "Moving dotfiles to \"$XDG_CONFIG_HOME/dotfiles\"..."
DIR="$PWD"
cd ..
mv "$DIR" "$XDG_CONFIG_HOME/dotfiles"
cd "$XDG_CONFIG_HOME/dotfiles"
ln -s "$XDG_CONFIG_HOME/dotfiles" "$DIR"
fi
fi
# TODO: use gnu stow
# http://brandon.invergo.net/news/2012-05-26-using-gnu-stow-to-manage-your-dotfiles.html?round=two
if ! type realpath >/dev/null ; then
if type grealpath >/dev/null ; then
realpath() { grealpath "$@"; }
else
realpath() { readlink -f "$@"; }
fi
fi
if ${USE_GNU_LN:-false} && type gln; then
ln() { gln "$@"; }
fi
o git submodule update --init
o ln -fs "$(realpath zshrc)" ~/.zshrc
o ln -fs "$(realpath zsh_history_interactive)" ~/.zsh_history_interactive
o mkdir -p ~/.config
o ./vim/setup.sh
o ln -fs "$(realpath jshintrc)" ~/.jshintrc
o ln -fs "$(realpath gitconfig)" ~/.gitconfig
o ln -fs "$(realpath gitignore)" ~/.gitignore
o ln -fs "$(realpath oglrc)" ~/.ogl
o ln -fs "$(realpath hgrc)" ~/.hgrc
o ln -fs "$(realpath nanorc)" ~/.nanorc
o ln -fs "$(realpath pythonhist)" ~/.pythonhist
o ln -fs -T "$(realpath plugins/direnv/config)" ~/.config/direnv
o mkdir -p ~/.config/glab-cli
o ln -fs "$(realpath plugins/glab/aliases.yml)" ~/.config/glab-cli/aliases.yml
o mkdir -p ~/.config/htop
o ln -fs "$(realpath htoprc)" ~/.config/htop/htoprc
o mkdir -p ~/.config/gh
o ln -fs "$(realpath gh/config.yml)" ~/.config/gh/config.yml
o ln -fs "$(realpath cargo)" ~/.cargo
o mkdir -p ~/.config/helix
o ln -fs "$(realpath helix/config.toml)" ~/.config/helix/config.toml
o ln -fs "$(realpath helix/themes)" ~/.config/helix/themes
o ln -fs "$(realpath ctop)" ~/.ctop
o ln -fs "$(realpath config/watchman.json)" ~/.config/watchman.json
o ln -fs "$(realpath colordiffrc)" ~/.colordiffrc
o ln -fs "$(realpath bash/bash_completion)" ~/.bash_completion
o ln -fs -T "$(realpath bash/bash_completion.d)" ~/.bash_completion.d
if $IS_OSX ; then
mkdir -p ~/.config/mackup
o ln -fs "$(realpath mackup.cfg)" ~/.mackup.cfg
mkdir -p ~/.config/yabai
o ln -fs "$(realpath config/yabairc)" ~/.config/yabai/yabairc
fi
# TODO: gnu stow or some other alternative to mackup for linux.
if [[ -n "$BABUN_HOME" ]]; then
BINPATH="$(cygpath "$HOMEPATH")/.local/bin"
o mkdir -p "$BINPATH"
if [[ ! -e "$BINPATH/recycle.exe" ]] ; then
o curl -OL http://www.maddogsw.com/cmdutils/cmdutils.zip
o unzip cmdutils.zip -d cmdutils
o cp cmdutils/Recycle.exe "$BINPATH/recycle.exe"
fi
fi
if type systemctl >/dev/null 2>/dev/null ; then
if ! type ssh-agent ; then
if type yum >/dev/null 2>/dev/null ; then
o sudo yum install openssh-askpass
else
echo please install ssh-agent
exit 1
fi
fi
o mkdir -p ~/.config/systemd/user
o cp ./systemd/ssh-agent.service ~/.config/systemd/user
o systemctl --user enable ssh-agent.service
o systemctl --user start ssh-agent.service
fi
if $is_xdg ; then
XDG_AUTOSTART_DIR="${XDG_CONFIG_HOME/autostart}"
o mkdir -p "${XDG_AUTOSTART_DIR}"
o ln -fs "$(realpath autostart/redshift.desktop)" "${XDG_AUTOSTART_DIR}/autostart/redshift.desktop"
o ln -fs "$(realpath autostart/synclient.desktop)" "${XDG_AUTOSTART_DIR}/autostart/synclient.desktop"
fi