/
autojump.rb
55 lines (45 loc) 路 1.86 KB
/
autojump.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
class Autojump < Formula
desc "Shell extension to jump to frequently used directories"
homepage "https://github.com/wting/autojump"
url "https://github.com/wting/autojump/archive/refs/tags/release-v22.5.3.tar.gz"
sha256 "00daf3698e17ac3ac788d529877c03ee80c3790472a85d0ed063ac3a354c37b1"
license "GPL-3.0-or-later"
revision 3
head "https://github.com/wting/autojump.git", branch: "master"
bottle do
rebuild 3
sha256 cellar: :any_skip_relocation, all: "186ebf3a980da0c5f3d7ab1436fb367ad5a47554d09d5b2cfbe0c37097cf287e"
end
depends_on "python@3.12"
def install
python_bin = Formula["python@3.12"].opt_libexec/"bin"
system python_bin/"python", "install.py", "-d", prefix, "-z", zsh_completion
# ensure uniform bottles
inreplace prefix/"etc/profile.d/autojump.sh", "/usr/local", HOMEBREW_PREFIX
# Backwards compatibility for users that have the old path in .bash_profile
# or .zshrc
(prefix/"etc").install_symlink prefix/"etc/profile.d/autojump.sh"
libexec.install bin
(bin/"autojump").write_env_script libexec/"bin/autojump", PATH: "#{python_bin}:$PATH"
end
def caveats
<<~EOS
Add the following line to your ~/.bash_profile or ~/.zshrc file:
[ -f #{etc}/profile.d/autojump.sh ] && . #{etc}/profile.d/autojump.sh
If you use the Fish shell then add the following line to your ~/.config/fish/config.fish:
[ -f #{HOMEBREW_PREFIX}/share/autojump/autojump.fish ]; and source #{HOMEBREW_PREFIX}/share/autojump/autojump.fish
Restart your terminal for the settings to take effect.
EOS
end
test do
path = testpath/"foo/bar"
path.mkpath
cmds = [
". #{etc}/profile.d/autojump.sh",
"j -a \"#{path.relative_path_from(testpath)}\"",
"j foo >/dev/null",
"pwd",
]
assert_equal path.realpath.to_s, shell_output("bash -c '#{cmds.join("; ")}'").strip
end
end