snibbets 2.0.39 → 2.0.40
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +179 -37
- data/lib/snibbets/string.rb +18 -2
- data/lib/snibbets/version.rb +1 -1
- data/lib/snibbets.rb +141 -136
- data/mise.toml +2 -0
- data/src/_README.md +176 -36
- metadata +4 -8
- data/Gemfile.lock +0 -125
- data/lib/snibbets/todo_spec.rb +0 -11
data/src/_README.md
CHANGED
@@ -97,39 +97,115 @@ output: raw
|
|
97
97
|
source: "~/Dropbox/Snippets"
|
98
98
|
```
|
99
99
|
|
100
|
+
| key | type | default | description |
|
101
|
+
| ------------------- | ------- | ---------- | ------------------------------------ |
|
102
|
+
| source | string | \*required | Path to snippet directory |
|
103
|
+
| all | boolean | false | Always display all snippets |
|
104
|
+
| all_notes | boolean | false | Show full content, including notes |
|
105
|
+
| copy | boolean | false | always copy output to clipboard |
|
106
|
+
| editor | string | $EDITOR | command or app to use with --edit |
|
107
|
+
| extension | string | md | Snippet extension to search |
|
108
|
+
| highlight | boolean | true | Syntax highlight code |
|
109
|
+
| highlight_theme | string | | Highlighter theme to use |
|
110
|
+
| highlighter | string | | Can be skylight or pygments |
|
111
|
+
| include_blockquotes | boolean | false | include blockquotes in output |
|
112
|
+
| interactive | boolean | true | display a menu when multiple options |
|
113
|
+
| launchbar | boolean | false | Output for LaunchBar |
|
114
|
+
| menus | string | fzf | menu utility: fzf, gum, console |
|
115
|
+
| name_only | boolean | false | Always search by filename |
|
116
|
+
| output | string | raw | Output format json, launchbar, raw |
|
117
|
+
[Configuration Options]
|
118
|
+
|
100
119
|
#### Snippet Location
|
101
120
|
|
102
121
|
Set the `source` key to the folder where you keep your Markdown snippets. Optionally adjust the `extension` setting if you use an extension other than `md` (e.g. `markdown` or `txt`).
|
103
122
|
|
104
123
|
#### Other Options
|
105
124
|
|
106
|
-
The `all` setting determines how Snibbets handles files
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
125
|
+
The `all` setting determines how Snibbets handles files
|
126
|
+
containing multiple snippets. If `all` is true, then it will
|
127
|
+
always display every snippet in the selected file. If false,
|
128
|
+
it will offer a menu and let you choose which snippet to
|
129
|
+
display. You can use `--all` on the command line to just
|
130
|
+
enable this once.
|
131
|
+
|
132
|
+
By default, Snibbets displays only the code from each
|
133
|
+
snippet (and optionally block quotes, see below). If you set
|
134
|
+
`all_notes` to true, then the full content of each snippet
|
135
|
+
containing a code block will be returned, allowing you to
|
136
|
+
see additional notes on the command line. This can be
|
137
|
+
toggled at runtime with `--notes` or `--no-notes`.
|
138
|
+
|
139
|
+
The `copy` setting determines whether the output is copied
|
140
|
+
to the clipboard in addition to being displayed on STDOUT.
|
141
|
+
This is the equivalent of running `snibbets QUERY | pbcopy`
|
142
|
+
(macOS) or `snibbets QUERY | xclip` (Linux). This can be
|
143
|
+
enabled for just one run with `--copy` on the command line.
|
144
|
+
Setting it to true in the config will copy to the clipboard
|
145
|
+
every time a snippet is displayed. On Mac this will work
|
146
|
+
automatically, on Windows/Linux you may need to [install
|
147
|
+
`xclip` or `xsel`][xclip].
|
111
148
|
|
112
149
|
[xclip]: https://ostechnix.com/access-clipboard-contents-using-xclip-and-xsel-in-linux/
|
113
150
|
|
114
|
-
The `editor` setting is used to open the config file, and to
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
151
|
+
The `editor` setting is used to open the config file, and to
|
152
|
+
open snippets for editing when using the `--edit` flag. This
|
153
|
+
setting can be any command line utility (`code`, `subl`,
|
154
|
+
`vim`, `nano`, etc.), or on macOS it can be an application
|
155
|
+
name (`BBEdit`, `VS Code`, etc.) or a bundle identifier
|
156
|
+
(`com.sublimetext.4`, `com.microsoft.VSCode`, etc.). If no
|
157
|
+
editor is set, then the file will be opened by whatever the
|
158
|
+
system default is (using `open` on macOS, `start` on
|
159
|
+
Windows, or `xdg-open`on Linux).
|
160
|
+
|
161
|
+
The `include_blockquotes` setting determines whether
|
162
|
+
blockquotes are included in the output. By default, Snibbets
|
163
|
+
removes everything other than code blocks (indented or
|
164
|
+
fenced) from the output it displays. But if you want to
|
165
|
+
include a note that you'll see on the command line, you can
|
166
|
+
put it in a block quote by preceding each line you want to
|
167
|
+
preserve with a right angle bracket (`>`).
|
168
|
+
|
169
|
+
The `interactive` setting determines whether menus will be
|
170
|
+
displayed. This should generally be true, but if you want
|
171
|
+
silent operation that just displays the best match
|
172
|
+
automatically, set it to false.
|
173
|
+
|
174
|
+
The `menus` setting will determine what method is used for
|
175
|
+
displaying interactive menus. If this is not set, it will be
|
176
|
+
automatically determined in the order of `fzf`, `gum`, and
|
177
|
+
`console`. You can manually choose to use one of these
|
178
|
+
options over another by making it the `menus` setting.
|
179
|
+
|
180
|
+
The `name_only` key will permanently set Snibbets to only
|
181
|
+
search for snippets by their filename rather than examining
|
182
|
+
their contents. You can enable this at runtime using
|
183
|
+
`--name-only` in the command.
|
123
184
|
|
124
185
|
#### Syntax Highlighting
|
125
186
|
|
126
|
-
The `highlight` key turns on syntax highlighting. This
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
187
|
+
The `highlight` key turns on syntax highlighting. This
|
188
|
+
requires that either `pygmentize` or `skylighting` is
|
189
|
+
available on your system (both available via package
|
190
|
+
managers like Homebrew). This feature is still in
|
191
|
+
development and results may be mixed. You can also set
|
192
|
+
`highlighter` to `pygments` or `skylight` to force using one
|
193
|
+
highlighter over the other.
|
194
|
+
|
195
|
+
Highlighting using Skylighting requires that your snippets
|
196
|
+
be named with extra extensions defining the lexer to use.
|
197
|
+
The last extension before `.md` (or whatever your snippet
|
198
|
+
extension is set to) should be the one that the highlighter
|
199
|
+
will recognize as a valid lexer, e.g. `my code.jquery.js.md`.
|
200
|
+
|
201
|
+
You can also define languages in your fenced code blocks by
|
202
|
+
putting the lexer name right after the opening fence. When
|
203
|
+
defining multiple snippets in one file that are of different
|
204
|
+
languages, this method will ensure that each one is properly
|
205
|
+
highlighted.
|
206
|
+
|
207
|
+
If you don't use either extensions or fenced code labels
|
208
|
+
with Skylighting, code won't get highlighted.
|
133
209
|
|
134
210
|
To define a snippet as python code, for example:
|
135
211
|
|
@@ -142,15 +218,33 @@ To define a snippet as python code, for example:
|
|
142
218
|
f = open(filename, 'w')
|
143
219
|
```
|
144
220
|
|
145
|
-
You can also define a color scheme with `highlight_theme`.
|
221
|
+
You can also define a color scheme with `highlight_theme`.
|
222
|
+
If you're using Pygments, run `pygmentize -L styles` to see
|
223
|
+
available options. If you're using Skylighting, you can
|
224
|
+
reference any theme in the [KDE repository]. Skylighting
|
225
|
+
themes are included in Snibbets and can be referenced by
|
226
|
+
their filename without `.theme`, or you can install your own
|
227
|
+
themes and reference them with a full path. (I recommend
|
228
|
+
`nord` when using Sylighting.)
|
146
229
|
|
147
230
|
[KDE repository]: https://github.com/KDE/syntax-highlighting/tree/master/data/themes
|
148
231
|
|
149
|
-
You can turn highlighting on or off for a single run using
|
232
|
+
You can turn highlighting on or off for a single run using
|
233
|
+
`--highlight` or `--no-highlight`. Syntax highlighting
|
234
|
+
definitely affects copyable output, so it's automatically
|
235
|
+
disabled when piping/redirecting output. When using
|
236
|
+
`--copy`, the code sent to the clipboard is not highlighted.
|
150
237
|
|
151
238
|
##### Installing a Syntax Highlighter
|
152
239
|
|
153
|
-
Snibbet's implementation of Skylighting has limited but
|
240
|
+
Snibbet's implementation of Skylighting has limited but
|
241
|
+
better-looking themes, and has some lexers that Pygments
|
242
|
+
lacks. However, Pygments has _more_ lexers and a wider array
|
243
|
+
of themes. It also can determine the target syntax
|
244
|
+
automatically better than Skylighting (which requires the
|
245
|
+
syntax to be specified -- it's pulled from the extensions of
|
246
|
+
your snippets), which is why Pygments is the default if it's
|
247
|
+
installed and you don't configure it otherwise.
|
154
248
|
|
155
249
|
- Install [Skylighting] with [Homebrew] (`brew install skylighting`) or [apt-get].
|
156
250
|
- Install [Pygments] using [Homebrew] (`brew install pygments`) or `pip install pygments`.
|
@@ -165,37 +259,80 @@ Snibbet's implementation of Skylighting has limited but better-looking themes, a
|
|
165
259
|
@cli(bundle exec bin/snibbets -h)
|
166
260
|
```
|
167
261
|
|
168
|
-
If your Snippets folder is set in the config, simply running
|
262
|
+
If your Snippets folder is set in the config, simply running
|
263
|
+
`snibbets [search query]` will perform the search and output
|
264
|
+
the code blocks, presenting a menu if more than one match is
|
265
|
+
found or the target file contains more than one snippet.
|
266
|
+
Selected contents are output raw to STDOUT.
|
169
267
|
|
170
268
|
> If you have fzf or gum installed, snibbets will use those for menus, providing fuzzy filtering of options.
|
171
269
|
|
172
270
|
#### JSON output
|
173
271
|
|
174
|
-
An undocumented output option is `-o json`, which will
|
272
|
+
An undocumented output option is `-o json`, which will
|
273
|
+
output all of the matches and their code blocks as a JSON
|
274
|
+
string that can be incorporated into other scripts. It's
|
275
|
+
similar to the `-o launchbar` option, but doesn't contain
|
276
|
+
the extra keys required for the LaunchBar action.
|
175
277
|
|
176
278
|
#### Open snippets in your editor
|
177
279
|
|
178
|
-
Use the `--edit` flag on any search to open the found
|
280
|
+
Use the `--edit` flag on any search to open the found
|
281
|
+
snippet file in your editor. Configure your default editor
|
282
|
+
in the config file. `snibbets configure` will open that, but
|
283
|
+
if you don't have an editor set, it might have strange
|
284
|
+
results. To edit manually, open
|
285
|
+
`~/.config/snibbets/snibbets.yml` in your text editor of
|
286
|
+
choice.
|
179
287
|
|
180
288
|
#### Creating new snippets
|
181
289
|
|
182
290
|
##### From clipboard
|
183
291
|
|
184
|
-
I do most of my snippet editing in [nvUltra], but sometimes
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
292
|
+
I do most of my snippet editing in [nvUltra], but sometimes
|
293
|
+
I have a function in my clipboard that just needs quick
|
294
|
+
saving and there are so few moving parts to creating a
|
295
|
+
snippet that it just feels like they could be
|
296
|
+
automated/simplified. That's why I added the `--paste` flag.
|
297
|
+
If you have a code snippet in your clipboard, you can just
|
298
|
+
run `snibbets --paste` (or just `-p`) and you'll get a
|
299
|
+
prompt asking you to describe the snippet (used for
|
300
|
+
filename) and one asking what language(s) are represented.
|
301
|
+
|
302
|
+
You can input the languages as names, e.g. `rust`,
|
303
|
+
`typescript`, or `scala`, or you can just add file
|
304
|
+
extensions that represent the language. If I say `ts` to
|
305
|
+
that prompt, it will generate an extension of `.ts.md` and
|
306
|
+
then add a metadata tag of `typescript` to the file. The
|
307
|
+
code from the clipboard goes into a fenced code block in the
|
308
|
+
document. You can always go add notes to it later, but it's
|
309
|
+
a great way to save snippets as you come across them (or
|
310
|
+
solutions you figure out after a week of banging your head).
|
311
|
+
|
312
|
+
This command requires that a clipboard utility be available.
|
313
|
+
On macOS, you have `pbpaste` by default and don't need to do
|
314
|
+
anything. On Windows and Linux, you'll need to
|
315
|
+
[install either `xclip` or `xsel`][xclip].
|
189
316
|
|
190
317
|
[nvUltra]: https://nvultra.com "nvUltra for Mac"
|
191
318
|
|
192
319
|
##### With editor
|
193
320
|
|
194
|
-
You can also create new snippets by opening a skeleton file
|
321
|
+
You can also create new snippets by opening a skeleton file
|
322
|
+
in your editor with `--edit-new`. This will prompt for a
|
323
|
+
title and languages, create the new file, and open it in
|
324
|
+
your editor (or in nvUltra with the `--nvultra` flag). If
|
325
|
+
you use `--edit-new-titled TITLE`, the new snippet will get
|
326
|
+
a filename from `TITLE` and languages will be determined
|
327
|
+
from any extension added to the title, or prompted for if
|
328
|
+
none are found.
|
195
329
|
|
196
330
|
#### Saving Settings When Running
|
197
331
|
|
198
|
-
Any time you specify things like a source folder with the
|
332
|
+
Any time you specify things like a source folder with the
|
333
|
+
`--source` flag, or turn on highlighting or name-only
|
334
|
+
search, you can add the flag `--save` to write those to your
|
335
|
+
config and make them the default options.
|
199
336
|
|
200
337
|
## LaunchBar Action
|
201
338
|
|
@@ -203,9 +340,12 @@ _I'm currently reworking the LaunchBar action, and it doesn't function very well
|
|
203
340
|
|
204
341
|
<!-- ### Installation
|
205
342
|
|
206
|
-
The LaunchBar action can be installed simply by double clicking the
|
343
|
+
The LaunchBar action can be installed simply by double clicking the
|
344
|
+
`.lbaction` file in Finder. The CLI is not required for the LaunchBar
|
345
|
+
action to function.
|
207
346
|
|
208
|
-
Once installed, run the action (type `snib` and hit return on the result) to
|
347
|
+
Once installed, run the action (type `snib` and hit return on the result) to
|
348
|
+
select your Snippets folder.
|
209
349
|
|
210
350
|
### Usage
|
211
351
|
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: snibbets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.40
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brett Terpstra
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-01-18 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: bundler
|
@@ -246,7 +245,6 @@ files:
|
|
246
245
|
- ".ruby-version"
|
247
246
|
- CHANGELOG.md
|
248
247
|
- Gemfile
|
249
|
-
- Gemfile.lock
|
250
248
|
- LICENSE.txt
|
251
249
|
- README.md
|
252
250
|
- README.rdoc
|
@@ -266,7 +264,6 @@ files:
|
|
266
264
|
- lib/snibbets/menu.rb
|
267
265
|
- lib/snibbets/os.rb
|
268
266
|
- lib/snibbets/string.rb
|
269
|
-
- lib/snibbets/todo_spec.rb
|
270
267
|
- lib/snibbets/version.rb
|
271
268
|
- lib/snibbets/which.rb
|
272
269
|
- lib/themes/atom-one-dark.theme
|
@@ -295,6 +292,7 @@ files:
|
|
295
292
|
- lib/themes/solarized-dark.theme
|
296
293
|
- lib/themes/solarized-light.theme
|
297
294
|
- lib/themes/vim-dark.theme
|
295
|
+
- mise.toml
|
298
296
|
- scripts/fixreadme.rb
|
299
297
|
- snibbets.gemspec
|
300
298
|
- src/_README.md
|
@@ -308,7 +306,6 @@ metadata:
|
|
308
306
|
bug_tracker_uri: https://github.com/ttscoff/snibbets/issues
|
309
307
|
changelog_uri: https://github.com/ttscoff/snibbets/blob/main/CHANGELOG.md
|
310
308
|
github_repo: git@github.com:ttscoff/snibbets.git
|
311
|
-
post_install_message:
|
312
309
|
rdoc_options:
|
313
310
|
- "--title"
|
314
311
|
- snibbets
|
@@ -330,8 +327,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
330
327
|
- !ruby/object:Gem::Version
|
331
328
|
version: '0'
|
332
329
|
requirements: []
|
333
|
-
rubygems_version: 3.2
|
334
|
-
signing_key:
|
330
|
+
rubygems_version: 3.6.2
|
335
331
|
specification_version: 4
|
336
332
|
summary: Snibbets
|
337
333
|
test_files: []
|
data/Gemfile.lock
DELETED
@@ -1,125 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
snibbets (2.0.39)
|
5
|
-
mdless (~> 1.0, >= 1.0.32)
|
6
|
-
tty-reader (~> 0.9, >= 0.9.0)
|
7
|
-
tty-which (~> 0.5, >= 0.5.0)
|
8
|
-
|
9
|
-
GEM
|
10
|
-
remote: https://rubygems.org/
|
11
|
-
specs:
|
12
|
-
ansi (1.5.0)
|
13
|
-
ast (2.4.2)
|
14
|
-
awesome_print (1.9.2)
|
15
|
-
diff-lcs (1.5.0)
|
16
|
-
docile (1.4.0)
|
17
|
-
gem-release (2.2.2)
|
18
|
-
json (2.6.3)
|
19
|
-
language_server-protocol (3.17.0.3)
|
20
|
-
lint_roller (1.0.0)
|
21
|
-
mdless (1.0.37)
|
22
|
-
multi_json (1.15.0)
|
23
|
-
parallel (1.23.0)
|
24
|
-
parse_gemspec (1.0.0)
|
25
|
-
parse_gemspec-cli (1.0.0)
|
26
|
-
multi_json
|
27
|
-
parse_gemspec
|
28
|
-
thor
|
29
|
-
parser (3.2.2.3)
|
30
|
-
ast (~> 2.4.1)
|
31
|
-
racc
|
32
|
-
racc (1.7.1)
|
33
|
-
rainbow (3.1.1)
|
34
|
-
rake (13.0.6)
|
35
|
-
rdoc (6.3.4.1)
|
36
|
-
regexp_parser (2.8.1)
|
37
|
-
rexml (3.2.5)
|
38
|
-
rspec (3.12.0)
|
39
|
-
rspec-core (~> 3.12.0)
|
40
|
-
rspec-expectations (~> 3.12.0)
|
41
|
-
rspec-mocks (~> 3.12.0)
|
42
|
-
rspec-core (3.12.2)
|
43
|
-
rspec-support (~> 3.12.0)
|
44
|
-
rspec-expectations (3.12.3)
|
45
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
46
|
-
rspec-support (~> 3.12.0)
|
47
|
-
rspec-mocks (3.12.5)
|
48
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
49
|
-
rspec-support (~> 3.12.0)
|
50
|
-
rspec-support (3.12.0)
|
51
|
-
rubocop (1.52.1)
|
52
|
-
json (~> 2.3)
|
53
|
-
parallel (~> 1.10)
|
54
|
-
parser (>= 3.2.2.3)
|
55
|
-
rainbow (>= 2.2.2, < 4.0)
|
56
|
-
regexp_parser (>= 1.8, < 3.0)
|
57
|
-
rexml (>= 3.2.5, < 4.0)
|
58
|
-
rubocop-ast (>= 1.28.0, < 2.0)
|
59
|
-
ruby-progressbar (~> 1.7)
|
60
|
-
unicode-display_width (>= 2.4.0, < 3.0)
|
61
|
-
rubocop-ast (1.29.0)
|
62
|
-
parser (>= 3.2.1.0)
|
63
|
-
rubocop-performance (1.18.0)
|
64
|
-
rubocop (>= 1.7.0, < 2.0)
|
65
|
-
rubocop-ast (>= 0.4.0)
|
66
|
-
ruby-progressbar (1.13.0)
|
67
|
-
simplecov (0.22.0)
|
68
|
-
docile (~> 1.1)
|
69
|
-
simplecov-html (~> 0.11)
|
70
|
-
simplecov_json_formatter (~> 0.1)
|
71
|
-
simplecov-console (0.9.1)
|
72
|
-
ansi
|
73
|
-
simplecov
|
74
|
-
terminal-table
|
75
|
-
simplecov-html (0.12.3)
|
76
|
-
simplecov_json_formatter (0.1.4)
|
77
|
-
standard (1.29.0)
|
78
|
-
language_server-protocol (~> 3.17.0.2)
|
79
|
-
lint_roller (~> 1.0)
|
80
|
-
rubocop (~> 1.52.0)
|
81
|
-
standard-custom (~> 1.0.0)
|
82
|
-
standard-performance (~> 1.1.0)
|
83
|
-
standard-custom (1.0.1)
|
84
|
-
lint_roller (~> 1.0)
|
85
|
-
standard-performance (1.1.0)
|
86
|
-
lint_roller (~> 1.0)
|
87
|
-
rubocop-performance (~> 1.18.0)
|
88
|
-
terminal-table (3.0.2)
|
89
|
-
unicode-display_width (>= 1.1.1, < 3)
|
90
|
-
thor (1.2.2)
|
91
|
-
tty-cursor (0.7.1)
|
92
|
-
tty-reader (0.9.0)
|
93
|
-
tty-cursor (~> 0.7)
|
94
|
-
tty-screen (~> 0.8)
|
95
|
-
wisper (~> 2.0)
|
96
|
-
tty-screen (0.8.2)
|
97
|
-
tty-which (0.5.0)
|
98
|
-
unicode-display_width (2.4.2)
|
99
|
-
wisper (2.0.1)
|
100
|
-
yard (0.9.36)
|
101
|
-
|
102
|
-
PLATFORMS
|
103
|
-
arm64-darwin-20
|
104
|
-
arm64-darwin-21
|
105
|
-
ruby
|
106
|
-
x64-mingw32
|
107
|
-
x86_64-darwin-20
|
108
|
-
x86_64-linux
|
109
|
-
|
110
|
-
DEPENDENCIES
|
111
|
-
awesome_print (~> 1.9)
|
112
|
-
bundler (~> 2.0)
|
113
|
-
gem-release (~> 2.2)
|
114
|
-
parse_gemspec-cli (~> 1.0)
|
115
|
-
rake (~> 13.0)
|
116
|
-
rdoc (~> 6.3.4.1)
|
117
|
-
rspec (~> 3.0)
|
118
|
-
simplecov (~> 0.21)
|
119
|
-
simplecov-console (~> 0.9)
|
120
|
-
snibbets!
|
121
|
-
standard (~> 1.3)
|
122
|
-
yard (~> 0.9, >= 0.9.36)
|
123
|
-
|
124
|
-
BUNDLED WITH
|
125
|
-
2.2.29
|
data/lib/snibbets/todo_spec.rb
DELETED