-
Notifications
You must be signed in to change notification settings - Fork 5
/
_install.sh
executable file
·159 lines (146 loc) · 3.56 KB
/
_install.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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#!/bin/sh
set -eu
. ./shared.sh
check_for_bash() {
printf "Checking if Bash..."
if [ "${BASH_VERSION:-}" ]; then
export HAS_BASH=1
echo "yes, $BASH_VERSION"
else
export HAS_BASH=
echo "no"
fi
}
check_os() {
printf "Detecting OS..."
case "$(uname)" in
"Darwin")
export OS=macOS
;;
"Linux")
export OS=Linux
case "$(cat /etc/os-release)" in
*elementary*)
export OS="$OS elementary"
;;
*Ubuntu*)
export OS="$OS Ubuntu"
;;
*Alpine*)
export OS="$OS Alpine"
;;
esac
;;
esac
echo "$OS"
}
check_root() {
if [ "$(id -u)" -eq 0 ]; then
export IS_ROOT=1
else
export IS_ROOT=
fi
}
install_stderred() {
git submodule update --init stderred
dil="${DYLD_INSERT_LIBRARIES:-}"
ld_preload="${LD_PRELOAD:-}"
unset DYLD_INSERT_LIBRARIES
unset LD_PRELOAD
set -x
cd stderred
if [ "$OS" = "macOS" ]; then
export PATH="/opt/local/bin/:$PATH"
make clean && CMAKE_OSX_ARCHITECTURES="x86_64;arm64;arm64e" make
else
make clean && make
fi
cd ..
{ set +x; } 2>/dev/null
export DYLD_INSERT_LIBRARIES="$dil"
export LD_PRELOAD="$ld_preload"
}
install_fixnano() {
case "$OS" in
"macOS")
extension=dylib
undefined_flags="-Wl,-U,_program_invocation_short_name -arch arm64e -arch arm64 -arch x86_64"
;;
"Linux"*)
extension=so
undefined_flags=
;;
esac
set -x
# shellcheck disable=SC2086
gcc -shared -fPIC -lc -ldl -Os $undefined_flags fixnano.c -o libfixnano.$extension
{ set +x; } 2>/dev/null
}
check_for_bash
check_os
if [ "$HAS_BASH" ]; then
# shellcheck disable=SC3040
set -o pipefail
fi
if [ ! -d ~/bin ]; then
set -x
mkdir ~/bin || true
{ set +x; } 2>/dev/null
fi
ask "Run platform-specific steps?" && case "$OS" in
"macOS")
./install-macos.sh
;;
"Linux elementary")
./install-elementary.sh
;;
"Linux Ubuntu")
./install-ubuntu.sh
;;
"Linux Alpine")
./install-alpine.sh
;;
esac
ask "Copy bashrc?" && checked_copy .bashrc ~/.bashrc
ask "Copy bash_profile?" && checked_copy .bash_profile ~/.bash_profile
ask "Copy inputrc?" && checked_copy .inputrc ~/.inputrc
ask "Copy nanorc?" && checked_copy .nanorc ~/.nanorc && ! test -L ~/.nano && \
case "$OS" in
"macOS")
set -x
ln -s /opt/local/share/nano ~/.nano
{ set +x; } 2>/dev/null
;;
"Linux"*)
set -x
ln -s /usr/share/nano/ ~/.nano
{ set +x; } 2>/dev/null
;;
esac
ask "Copy gdbinit?" && checked_copy .gdbinit ~/.gdbinit
ask "Copy clang-format?" && checked_copy .clang-format ~/.clang-format
ask "Copy gitconfig?" && checked_copy .gitconfig ~/.gitconfig
ask "Copy gitattributes?" && checked_copy .gitattributes ~/.gitattributes
ask "Copy tigrc?" && checked_copy .tigrc ~/.tigrc
if [ ! -d ~/.config ]; then
set -x
mkdir ~/.config || true
{ set +x; } 2>/dev/null
fi
ask "Install iTerm shell integration?" && curl -L https://iterm2.com/misc/install_shell_integration.sh | bash
ask "Install git-ps1-status?" && checked_copy git-ps1-status ~/bin/git-ps1-status
ask "Install git-add-upstream?" && checked_copy git-add-upstream ~/bin/git-add-upstream
ask "Install git-test-pr?" && checked_copy git-test-pr ~/bin/git-test-pr
ask "Install git-_diff-pager?" && checked_copy git-_diff-pager ~/bin/git-_diff-pager
ask "Install _nano-clang-format?" && checked_copy _nano-clang-format ~/bin/_nano-clang-format
ask "Install cysh?" && checked_copy cysh ~/bin/cysh
ask "Install clangd config?" && case "$OS" in
"macOS")
checked_copy config.yaml ~/Library/Preferences/clangd/config.yaml
;;
"Linux"*)
checked_copy config.yaml ~/.config/clangd/config.yaml
;;
esac
ask "Install stderred?" && install_stderred
ask "Install nano fixes?" && install_fixnano