-
Notifications
You must be signed in to change notification settings - Fork 0
/
install
executable file
·68 lines (62 loc) · 1.86 KB
/
install
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
#!/usr/bin/env bash
APP_DIR=$(pwd)
DATA_DIR="$APP_DIR/data"
mkdir -p "$DATA_DIR"
./generate-config "$DATA_DIR"
echo "Create symlink /usr/local/bin/oh-hai"
sudo ln -sf "$APP_DIR/oh-hai" /usr/local/bin/oh-hai
# bash
FILE_BASHRC=~/.bashrc
if [ -f "$FILE_BASHRC" ]; then
BASH_SCRIPT_KEYBINDING="$APP_DIR/shell/key-bindings.bash"
RC_FILE="$DATA_DIR/.bash"
tee "$RC_FILE" > /dev/null <<EOT
if [ -f '$BASH_SCRIPT_KEYBINDING' ]; then
. '$BASH_SCRIPT_KEYBINDING'
fi
EOT
SOURCE_STR="[ -f $RC_FILE ] && source $RC_FILE"
SOURCE_STR_ESCAPED=$(echo "$SOURCE_STR" | sed 's/[][\\.*^$\-\/]/\\&/g')
if ! grep -q "^$SOURCE_STR_ESCAPED" $FILE_BASHRC ; then
printf "\n$SOURCE_STR" >> $FILE_BASHRC
fi
else
echo "warn: $FILE_BASHRC does not exist."
fi
# nushell
NU_CONFIG=~/.config/nushell/config.nu
if [ -f "$NU_CONFIG" ]; then
NU_KEYBINDING="$APP_DIR/shell/key-bindings.nu"
NU_SCRIPT="$DATA_DIR/.nu"
tee "$NU_SCRIPT" > /dev/null <<EOT
if ('$NU_KEYBINDING' | path exists) {
source $NU_KEYBINDING }
EOT
SOURCE_STR="if ('$NU_SCRIPT' | path exists) {source $NU_SCRIPT}"
SOURCE_STR_ESCAPED=$(echo "$SOURCE_STR" | sed 's/[][\\.*^$\-\/]/\\&/g')
if ! grep -q "^$SOURCE_STR_ESCAPED" $NU_CONFIG ; then
printf "\n$SOURCE_STR" >> $NU_CONFIG
fi
else
echo "warn: $NU_CONFIG does not exist."
fi
# zsh
FILE_ZSHRC=~/.zshrc
if [ -f "$FILE_ZSHRC" ]; then
ZSH_SCRIPT_KEYBINDING="$APP_DIR/shell/key-bindings.zsh"
RC_FILE="$DATA_DIR/.zsh"
tee "$RC_FILE" > /dev/null <<EOT
if [ -f '$ZSH_SCRIPT_KEYBINDING' ]; then
. '$ZSH_SCRIPT_KEYBINDING'
fi
EOT
SOURCE_STR="[ -f $RC_FILE ] && source $RC_FILE"
SOURCE_STR_ESCAPED=$(echo "$SOURCE_STR" | sed 's/[][\\.*^$\-\/]/\\&/g')
if ! grep -q "^$SOURCE_STR_ESCAPED" $FILE_ZSHRC ; then
printf "\n$SOURCE_STR" >> $FILE_ZSHRC
fi
else
echo "warn: $FILE_ZSHRC does not exist."
fi
echo 'Successfully installed'
echo 'Restart shell or reload bin file.'