mgalgs / fuzzy_bash_completion

Fuzzy tab completion for bash.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mac osx compatibility (+workaround)

coderofsalvation opened this issue · comments

Cool experiment, but im on mac osx.

$ uname -a
Darwin Leons-MacBook-Pro.local 15.3.0 Darwin Kernel Version 15.3.0: Thu Dec 10 18:40:58 PST 2015; root:xnu-3248.30.4~1/RELEASE_X86_64 x86_64
$ brew install bash
$ bash --version
GNU bash, version 4.3.42(1)-release (x86_64-apple-darwin15.3.0)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

And it doesn't seem to work out of the box.
However with this patch it works.

--- /tmp/fuzzy_bash_completion  2016-04-25 09:24:28.000000000 +0200
+++ /Users/leon/.bash_completion.d/fuzzy_bash_completion    2016-04-25 09:24:05.000000000 +0200
 39: ### Helpers ###
 40: _fuzzy_upcase()
 41: {
-42:     echo ${1^^}
+39:     str="$1"
+40:     [[ ${#str} > 0 ]] && echo "$1" | tr '[:upper:]' '[:lower:]'
 43: }
 44: 
 45: _fuzzy_complete_find_matches()
 152: # up fuzzy completion
 153: ################################################################################
 154: 
-155: declare -A _fuzzy_replaced_specs
+153: declare -a _fuzzy_replaced_specs 
 156: 
 157: # the options used to set up the completion:
 158: _fuzzy_complete_options="-o bashdefault -o default -o filenames -o nospace -v -F _fuzzy_complete"

Im not doing a PR, since I've got no idea why it doesn't support the uppercase feature ${1^^}.
The declare -a is also a mystery to me, since this is a gnu bash builtin (which declare returns nothing).

Any mac osx users out here?

I'm not sure why ${1^^} isn't working.

Regarding declare -A vs. declare -a, I'm confused how your patch is actually working because we're using _fuzzy_replaced_specs as an associative array. So declare -a really shouldn't work... More about this here.

Those two issues make me think that you're not actually running bash>=4...

I'm going to close this issue since it seems to be a setup problem as opposed to a bug in fuzzy_bash_completion, but feel free to re-open if you find anything else out.