-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall
More file actions
executable file
·182 lines (149 loc) · 5.3 KB
/
install
File metadata and controls
executable file
·182 lines (149 loc) · 5.3 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
#!/bin/bash
set -o nounset -o pipefail -o errexit
function check_cmd {
if ! which $1 > /dev/null; then
echo "Needs $1"
exit 5
fi
}
function install_tpm {
home="$1"
if ! [ -d $home/.tmux/plugins/tpm ]; then
mkdir -p $home/.tmux/plugins
git clone https://github.com/tmux-plugins/tpm $home/.tmux/plugins/tpm
fi
chown -R `basename $home`: $home/.tmux
}
function install_nvim {
if ! [ -d /opt/nvim-linux64 ]; then
curl -LO https://github.com/neovim/neovim/releases/latest/download/nvim-linux-x86_64.tar.gz
rm -rf /opt/nvim-linux64 /opt/nvim-linux-x86_64
tar -C /opt -xzf nvim-linux-x86_64.tar.gz
# To be compatible with the previous path. Should put this in /opt/nvim and update PATH in the rest of the repo
mv /opt/nvim-linux-x86_64 /opt/nvim-linux64
rm -f nvim-linux64.tar.gz
fi
}
function install_nvim_profile {
home="$1"
if ! [ -d $home/.config/nvim ]; then
mkdir -p $home/.config
git clone https://github.com/julsemaan/nvim-profile $home/.config/nvim
fi
cd $home/.config/nvim
git config --global --add safe.directory $home/.config/nvim
git pull
cd -
chown `basename $home`: $home/.config
chown -R `basename $home`: $home/.config/nvim
}
function install_complete_alias {
if [ -d /etc/bash_completion.d/ ]; then
echo "Installing complete_alias"
curl --fail https://raw.githubusercontent.com/cykerway/complete-alias/refs/heads/master/complete_alias > /etc/bash_completion.d/complete_alias 2>/dev/null
else
echo "Skipping complete_alias because /etc/bash_completion.d/ doesn't exist"
fi
}
function install_file {
src="$1"
dst="$2"
user="${3:-}"
echo "Installing $src in $dst"
cp -a $src $dst
if ! [ -z "$user" ]; then
chown -R $user: $dst
fi
}
check_cmd git
check_cmd make
check_cmd gawk
LOCAL_INSTALL=${LOCAL_INSTALL:-}
if [ -z "$LOCAL_INSTALL" ]; then
d=$(mktemp -d)
function finish {
rm -fr $d
}
trap finish EXIT
git clone https://github.com/julsemaan/profile $d
else
d=`pwd`
fi
install_complete_alias
install_file $d/profile/.bashrc_append /usr/local/etc/.bashrc_append
install_file $d/profile/.inputrc /usr/local/etc/.inputrc
install_file $d/profile/.tmux.conf /usr/local/etc/.tmux.conf
install_file $d/profile/.vimrc /usr/local/etc/.vimrc
install_file $d/profile/.gitignore /usr/local/etc/.gitignore
install_file $d/profile/.blerc /usr/local/etc/.blerc
install_file $d/profile/codex-unleashed-safely.sh /usr/local/bin/codex-unleashed-safely
chmod +x /usr/local/bin/codex-unleashed-safely
install_file $d/profile/opencode-unleashed-safely.sh /usr/local/bin/opencode-unleashed-safely
chmod +x /usr/local/bin/opencode-unleashed-safely
mkdir -p /usr/local/etc/opencode
install_file $d/opencode/opencode.json /usr/local/etc/opencode/opencode.json
mkdir -p /usr/local/etc/opencode/agent
install_file $d/opencode/agent/pr-review-critic.md /usr/local/etc/opencode/agent/pr-review-critic.md
rm -fr /usr/local/etc/tmuxifiers
install_file $d/tmuxifiers/ /usr/local/etc/tmuxifiers
install_nvim
if ! [ -f /etc/cron.d/jprofile ] || [ $(md5sum /etc/cron.d/jprofile $d/cron | awk '{print $1}' | uniq | wc -l) -ne 1 ]; then
if [ -d /etc/cron.d ]; then
install_file $d/cron /etc/cron.d/jprofile
else
echo "Skipping cron installation because /etc/cron.d doesn't exist"
fi
fi
VIMRC=""
if [ -f /etc/vimrc ]; then
VIMRC="/etc/vimrc"
elif [ -f /etc/vim/vimrc ]; then
VIMRC="/etc/vim/vimrc"
fi
if ! [ -z "$VIMRC" ]; then
if ! grep 'source /usr/local/etc/.vimrc' $VIMRC > /dev/null 2>&1 ; then
echo "Installing the sourcing of vimrc in vimrc"
echo 'source /usr/local/etc/.vimrc' >> $VIMRC
echo "" >> $VIMRC
fi
fi
git config --system core.excludesfile /usr/local/etc/.gitignore
homes=(/home/* /root /Users/*)
for home in "${homes[@]}"; do
if [ $home == "/home/*" ]; then
continue
fi
if (which dscl > /dev/null 2>&1 && dscl . list /Users | grep -v '^_' | grep `basename $home` >/dev/null) || grep ^`basename $home`: /etc/passwd >/dev/null; then
if [ -d "$home" ]; then
install_file /usr/local/etc/.tmux.conf $home/.tmux.conf `basename $home`
install_file /usr/local/etc/.inputrc $home/.inputrc `basename $home`
install_file /usr/local/etc/.blerc $home/.blerc `basename $home`
BASHRC="$home/.bashrc"
if ! grep 'source /usr/local/etc/.bashrc_append' $BASHRC > /dev/null 2>&1 ; then
echo "Installing the sourcing of bashrc_append in $BASHRC"
echo 'source /usr/local/etc/.bashrc_append' >> $BASHRC
echo "" >> $BASHRC
fi
install_tpm $home
install_nvim_profile $home
fi
fi
done
if ! [ -d /usr/local/etc/.tmuxifier ]; then
git clone https://github.com/jimeh/tmuxifier.git /usr/local/etc/.tmuxifier
fi
if ! [ -d /usr/local/etc/.vim/bundle/Vundle.vim ]; then
git clone https://github.com/VundleVim/Vundle.vim.git /usr/local/etc/.vim/bundle/Vundle.vim
fi
if ! [ -f /usr/local/etc/ble.sh/out/ble.sh ]; then
rm -fr /usr/local/etc/ble.sh
git clone --depth 1 --recursive https://github.com/akinomyoga/ble.sh.git /usr/local/etc/ble.sh
make -C /usr/local/etc/ble.sh
chmod a+rw /usr/local/etc/ble.sh/out/
fi
if ! [ -f /usr/local/etc/.fzf.bash ]; then
rm -fr /usr/local/etc/fzf
git clone --depth 1 https://github.com/junegunn/fzf.git /usr/local/etc/fzf
/usr/local/etc/fzf/install --all --no-update-rc
mv $HOME/.fzf.bash /usr/local/etc/.fzf.bash
fi