From 1995f653086ec0b4ab56618105c5678331949106 Mon Sep 17 00:00:00 2001 From: Zach Whaley Date: Sat, 3 Dec 2016 11:36:49 -0600 Subject: [PATCH] Add a method for installing fish function files Fish shell allows third-party software vendors to put their own function files in a directory for their software. For brew installed Fish shell, this is /usr/local/share/fish/vendor_functions.d --- Library/Homebrew/caveats.rb | 12 ++++++++++++ Library/Homebrew/formula.rb | 8 ++++++++ Library/Homebrew/keg.rb | 5 +++++ 3 files changed, 25 insertions(+) diff --git a/Library/Homebrew/caveats.rb b/Library/Homebrew/caveats.rb index a5568cb29a..0b1c0fd23a 100644 --- a/Library/Homebrew/caveats.rb +++ b/Library/Homebrew/caveats.rb @@ -19,6 +19,7 @@ class Caveats caveats << bash_completion_caveats caveats << zsh_completion_caveats caveats << fish_completion_caveats + caveats << fish_function_caveats caveats << plist_caveats caveats << python_caveats caveats << app_caveats @@ -99,6 +100,17 @@ class Caveats EOS end + def fish_function_caveats + return unless keg + return unless keg.fish_functions_installed? + return unless which("fish") + + <<-EOS.undent + fish functions have been installed to: + #{HOMEBREW_PREFIX}/share/fish/vendor_functions.d + EOS + end + def python_caveats return unless keg return unless keg.python_site_packages_installed? diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index bae2e3314f..3f2653e4ab 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -778,6 +778,14 @@ class Formula HOMEBREW_PREFIX+"var" end + # The directory where the formula's fish function files should be + # installed. + # This is symlinked into `HOMEBREW_PREFIX` after installation or with + # `brew link` for formulae that are not keg-only. + def fish_function + share+"fish/vendor_functions.d" + end + # The directory where the formula's Bash completion files should be # installed. # This is symlinked into `HOMEBREW_PREFIX` after installation or with diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb index f1275e7481..b3d88ea630 100644 --- a/Library/Homebrew/keg.rb +++ b/Library/Homebrew/keg.rb @@ -303,6 +303,11 @@ class Keg dir && dir.directory? && !dir.children.empty? end + def fish_functions_installed? + dir = path.join("share", "fish", "vendor_functions.d") + dir && dir.directory? && !dir.children.empty? + end + def plist_installed? !Dir["#{path}/*.plist"].empty? end