-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh
executable file
·36 lines (36 loc) · 959 Bytes
/
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
#!/bin/bash
set -eu
unameOut="$(uname -s)"
case "${unameOut}" in
Darwin*) readlink=greadlink;;
*BSD*) readlink=greadlink;;
*) readlink=readlink;;
esac
myloc="$($readlink -f "$(dirname "$0")")" || {
echo 'need GNU coreutils!'
exit 1
}
usage() {
echo "Usage: install.sh install|uninstall"
}
case ${1:-} in
install)
git config --global alias.sh "!'$myloc/shgit.sh'"
echo "added alias 'sh' to your global git config."
[[ -d "${HOME}/.libexec" ]] || {
mkdir "${HOME}/.libexec"
echo "created ${HOME}/.libexec"
}
ln -s "$myloc/completions" "${HOME}/.libexec/shgit_completions"
echo "You can invoke the shell via 'git sh' from within a repo."
;;
uninstall)
rm -r "${HOME}/.libexec/shgit_completions"
echo "Removed ${HOME}/.libexec/shgit_completions"
git config --global --unset alias.sh
echo "Removed alias 'sh' from your global git config"
;;
*|-h)
usage
;;
esac