blob: e30ab7d51ed9b60ed16f349b6e1121853123d343 (
plain)
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
|
#!/usr/bin/env sh
set -e
usage() {
echo "Usage: $0 [--shell fish|bash|none|all] [--no-man]"
}
requested_shell=
install_man=true
while [ "$#" -gt 0 ]; do
case "$1" in
--shell)
requested_shell=${2:-}
shift 2
;;
--shell=*)
requested_shell=${1#--shell=}
shift
;;
--no-man)
install_man=false
shift
;;
-h|--help)
usage
exit 0
;;
*)
echo "Unknown option: $1" >&2
usage >&2
exit 1
;;
esac
done
cabal build exe:tasker
bin=$(cabal list-bin exe:tasker)
sudo install -Dm755 "$bin" /usr/local/bin/tasker
echo "Installed $bin -> /usr/local/bin/tasker"
detect_shell() {
if [ -n "$requested_shell" ]; then
echo "$requested_shell"
else
basename "${SHELL:-}"
fi
}
install_fish_completion() {
if [ -f tasker.fish ]; then
sudo install -Dm644 tasker.fish \
/usr/share/fish/vendor_completions.d/tasker.fish
echo "Installed tasker.fish -> /usr/share/fish/vendor_completions.d/tasker.fish"
else
echo "Skipped fish completion: tasker.fish not found"
fi
}
install_bash_completion() {
if [ -f tasker.bash ]; then
sudo install -Dm644 tasker.bash \
/usr/share/bash-completion/completions/tasker
echo "Installed tasker.bash -> /usr/share/bash-completion/completions/tasker"
else
echo "Skipped bash completion: tasker.bash not found"
fi
}
install_manpage() {
if [ -f tasker.1 ]; then
sudo install -Dm644 tasker.1 \
/usr/local/share/man/man1/tasker.1
sudo mandb 2>/dev/null || true
echo "Installed tasker.1 -> /usr/local/share/man/man1/tasker.1"
else
echo "Skipped manpage: tasker.1 not found"
fi
}
case "$(detect_shell)" in
fish)
install_fish_completion
;;
bash)
install_bash_completion
;;
all)
install_fish_completion
install_bash_completion
;;
none)
echo "Skipped shell completions"
;;
*)
echo "Unsupported shell: ${requested_shell:-${SHELL:-unset}}"
echo "Skipped shell completions"
;;
esac
if [ "$install_man" = true ]; then
install_manpage
fi
|