-
Notifications
You must be signed in to change notification settings - Fork 64
/
Copy pathinstall_sack.sh
executable file
·73 lines (64 loc) · 2.06 KB
/
install_sack.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
#!/bin/bash
#
# @filename: install_sack.sh
#
# @author Sampson L. Chen (sampson-chen / slchen)
# @date 2012-10-14
#
# @description:
# Sack auto-install script
#
# @usage:
# run this script from where the git repo is cloned to.
# sack installation variables
sack__install_main=$HOME/bin
sack__install_sackrc=$HOME
sack__install_cwd=$(pwd)
# If the install directory doesn't exist, create it
if [[ ! -d "$sack__install_main" ]]; then
echo "Creating '$sack__install_main'..."
mkdir "$sack__install_main"
fi
# If ack is not installed, install it
if [[ `which ack | wc -l` -eq 0 ]]; then
echo "Downloading 'ack' to '$sack__install_main/ack'..."
# FIXME: https
curl -s -L http://betterthangrep.com/ack-standalone \
> $sack__install_main/ack && chmod 0755 $sack__install_main/ack
if (( $? )); then
echo
echo "ACK! There was a problem downloading 'ack' from betterthangrep.com" >&2
echo " Bailing out." >&2
echo
exit 1
fi
fi
# No install script for ag, so let it be a TODO
echo "Copying 'sack' to '$sack__install_main/sack'..."
cp "$sack__install_cwd/sack" "$sack__install_main"
chmod +x "$sack__install_main/sack"
echo "Copying 'sag' to '$sack__install_main/sag'..."
cp "$sack__install_cwd/sag" "$sack__install_main"
chmod +x "$sack__install_main/sag"
if [[ -f "$sack__install_sackrc/.sackrc" ]]; then
echo >&2
echo "It seems you already have a .sackrc from a previous install." >&2
echo >&2
echo "Overwrite this with a fresh copy from the source distribution" >&2
echo "(losing your customizations)?" >&2
echo >&2
read -p "(Ctrl+C to quit) y/[N]? " ANS
if [[ $ANS =~ ^[Yy] ]]; then
echo
echo "Overwriting your existing rcfile at '$sack__install_sackrc/.sackrc'..."
cp "$sack__install_cwd/.sackrc" "$sack__install_sackrc"
else
echo
echo "Okay, not overwriting your existing .sackrc."
fi
else
echo "Creating new rcfile at '$sack__install_sackrc/.sackrc'..."
cp "$sack__install_cwd/.sackrc" "$sack__install_sackrc"
fi
echo
echo "All done."