-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathzdotdir.rb
41 lines (34 loc) · 1021 Bytes
/
zdotdir.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
require "active_support/core_ext/string/inflections"
class Zdotdir < Formula
desc "Personal Zsh configuration"
GITHUB_USER = GitHub.user["login"].freeze
homepage "https://github.com/#{GITHUB_USER}/#{name.demodulize.downcase}#readme"
latest = homepage.sub "#readme", ".git"
url latest, using: :git, branch: "main"
version "latest"
license "MIT"
uses_from_macos "zsh" => :test
def install
doc.install_metafiles
end
def post_install
system "#{HOMEBREW_BREW_FILE} completions link"
end
def caveats
<<~EOS
Consider adding to your Brewfile:
brew "#{name}", restart_service: :changed
EOS
end
service do
zdotdir = @formula.tap.path/@formula.name.downcase
run ["/bin/launchctl", "setenv", @formula.name.upcase, zdotdir]
keep_alive path: zdotdir/".zshenv"
end
test do
ENV[@formula.name.upcase] = testpath
touch ".zshenv"
sourced = shell_output "zsh --source-trace -c exec 2>&1"
assert_match "#{testpath}/.zshenv", sourced
end
end