Skip to content

Instantly share code, notes, and snippets.

@jnovack
Last active November 23, 2020 03:35
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jnovack/e66f40e7a31e04f909c2f503c6df7367 to your computer and use it in GitHub Desktop.
Save jnovack/e66f40e7a31e04f909c2f503c6df7367 to your computer and use it in GitHub Desktop.
bash_completion on OSX without Homebrew

Bash Completion on OSX without Homebrew

One Liner:

cd /tmp && curl -LOs https://gist.github.com/jnovack/e66f40e7a31e04f909c2f503c6df7367/raw/Makefile && make

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

Change Log

  • 2019-05-28 : Fixed URLs
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.githubusercontent.com/jnovack/e66f40e7a31e04f909c2f503c6df7367/raw/287b97a1f24bb47746248a15659b9478e6ec8e02/osx.patch
curl -LOs https://gist.github.com/jnovack/e66f40e7a31e04f909c2f503c6df7367/raw/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/profile.d/bash_completion.sh" >> ~/.bashrc
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
@ritterob
Copy link

The URL for bash_completion-1.3.tar.bz2 is incorrect. The server can't be found.

@jnovack
Copy link
Author

jnovack commented May 28, 2019

Thanks for the correction, fix'd.

@jyeary
Copy link

jyeary commented Aug 29, 2019

I am curious why you chose 1.3 for the version since 2.8 is the latest version of bash-completion. Is there an issue with it above 1.3 on a Mac?

@jnovack
Copy link
Author

jnovack commented Sep 4, 2019

From https://github.com/Homebrew/homebrew-core/blob/master/Formula/bash-completion.rb:

NOTE: version 2 is out, but it requires Bash 4, and macOS ships with 3.2.57.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment