-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathzsh-abbr.rb
89 lines (67 loc) · 2.75 KB
/
zsh-abbr.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
class ZshAbbr < Formula
desc "Auto-expanding abbreviations manager for zsh, inspired by fish"
homepage "https://github.com/olets/zsh-abbr"
url "https://github.com/olets/zsh-abbr.git",
tag: "v6.2.1",
revision: "f9e43d78110db0a8bf8ec75ca5b101a06b1d5ce8"
head "https://github.com/olets/zsh-abbr.git", branch: "next"
def install
pkgshare.install "zsh-abbr.zsh"
pkgshare.install "zsh-job-queue"
pkgshare.install "completions/_abbr"
man1.mkpath
man1.install "man/man1/abbr.1"
end
def caveats
<<~EOS
To activate abbreviations, add the following at the end of your .zshrc:
source #{HOMEBREW_PREFIX}/share/zsh-abbr/zsh-abbr.zsh
If you prefer to manage the package with Homebrew but load it with
a plugin manager, you may be able to load the above path with your
plugin manager.
Then to activate abbreviations in already open sessions, restart
zsh by running
exec zsh
To activate completions for abbr commands, add the following to
your .zshrc:
if type brew &>/dev/null; then
FPATH=$(brew --prefix)/share/zsh-abbr:$FPATH
autoload -Uz compinit
compinit
fi
You may also need to force rebuild `zcompdump`:
rm -f ~/.zcompdump; compinit
Additionally, if you receive "zsh compinit: insecure directories"
warnings when attempting to load these completions, you may need
to run these commands:
chmod go-w '#{HOMEBREW_PREFIX}/share'
chmod -R go-w '#{HOMEBREW_PREFIX}/share/zsh'
If you installed with --HEAD, you may now or in the future
have an unstable version (for example a beta version). Use at your
own risk. Backing up your abbreviations is recommended.
To switch to the stable version, first uninstall and then
(without passing HEAD) reinstall. You can check your version by
running `abbr --version`.
⚠️ You have installed the latest version of zsh-abbr. It
is possible that you were upgraded to a different major version. To
check your version, run:
abbr --version
Refer to https://github.com/olets/zsh-abbr/blob/main/CHANGELOG.md
for the latest changes and instructions.
Refer to https://zsh-abbr.olets.dev/installation.html
for instuctions on installing a different major version.
EOS
end
test do
# test that the program is installed
assert_match "1",
shell_output("zsh -c '. #{pkgshare}/zsh-abbr.zsh && echo $ABBR_DEFAULT_BINDINGS'")
# test that completions are installed
(testpath/"test.zsh").write <<~EOS
fpath=(#{pkgshare} $fpath)
autoload _ack
which _ack
EOS
assert_match(/^_ack/, shell_output("zsh test.zsh"))
end
end