aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/keg.rb
diff options
context:
space:
mode:
authorZach Whaley2016-12-03 20:45:54 -0600
committerZach Whaley2016-12-08 07:23:26 -0600
commit14f46625a3e734a6b0e1ecdd8f146da20de5ea96 (patch)
tree3d6c15ee4a00c4b415207cb55d980513f29e87b3 /Library/Homebrew/keg.rb
parent95688cd72e318fca1cb2a0652e48c5d4db5a1466 (diff)
downloadbrew-14f46625a3e734a6b0e1ecdd8f146da20de5ea96.tar.bz2
caveats: Differentiate zsh completion files and function files
When installing a file to zsh/site-functions directory, it is assumed this is a zsh completion file, and the zsh completion caveat is printed after installation. But not all files in the zsh/site-functions directory are completion files. Some are files for functions that can be loaded on demand with zsh's autoload command. - Edit Keg.completion_installed to search specifically for files in the zsh/site-functions directory starting with an underscore only (By convention, zsh completion files start with an underscore) - Add Keg.zsh_functions_installed to search for non-completion files in the zsh/site-functions - Add Caveats.zsh_function_caveats to print a caveat if non-completion files have been installed to zsh/site-functions
Diffstat (limited to 'Library/Homebrew/keg.rb')
-rw-r--r--Library/Homebrew/keg.rb11
1 files changed, 10 insertions, 1 deletions
diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb
index b3d88ea63..5c8e71d07 100644
--- a/Library/Homebrew/keg.rb
+++ b/Library/Homebrew/keg.rb
@@ -297,12 +297,21 @@ class Keg
def completion_installed?(shell)
dir = case shell
when :bash then path.join("etc", "bash_completion.d")
- when :zsh then path.join("share", "zsh", "site-functions")
+ when :zsh
+ dir = path.join("share", "zsh", "site-functions")
+ dir if dir && dir.directory? && dir.children.any? { |f| f.basename.to_s.start_with?("_") }
when :fish then path.join("share", "fish", "vendor_completions.d")
end
dir && dir.directory? && !dir.children.empty?
end
+ def zsh_functions_installed?
+ # Check for non completion functions (i.e. files not started with an underscore),
+ # since those can be checked separately
+ dir = path.join("share", "zsh", "site-functions")
+ dir && dir.directory? && dir.children.any? { |f| !f.basename.to_s.start_with?("_") }
+ end
+
def fish_functions_installed?
dir = path.join("share", "fish", "vendor_functions.d")
dir && dir.directory? && !dir.children.empty?