-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.sh
executable file
·81 lines (71 loc) · 2.05 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
#!/bin/sh
set -e
CURRENT_DIR=$(pwd -P)
TEMPDIR=$(mktemp -d)
cd "$TEMPDIR"
echo "Cloning jumper's repository..."
git clone https://github.com/homerours/jumper
cd jumper
echo
echo "Building jumper's binary..."
if [ -z "$PREFIX" ]; then
make install
else
make PREFIX="$PREFIX" install
fi
cd "$CURRENT_DIR"
echo
echo "Update shell configurations files? (y/n)"
read REPLY
echo
if [ $REPLY = 'y' ]; then
# Borrowed from https://github.com/junegunn/fzf
append_line() {
set -e
local line file lno
line="$1"
file="$2"
lno=""
echo "Update $file:"
echo " - $line"
if [ -f "$file" ]; then
lno=$(\grep -nF "$line" "$file" | sed 's/:.*//' | tr '\n' ' ')
fi
if [ -n "$lno" ]; then
echo " - Already exists: line #$lno"
else
[ -f "$file" ] && echo >> "$file"
echo "$line" >> "$file"
echo " + Added"
fi
echo
}
bash_config=~/.bashrc
zsh_config=~/.zshrc
fish_config=~/.config/fish/config.fish
if [ -f "${bash_config}" ]; then
append_line 'eval "$(jumper shell bash)"' "${bash_config}"
else
echo "File ${bash_config} does not exists."
echo "Please add 'eval \"\$(jumper shell bash)\"' to your bash config file if you would like to use jumper's mappings within bash."
echo
fi
if [ -f "${zsh_config}" ]; then
append_line 'source <(jumper shell zsh)' "${zsh_config}"
else
echo "File ${zsh_config} does not exists."
echo "Please add 'source <(jumper shell zsh)' to your zsh config file if you would like to use jumper's mappings within zsh."
echo
fi
if [ -f "${fish_config}" ]; then
append_line 'jumper shell fish | source' "${fish_config}"
else
echo "File ${fish_config} does not exists."
echo "Please add 'jumper shell fish | source' to your fish config file if you would like to use jumper's mappings within fish."
echo
fi
else
echo 'Shell configuration files have not been updated.'
echo
fi
echo 'Done!'