ready 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 456956b1ac3139ec747542b6b3c38462e4a4016404345930207a36114767b288
4
- data.tar.gz: 5c12ad3085a8d16064f6fc2cf3cd9864a827624ae7aa42812d1a0d4e37fc620e
3
+ metadata.gz: fecb44116c404a5eeefe685cdaafc2b785c57480ade703fb02bd6c6f05fbc794
4
+ data.tar.gz: 3f641b0e7cb187f7f18f761f2de5e7d269af0532f1b47103efaae1d054bf8ad8
5
5
  SHA512:
6
- metadata.gz: a350d3b345d9c2bf0eee35816f2b2af3eea33d5a9b4ea6f1c8213d0ff6cf1cfbdb1fc4a92dc68a317604a98ce875ffbfd2ad6f7f2d166cb6b35029a8b83d2a59
7
- data.tar.gz: 5bdf1c8d1cdaa141028ca2ffba6c1cb016839884607de0d12aba9bc141a73cd4aa1cb66dfc885ad6198b0394ca1f69ed3647df81e97c010294de2ed7c08fb4b4
6
+ metadata.gz: a5fcba05fafe2c0f5ae82bfcba271e48f6a5fefe52ded9b3c49175c071174287d2afab742705f1369cd586bd8db039aebe20286d6f0e80bc9eadb0cb2074126b
7
+ data.tar.gz: 41b2773cf859b8fac712b8dfa4587aa993b3c60bd86518f09d5eab2d973e0a8d4eea873e8776f25d9afbad13edaabc5289882515164c741bc924f423366238a8
data/.rubocop.yml CHANGED
@@ -17,10 +17,23 @@ plugins:
17
17
 
18
18
  AllCops:
19
19
  NewCops: enable
20
- TargetRubyVersion: 4.0
20
+ # Lint at the gem's supported floor (ready.gemspec's required_ruby_version),
21
+ # which CI also exercises -- not the 4.0.1 dev pin -- so accidental
22
+ # 4.0-only syntax is caught rather than shipped to 3.4 users.
23
+ TargetRubyVersion: 3.4
21
24
  Exclude:
22
- - bin/*
25
+ # Stock bundler scripts; bin/bench is ours and stays linted.
26
+ - bin/console
27
+ - bin/setup
23
28
  - vendor/**/*
29
+ # Vendored read-only reference copy of an external gem; not this project's
30
+ # code (it is also gitignored, so CI never sees it).
31
+ - references/**/*
32
+ # Standalone runtime helper scripts -- a doc formatter and the rdoc `ri`
33
+ # patch -- with their own conventions, not the gem's authored library code.
34
+ - extra/**/*
35
+ # Gitignored scratch: benchmark run logs and throwaway report-parsing scripts.
36
+ - log/**/*
24
37
  - lib/core_ext/**/*
25
38
  - rakelib/project.rb
26
39
  - rakelib/project_version.rb
@@ -128,6 +141,12 @@ Claude/MysteryRegex:
128
141
  Style/MutableConstant:
129
142
  EnforcedStyle: literals
130
143
 
144
+ # Data.define subclassing keeps the class body a real class body, so constants
145
+ # holding instances of the class (e.g. Span::TABLE) live where they belong;
146
+ # the block form would bind them lexically to the enclosing namespace.
147
+ Style/DataInheritance:
148
+ Enabled: false
149
+
131
150
  # Shared test contexts legitimately define many helpers.
132
151
  RSpec/MultipleMemoizedHelpers:
133
152
  Max: 10
@@ -151,6 +170,35 @@ Style/Documentation:
151
170
  Exclude:
152
171
  - "spec/**/*"
153
172
 
173
+ # E2E specs share one expensive by-server across examples via before(:all) and
174
+ # hold it in an instance variable; that is intentional here.
175
+ RSpec/BeforeAfterAll:
176
+ Exclude:
177
+ - "spec/e2e/**/*"
178
+
179
+ RSpec/InstanceVariable:
180
+ Exclude:
181
+ - "spec/e2e/**/*"
182
+
183
+ # E2E examples are longer by nature (shell/server setup + several aggregated
184
+ # structural assertions per example).
185
+ RSpec/ExampleLength:
186
+ Exclude:
187
+ - "spec/e2e/**/*"
188
+
189
+ # The e2e and benchmark suites are grouped by test type, not class namespace,
190
+ # so their paths deliberately do not mirror the described constant.
191
+ RSpec/SpecFilePathFormat:
192
+ Exclude:
193
+ - "spec/e2e/**/*"
194
+ - "spec/bench/**/*"
195
+
196
+ # Ready::Bench::Report is a waterfall renderer whose job is to write to stdout;
197
+ # it lives under spec/support only so Zeitwerk autoloads it.
198
+ RSpec/Output:
199
+ Exclude:
200
+ - "spec/support/bench/**/*"
201
+
154
202
  # Trailing commas in multiline literals and arguments.
155
203
  Style/TrailingCommaInArrayLiteral:
156
204
  EnforcedStyleForMultiline: comma
@@ -183,3 +231,10 @@ RSpec/NamedSubject:
183
231
  # have_file_content matcher accepts a filename string in expect()
184
232
  RSpec/ExpectActual:
185
233
  Enabled: false
234
+
235
+ Lint/EmptyInPattern:
236
+ Enabled: false
237
+
238
+ Metrics/MethodLength:
239
+ Exclude:
240
+ - "**/*.rake"
data/README.md CHANGED
@@ -1,25 +1,92 @@
1
1
  # Ready
2
2
 
3
- A new Ruby gem
3
+ Make Ruby CLIs start instantly. `ready` preloads your Ruby executables into a
4
+ persistent [`by`][by] server and installs thin zsh stubs that dispatch to it, so
5
+ tools like `irb`, `rails`, or `rspec` skip Ruby's startup cost on every run.
4
6
 
5
- ## Installation
7
+ ## Requirements
6
8
 
7
- Install the gem and add to the application's Gemfile by executing:
9
+ - **zsh** — the only supported shell (bash and fish are not supported)
10
+ - **[rbenv]** — the supported Ruby version manager
11
+ - **Ruby >= 3.4.7**
8
12
 
9
- $ bundle add ready
13
+ ## Install
10
14
 
11
- If bundler is not being used to manage dependencies, install the gem by executing:
15
+ Install `ready` globally as a command-line tool. Do **not** add it to a
16
+ project's Gemfile or run `bundle add ready` / `bundle install` for it — `ready`
17
+ manages a single machine-wide preloader, not a per-project dependency:
12
18
 
13
- $ gem install ready
19
+ ```sh
20
+ gem install ready
21
+ ```
22
+
23
+ Then load the zsh plugin. `ready init` resolves the plugin's path and prints the
24
+ line that sources it — add it to your `~/.zshrc`:
25
+
26
+ ```sh
27
+ # ~/.zshrc
28
+ eval "$(ready init)"
29
+ ```
30
+
31
+ `ready init` on its own just prints that line, so you can paste it directly
32
+ instead:
33
+
34
+ ```sh
35
+ $ ready init
36
+ source /usr/local/.../gems/ready-x.y.z/zsh/ready/ready.plugin.zsh
37
+ ```
14
38
 
15
39
  ## Usage
16
40
 
17
- TODO: Write usage instructions here.
41
+ List the gems to preload and the executables to compile in `~/.readyfile`:
42
+
43
+ ```yaml
44
+ gems:
45
+ - rails
46
+ executables:
47
+ - irb
48
+ - rspec
49
+ ```
50
+
51
+ Build every stub and start the server:
52
+
53
+ ```sh
54
+ ready up
55
+ ```
56
+
57
+ `irb`, `rspec`, … are now near-instant. The rest of the commands:
58
+
59
+ ```sh
60
+ ready compile irb rspec # (re)compile stubs for specific CLIs
61
+ ready compile by # (re)compile just the persistent `by` client
62
+ ready compile all # recompile everything
63
+ ready clobber # remove all compiled artifacts
64
+ ready help # full command reference
65
+ ```
66
+
67
+ ## Configuration
68
+
69
+ `ready` is configured through environment variables — set them before the zsh
70
+ plugin loads:
71
+
72
+ | Name | Description | Default |
73
+ |------|-------------|---------|
74
+ | `READY_PREFIX` | Base directory for ready's runtime state (socket, builds, logs) | `/tmp/ready` |
75
+ | `READY_SOCK_PATH` | Unix socket for the `by` preloader server | `$READY_PREFIX/ready.sock` |
76
+ | `READY_READYFILE` | YAML file listing the gems/executables to preload | `~/.readyfile` |
77
+ | `READY_LOG_PATH` | Log file | `$READY_PREFIX/ready.log` |
78
+ | `READY_LOGLEVEL` | Minimum log level (`debug`, `info`, `warn`, `error`) | `info` |
79
+ | `READY_DEBUG` | Set to `1` to force debug-level logging | `0` |
18
80
 
19
81
  ## Development
20
82
 
21
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests.
83
+ After checking out the repo, run `bin/setup` to install dependencies. Then run
84
+ `rake spec` to run the tests and `rake rubocop` to lint (`rake` runs both).
22
85
 
23
86
  ## License
24
87
 
25
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
88
+ The gem is available as open source under the terms of the
89
+ [MIT License](https://opensource.org/licenses/MIT).
90
+
91
+ [by]: https://github.com/jeremyevans/by
92
+ [rbenv]: https://github.com/rbenv/rbenv
data/Rakefile CHANGED
@@ -1,9 +1,100 @@
1
+ # Everything below develops the ready gem itself (gem build/release, specs,
2
+ # rubocop, benchmarks) and depends on dev-only gems. None of it is needed to RUN
3
+ # ready: the runtime `ready`/`compile`/`clobber`/`ready:*` tasks live in
4
+ # rakelib/ready.rake, which rake auto-loads independently of this file. When
5
+ # ready runs as an installed gem the gemspec and dev gems are absent, so loading
6
+ # this file would crash `ready up|compile|clobber` (e.g. bundler/gem_tasks
7
+ # raising "Unable to determine name from existing gemspec"). Load the dev tasks
8
+ # only in a source checkout, detected by the gemspec's presence.
9
+ return unless (Pathname(__dir__) / "ready.gemspec").exist?
10
+
1
11
  require "bundler/gem_tasks"
2
12
 
3
13
  require "rspec/core/rake_task"
4
14
 
5
15
  RSpec::Core::RakeTask.new(:spec)
6
16
 
17
+ namespace :spec do
18
+ desc "Run the end-to-end (:e2e) specs (needs zsh + by/by-server)"
19
+ task :e2e do
20
+ ok = system({ "READY_E2E" => "1" }, RbConfig.ruby, "-S", "rspec", "--tag", "e2e")
21
+ abort("e2e specs failed") unless ok
22
+ end
23
+ end
24
+
25
+ def bench_protocol
26
+ executable = ENV.fetch("BENCH_EXE", "ri")
27
+ # TCPServer is the default workload for the default tool only; any other
28
+ # executable runs bare unless BENCH_ARGS says otherwise.
29
+ default_arguments = executable == "ri" ? "TCPServer" : ""
30
+ Ready::Bench::Protocol.new(
31
+ executable_name: executable,
32
+ arguments: ENV.fetch("BENCH_ARGS", default_arguments).split,
33
+ preload_gems: bench_preload_gems,
34
+ rounds: Integer(ENV.fetch("BENCH_RUNS", "15")),
35
+ warmups: Integer(ENV.fetch("BENCH_WARMUPS", "3")),
36
+ )
37
+ end
38
+
39
+ # The hot server preloads the gems a readyfile declares (BENCH_READYFILE),
40
+ # falling back to rdoc, which ships the default tool. The build_dir is
41
+ # irrelevant here -- only gem names are read -- but Readyfile requires an
42
+ # existing directory, so the readyfile's own parent satisfies it.
43
+ def bench_preload_gems
44
+ readyfile_path = ENV.fetch("BENCH_READYFILE", nil)
45
+ return ["rdoc"] if readyfile_path.nil?
46
+
47
+ readyfile_path = Pathname(readyfile_path)
48
+ Ready::Readyfile.open(readyfile_path, build_dir: readyfile_path.expand_path.parent).gem_names
49
+ end
50
+
51
+ def bench_runner
52
+ require "ready"
53
+ require "zeitwerk"
54
+ Zeitwerk::Loader.new.tap do |loader|
55
+ loader.inflector.inflect("cli" => "CLI")
56
+ loader.push_dir(Pathname(__dir__) / "spec/support", namespace: Ready)
57
+ loader.setup
58
+ end
59
+ Ready::Bench::Runner.new(protocol: bench_protocol)
60
+ end
61
+
62
+ # Appends this run's headline numbers so a caller sequencing several
63
+ # benchmarks (bin/bench --plot) can chart them afterwards.
64
+ def export_bench_results(runner, results_path)
65
+ results = Ready::Bench::ResultsLog.new(results_path)
66
+ results.append(command: runner.invocation, arm: :cold,
67
+ full_milliseconds: runner.cold_summary.duration_of(:full))
68
+ results.append(command: runner.invocation, arm: :hot,
69
+ full_milliseconds: runner.hot_summary.duration_of(:full))
70
+ end
71
+
72
+ # Plot mode (BENCH_RESULTS set by bin/bench --plot) exports the headline
73
+ # numbers for the CLI to chart and stays silent on stdout, so the plot is the
74
+ # only output; otherwise the full waterfall report is the output. Either way
75
+ # the run narrates its progress to stderr.
76
+ def run_bench(verbose:)
77
+ runner = bench_runner.call
78
+ results_path = ENV.fetch("BENCH_RESULTS", nil)
79
+ if results_path
80
+ export_bench_results(runner, results_path)
81
+ else
82
+ runner.render(verbose:)
83
+ end
84
+ end
85
+
86
+ desc "Print the cold-vs-hot startup waterfall (needs zsh + by-server + rbenv); bin/bench is the front door"
87
+ task :bench do
88
+ run_bench(verbose: false)
89
+ end
90
+
91
+ namespace :bench do
92
+ desc "rake bench plus a legend table explaining every span row"
93
+ task :verbose do
94
+ run_bench(verbose: true)
95
+ end
96
+ end
97
+
7
98
  require "rubocop/rake_task"
8
99
  RuboCop::RakeTask.new
9
100
 
data/demo/demofns.zsh ADDED
@@ -0,0 +1,34 @@
1
+ unready_shell() {
2
+ local fnname=$0
3
+ local i
4
+ local -a fns=(${functions[(I)*ready_*]})
5
+ local -a toremove=(${0} reready)
6
+ local -a raliases
7
+ fns=(${fns:|toremove})
8
+
9
+ for i in $fns; do
10
+ print -u2 "Removing fn ${(qqq)i}"
11
+ unfunction $i
12
+ done
13
+
14
+ raliases=(${(k)aliases[(R)*ready*]})
15
+
16
+ for i in $raliases; do
17
+ print -u2 "Removing alias ${(qqq)i}"
18
+ unalias $i
19
+ done
20
+ }
21
+
22
+ reready() {
23
+ unready_shell
24
+ command pkill -f by-server
25
+ command ready clobber
26
+ yes | command gem uninstall ready || true
27
+ command bundle exec rake clobber
28
+ command bundle exec rake build
29
+ command gem install \
30
+ --conservative \
31
+ --no-document \
32
+ --no-update-sources \
33
+ --local pkg/ready*
34
+ }
data/demo/rubyconf.rec ADDED
@@ -0,0 +1,40 @@
1
+ %rec: Issue
2
+ %key: Id
3
+ %typedef: text_t regexp /^.*$/
4
+ %typedef: Owner_t enum me claude
5
+ %typedef: Status_t enum open in_progress complete
6
+ %type: Id int
7
+ %type: Title line
8
+ %type: Desc text_t
9
+ %type: Owner Owner_t
10
+ %type: Status Status_t
11
+ %type: Updated date
12
+ %auto: Id Updated
13
+ %mandatory: Title Desc Owner Status
14
+
15
+ Id: 0
16
+ Updated: Mon, 13 Jul 2026 20:59:56 -0500
17
+ Title: Tough items still not figured out
18
+ Desc:
19
+ + 1. By needs a few patches:
20
+ + a. Need to provide process substitution support - the process sub fds also need to be passed via send_io
21
+ + 2. Interactives like ssh, fzf, irb and friends can be unpredictable and extremely difficult to debug/test
22
+ + a. kamal ssh not working e2e
23
+ + b. irb occasionally spits out bizarre errors
24
+ + c. SIGINT currently kills the whole process, rather than propogating to the interactive
25
+ Owner: me
26
+ Status: open
27
+
28
+ Id: 1
29
+ Updated: Mon, 13 Jul 2026 21:08:41 -0500
30
+ Title: ready compile should default to all - shouldn't be required
31
+ Desc:
32
+ Owner: me
33
+ Status: open
34
+
35
+ Id: 2
36
+ Updated: Mon, 13 Jul 2026 22:06:59 -0500
37
+ Title: Interesting quirks
38
+ Desc: 1. bundler/setup and bundle exec were causing major issues, took a lot of debugging but eventually traced the RUBYOPT env var being set by bundler. the zsh stubs surgically remove that env variable before loading the stub (doesn't affect global env, just the run)
39
+ Owner: me
40
+ Status: open
data/exe/ready CHANGED
@@ -1,3 +1,20 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "ready"
3
+ # Use Bundler when developing against a checkout (a Gemfile is present in the
4
+ # gem root), but stay bundler-free in production so an installed `ready` gem
5
+ # resolves its dependencies through RubyGems. Requiring bundler/setup directly
6
+ # (rather than invoking via `bundle exec`) means production installs (which
7
+ # ship no Gemfile, per the gemspec's file list) run without Bundler at all.
8
+ # In a dev checkout Bundler is active and, as expected, propagates
9
+ # `-rbundler/setup` in RUBYOPT to child processes; the generated zsh stubs strip
10
+ # that at runtime (see fn.zsh.erb).
11
+ gemfile = File.expand_path("../Gemfile", __dir__)
12
+
13
+ if File.exist?(gemfile)
14
+ ENV["BUNDLE_GEMFILE"] ||= gemfile
15
+ require "bundler/setup"
16
+ end
17
+
18
+ require_relative "../lib/ready"
19
+
20
+ Ready::CLI.start
data/extra/browse.sh ADDED
@@ -0,0 +1,161 @@
1
+ #!/usr/bin/env zsh
2
+ emulate -L zsh
3
+ setopt extendedglob
4
+
5
+ zmodload zsh/zutil
6
+
7
+ local -A opts
8
+ zparseopts -D -E -F -M -A opts \
9
+ - \
10
+ -style: \
11
+ -reg \
12
+ -preview \
13
+ -glow \
14
+ -rif \
15
+ f:=-format \
16
+ -format:
17
+
18
+ (( $? == 0 )) || return 1
19
+
20
+ zmodload -F zsh/files b:zf_mkdir
21
+ zmodload zsh/mapfile
22
+ mapfile[/tmp/fzf/state//reg]=""
23
+
24
+ typeset -gx RIF=$(( $+opts[--rif] ))
25
+ typeset -gx RI_REG=$(( $+opts[--reg] ))
26
+ typeset -gx FORMAT=${${opts[--format]:-markdown}#=}
27
+ typeset -gx GLOW=$(( $+opts[--glow] ))
28
+ typeset -gx STYLE=${${opts[--style]:-dark}#=}
29
+ typeset -gx TIMEFMT='%U user %S system %P cpu %*E total'
30
+ typeset -gx _RI_SELF=${0:A}
31
+ typeset -gx _RI_FIFO=$(mktemp -u)
32
+ typeset -gx _RI_FD_RW _RI_FD_R
33
+
34
+ typeset -g FZFX=~/repos/vault/wip/fzfx.sh
35
+
36
+ local script_dir=${0:A:h}
37
+ local rif=$script_dir/rif2
38
+ local formatter=$script_dir/formatter.rb
39
+ local ready_build=/tmp/ready/builds.zwc
40
+
41
+ if [[ -f $ready_build ]]; then
42
+ fpath+=(${ready_build:P})
43
+ autoload -Uz ${ready_build:P}
44
+ else
45
+ print -u2 -P "%F{yellow}Warning: ready build zwc not found"
46
+ exit 1
47
+ fi
48
+
49
+ if ! [[ -f $formatter ]]; then
50
+ print -u2 "%F{red}%BError:%b Cannot locate %Bformatter.rb%b%f"
51
+ return 1
52
+ fi
53
+
54
+ mkfifo $_RI_FIFO
55
+
56
+ exec {_RI_FD_RW}<>$_RI_FIFO
57
+ exec {_RI_FD_R}<$_RI_FIFO
58
+
59
+ trap "exec {_RI_FD_RW}>&- {_RI_FD_R}>&-; rm -f $_RI_FIFO" EXIT INT TERM
60
+
61
+ glow() {
62
+ emulate -L zsh
63
+ setopt extendedglob
64
+ CLICOLOR_FORCE=1 command glow --style $STYLE $@
65
+ }
66
+
67
+ display() {
68
+ emulate -L zsh
69
+
70
+ if ! (( GLOW )); then
71
+ command cat
72
+ else
73
+ $script_dir/by $formatter \
74
+ | gawk '
75
+ /`{3}ruby/{block=1; print; next}
76
+ /`{3}/{block=0; print; next}
77
+ block==1{gsub(/^ /,"")}
78
+ {print}
79
+ ' | glow
80
+ fi
81
+ }
82
+
83
+ preview() {
84
+ emulate -L zsh
85
+ setopt extendedglob
86
+ local rc
87
+ local -a ri_args=(--format=$FORMAT)
88
+ local -a rif_args=(--forcebat)
89
+ local -a rif2_args
90
+
91
+ if (( RIF )); then
92
+ autoload -Uz +X rif
93
+ rif_args+=(${@:#-*})
94
+ rif2_args+=(${@:#-*})
95
+ $rif ${(z)rif2_args}; rc=$?
96
+
97
+ if (( rc != 0 )); then
98
+ print -u2 -P "%F{yellow}No matches found for %B$@%b%f"
99
+ fi
100
+ return $rc
101
+ fi
102
+
103
+ {
104
+ if (( $RI_REG )); then
105
+ command ri $ri_args $@
106
+ else
107
+ # normally would pass ri_args here but args present keeps triggering Test::Unit
108
+ $script_dir/ready_ri $@
109
+ fi
110
+ } | display
111
+ }
112
+
113
+ printrez() {
114
+ local arr_name=${1:?}
115
+ local item=${${(P)arr_name}[-1]}
116
+ local rc
117
+ local -a lines
118
+ ($script_dir/ready_ri --list $item 2>/dev/null) \
119
+ | {
120
+ read line && lines+=($line)
121
+ read line && lines+=($line)
122
+ read line && lines+=($line)
123
+ read line && lines+=($line)
124
+ if [[ $lines =~ '--list' ]]; then
125
+ $script_dir/ready_ri "$item#" 2>/dev/null
126
+ else
127
+ print -r -l -- $lines
128
+ cat
129
+ fi
130
+ } | $script_dir/finder.sh
131
+ }
132
+
133
+ local -a stack
134
+ if (( $+opts[--preview] )); then
135
+ preview $@
136
+ return $?
137
+ else
138
+ while true; do
139
+ if (( $#stack == 0 )); then
140
+ result=$( printrez stack)
141
+ rc=$?
142
+
143
+ if [[ -z $result ]]; then
144
+ break
145
+ return $rc
146
+ fi
147
+ stack+=($result)
148
+ else
149
+ result=$(printrez stack)
150
+
151
+ rc=$?
152
+
153
+ if (( rc == 0 )) && (( ${#${result#[A-Z]}} != $#result )); then
154
+ stack+=($result)
155
+ continue
156
+ else
157
+ stack=(${stack[1,-2]})
158
+ fi
159
+ fi
160
+ done
161
+ fi
data/extra/finder.sh ADDED
@@ -0,0 +1,97 @@
1
+ #!/usr/bin/env sh
2
+
3
+ FZFX="$HOME/repos/vault/wip/fzfx.sh"
4
+
5
+ exec "$FZFX" \
6
+ --ansi \
7
+ --reverse \
8
+ --preview='preview {}' \
9
+ --bind='change:first' \
10
+ --bind='focus:bg-transform-preview-label(print_timing)' \
11
+ --bind='start:execute-silent(initialize)+bg-transform-footer(flip_toggle glow; print_mode)+refresh-preview' \
12
+ --bind='alt-m:execute-silent(change_mode)+bg-transform-footer(print_mode)+refresh-preview' \
13
+ --bind='alt-g:execute-silent(toggle_glow)+bg-transform-footer(print_mode)+refresh-preview' \
14
+ --bind='tab:execute-silent(toggle_source)+refresh-preview' \
15
+ --preview-window='70%,wrap' \
16
+ --inject '
17
+ initialize() {
18
+ create_toggle rif
19
+ create_toggle glow
20
+
21
+ if (( RI_REG )); then
22
+ state_set reg 1
23
+ else
24
+ state_set reg 0
25
+ fi
26
+ }
27
+
28
+ print_timing() {
29
+ zmodload zsh/system
30
+ sysread -i ${_RI_FD_R} -o 1
31
+ }
32
+
33
+ print_mode() {
34
+ emulate -L zsh
35
+ local mode
36
+
37
+ if _is_reg; then
38
+ mode="%BNORMAL%b"
39
+ else
40
+ mode="%B%F{green}RIZZ%f%b"
41
+ fi
42
+
43
+ if get_toggle glow; then
44
+ mode="$mode + %F{magenta}glow%f"
45
+ fi
46
+ print -P -- ${mode}
47
+ }
48
+
49
+ toggle_glow() {
50
+ flip_toggle glow
51
+ }
52
+
53
+ toggle_source() {
54
+ flip_toggle rif
55
+ }
56
+
57
+ change_mode() {
58
+ if _is_reg; then
59
+ state_set reg 0
60
+ else
61
+ state_set reg 1
62
+ fi
63
+ }
64
+
65
+ preview() {
66
+ if _is_reg; then
67
+ RI_REG=1
68
+ else
69
+ RI_REG=0
70
+ fi
71
+
72
+ local -a args=(--preview)
73
+
74
+ if (( RI_REG )); then
75
+ args+=(--reg)
76
+ fi
77
+
78
+ if get_toggle glow; then
79
+ args+=(--glow)
80
+ fi
81
+
82
+ if get_toggle rif; then
83
+ args+=(--rif)
84
+ fi
85
+
86
+ { time $_RI_SELF --style $STYLE -f $FORMAT ${(z)args} -- $@ 2>&1 } 2>&$_RI_FD_RW
87
+ }
88
+
89
+ _is_reg() {
90
+ integer value=$(state_get reg)
91
+ if (( value )); then
92
+ return 0;
93
+ else
94
+ return 1
95
+ fi
96
+ }
97
+ '