Skip to content

Instantly share code, notes, and snippets.

@rckrdstrgrd
Forked from jnovack/Makefile
Last active February 7, 2019 10:11
Show Gist options
  • Save rckrdstrgrd/c8ab333b032f0e5cc3c2204eee7f8204 to your computer and use it in GitHub Desktop.
Save rckrdstrgrd/c8ab333b032f0e5cc3c2204eee7f8204 to your computer and use it in GitHub Desktop.
Install bash_completion on macOS without Homebrew

Install bash_completion on macOS without Homebrew

One Liner:

cd /tmp && curl -LOs https://gist.github.com/rckrdstrgrd/c8ab333b032f0e5cc3c2204eee7f8204/raw/792cb0dfcda2bf540237801f1446ce58f2424673/Makefile && make

I hate HomeBrew for the overhead just to install a simple package (which should be installed on OSX by default!).

COMPOSE_VERSION=$(docker-compose version --short)
DOCKER_VERSION=$(docker version --format '{{.Client.Version}}')
MACHINE_VERSION=$(docker-machine version | cut -d" " -f 3 | tr -d ,)
echo "Ininstalling bash completion for compose: $COMPOSE_VERSION docker: $DOCKER_VERSION machine: $MACHINE_VERSION"
sudo curl -L https://raw.githubusercontent.com/docker/compose/$COMPOSE_VERSION/contrib/completion/bash/docker-compose -o /usr/local/etc/bash_completion.d/docker-compose
sudo curl -L https://raw.githubusercontent.com/docker/machine/v$MACHINE_VERSION/contrib/completion/bash/docker-machine.bash -o /usr/local/etc/bash_completion.d/docker-machine
sudo curl -L https://raw.githubusercontent.com/docker/cli/v$DOCKER_VERSION/contrib/completion/bash/docker -o /usr/local/etc/bash_completion.d/docker
all:
@echo "WARNING: Installation requires your sudo access, please enter your password when prompted."
@echo " ... press Enter to continue... "
@read
curl -LOs https://src.fedoraproject.org/repo/pkgs/bash-completion/bash-completion-1.3.tar.bz2/a1262659b4bbf44dc9e59d034de505ec/bash-completion-1.3.tar.bz2
curl -LOs https://raw.githubusercontent.com/Homebrew/formula-patches/c1d87451da3b5b147bed95b2dc783a1b02520ac5/bash-completion/bug-740971.patch
curl -LOs https://gist.github.com/rckrdstrgrd/c8ab333b032f0e5cc3c2204eee7f8204/raw/abf1dbce62239cd2629f193b889726d98e19a646/osx.patch
curl -LOs https://gist.github.com/rckrdstrgrd/c8ab333b032f0e5cc3c2204eee7f8204/raw/abf1dbce62239cd2629f193b889726d98e19a646/SHA256SUMS
shasum -c SHA256SUMS || (@echo "There was an error downloading one or more files... please try again."; exit 1)
tar -xzvf bash-completion-1.3.tar.bz2
cd bash-completion-1.3/ && \
patch < ../bug-740971.patch && \
patch < ../osx.patch && \
./configure && \
make && \
sudo make install
@echo "source /usr/local/etc/bash_completion" >> ~/.bash_profile
diff --git a/bash_completion b/bash_completion
index 6601937..e56750b 100644
--- a/bash_completion
+++ b/bash_completion
@@ -39,9 +39,9 @@ fi
# Alter the following to reflect the location of this file.
#
-[ -n "$BASH_COMPLETION" ] || BASH_COMPLETION=/etc/bash_completion
-[ -n "$BASH_COMPLETION_DIR" ] || BASH_COMPLETION_DIR=/etc/bash_completion.d
-[ -n "$BASH_COMPLETION_COMPAT_DIR" ] || BASH_COMPLETION_COMPAT_DIR=/etc/bash_completion.d
+[ -n "$BASH_COMPLETION" ] || BASH_COMPLETION=/usr/local/etc/bash_completion
+[ -n "$BASH_COMPLETION_DIR" ] || BASH_COMPLETION_DIR=/usr/local/etc/bash_completion.d
+[ -n "$BASH_COMPLETION_COMPAT_DIR" ] || BASH_COMPLETION_COMPAT_DIR=/usr/local/etc/bash_completion.d
readonly BASH_COMPLETION BASH_COMPLETION_DIR BASH_COMPLETION_COMPAT_DIR
# Set a couple of useful vars
@@ -1098,7 +1098,7 @@
if type -p realpath > /dev/null; then
realpath "$(type -P "$1")"
elif type -p readlink > /dev/null; then
- readlink -f "$(type -P "$1")"
+ readlink "$(type -P "$1")"
else
type -P "$1"
fi
8ebe30579f0f3e1a521013bcdd183193605dab353d7a244ff2582fb3a36f7bec bash-completion-1.3.tar.bz2
bd242a35b8664c340add068bcfac74eada41ed26d52dc0f1b39eebe591c2ea97 bug-740971.patch
d4e5a8cb9730f14cfba3b2ce5ba0d0ce3eae3aff817300481b85469532f7e13f osx.patch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment