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
This commit is contained in:
Zach Whaley 2016-12-03 11:36:49 -06:00
parent 52691cd0de
commit 1995f65308
3 changed files with 25 additions and 0 deletions

View File

@ -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?

View File

@ -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

View File

@ -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