lincheney / fzf-tab-completion

Tab completion using fzf
GNU General Public License v3.0
652 stars 41 forks source link

fix(bash): support bash on macOS by preferring gawk/gsed #35

Closed mattduck closed 3 years ago

mattduck commented 3 years ago

Hey @lincheney, thanks for building this! I just used it for the first time and it looks pretty useful.

I had to do the same gawk/gsed fix mentioned in https://github.com/lincheney/fzf-tab-completion/issues/28#issuecomment-757622797 to get this running on macos, so figured I would PR it. Feel free to ignore if you don't want to support mac - happy to use my fork.


(Copying the commit message below for more context)

On macOS, the default awk and sed are the BSD versions, which aren't compatible with some of the flags used in fzf-bash-completion.sh. GNU coreutils can be installed, but by default the GNU commands will be prefixed with "g" to avoid breaking anything that depends on the BSD versions.

If gawk/gsed are available, prefer them over awk and sed. This adds basic support for MacOS if the user has the GNU tools installed. We could do one better by using appropriate flags depending on the BSD/GNU version, but this is way quicker to implement and works fine for me.

Note - this only adds bash support, it doesn't add the equivalent gawk fix for zsh.

lincheney commented 3 years ago

lgtm thanks!