snibbets 2.0.11 → 2.0.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md.orig +18 -0
- data/Gemfile.lock +2 -1
- data/README.md +27 -25
- data/bin/snibbets +4 -0
- data/buildnotes.md +4 -1
- data/lib/snibbets/config.rb +1 -0
- data/lib/snibbets/string.rb +14 -4
- data/lib/snibbets/version.rb +1 -1
- data/lib/snibbets.rb +5 -1
- data/snibbets.gemspec +1 -1
- metadata +12 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72d22da7e8723b49ee57a4b244c36dfc798f3f73eee8b936c0538eb09028f302
|
4
|
+
data.tar.gz: e0fa3c991a45448cdb6119583e34f631cc99e8028cb890c86fcc2a0a2bb8b2b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d15bffd5530b1d267c48f833d4a8f8711538eb8d4bcf48e21acdfe7247565f239dc46c0ce3938fa0e5b86727faf9afa4a86e3f32507ad9b590edeb968622c7c6
|
7
|
+
data.tar.gz: 5d910f25059137ade7c625dc1d8ecb207ac93cc199aa03385bc91f9c359a9233a5858481df5a598b4f3f80293e3807bdcf1b03f1cf838e4c6a03cfe807a08075
|
data/CHANGELOG.md.orig
CHANGED
@@ -1,3 +1,21 @@
|
|
1
|
+
### 2.0.13
|
2
|
+
|
3
|
+
2023-04-15 19:57
|
4
|
+
|
5
|
+
#### NEW
|
6
|
+
|
7
|
+
- Option to include blockquotes (>) in output
|
8
|
+
|
9
|
+
### 2.0.12
|
10
|
+
|
11
|
+
2023-04-15 19:28
|
12
|
+
|
13
|
+
#### FIXED
|
14
|
+
|
15
|
+
- Lowered minimum ruby version to allow Ruby 2.6
|
16
|
+
- Failure to recognize snippet if title is on first line of file
|
17
|
+
- Errantly discarding first snippet in file with multiple snippets
|
18
|
+
|
1
19
|
### 2.0.11
|
2
20
|
|
3
21
|
2023-04-15 19:06
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,19 +1,14 @@
|
|
1
|
-
# Snibbets
|
2
1
|
|
3
|
-
[![RubyGems.org](https://img.shields.io/gem/v/snibbets)](https://rubygems.org/gems/snibbets)
|
4
|
-
[![GitHub Actions](https://github.com/ttscoff/snibbets/actions/workflows/check.yml/badge.svg)](https://github.com/ttscoff/snibbets/actions/workflows/check.yml)
|
5
|
-
|
6
|
-
<!--README-->
|
7
2
|
A tool for accessing code snippets contained in a folder of plain text Markdown files.
|
8
3
|
|
9
4
|
Snibbets allows me to keep code snippets in raw files, not relying on a dedicated code snippet app. I can collect and edit my snippets using a text editor, nvALT (nvUltra), or simply by saving snippets from my clipboard to a text file using *NIX redirection on the command line. I can add descriptive names and extended descriptions/notes to code snippets using standard Markdown.
|
10
5
|
|
11
6
|
What Snibbets does is simply allow a quick search for a specific snippet that I can either output to the terminal, pipe to my clipboard, or access via LaunchBar (via the included LaunchBar Action). It's basically a wrapper for `find` and `grep` with the ability to separate code blocks from other text in my Markdown files.
|
12
7
|
|
13
|
-
|
8
|
+
|
14
9
|
![Snibbets in action](https://cdn3.brettterpstra.com/uploads/2023/04/snibbets2.gif)
|
15
|
-
|
16
|
-
|
10
|
+
|
11
|
+
|
17
12
|
|
18
13
|
## Collecting Snippets
|
19
14
|
|
@@ -56,12 +51,12 @@ Snibbets requires Ruby 3.0+. On recent versions of macOS, this is not included b
|
|
56
51
|
|
57
52
|
If available, menus are generated by [fzf] or [gum]. If neither are available, a basic Readline menu system will be displayed, so neither are required, just nice to have as they provide fuzzy filtering, scrolling, and type-ahead completion.
|
58
53
|
|
59
|
-
[homebrew]: https://brew.sh/ "Homebrew
|
54
|
+
[homebrew]: https://brew.sh/ "Homebrew???The Missing Package Manager for macOS (or Linux)"
|
60
55
|
[rbenv]: https://github.com/rbenv/rbenv "rbenv/rbenv:Manage your app's Ruby environment"
|
61
56
|
[rvm]: https://rvm.io/ "Ruby Version Manager"
|
62
57
|
[asdf]: https://asdf-vm.com/ "ASDF environment manager"
|
63
58
|
[fzf]: https://github.com/junegunn/fzf "junegunn/fzf:A command-line fuzzy finder"
|
64
|
-
[gum]: https://github.com/charmbracelet/gum "charmbracelet/gum:A tool for glamorous shell scripts
|
59
|
+
[gum]: https://github.com/charmbracelet/gum "charmbracelet/gum:A tool for glamorous shell scripts ????"
|
65
60
|
|
66
61
|
### Installation
|
67
62
|
|
@@ -86,6 +81,7 @@ copy: false
|
|
86
81
|
editor:
|
87
82
|
extension: md
|
88
83
|
highlight: false
|
84
|
+
include_blockquotes: false
|
89
85
|
interactive: true
|
90
86
|
launchbar: false
|
91
87
|
menus:
|
@@ -110,6 +106,8 @@ The `editor` setting is used to open the config file, and to open snippets for e
|
|
110
106
|
|
111
107
|
The `highlight` key turns on syntax highlighting. This requires that either `pygmentize` or `skyligting` is available on your system (both available via package managers like Homebrew). This feature is still in development and results may be mixed.
|
112
108
|
|
109
|
+
The `include_blockquotes` setting determines whether blockquotes are included in the output. By default, Snibbets removes everything other than code blocks (indented or fenced) from the output it displays. But if you want to include a note that you'll see on the command line, you can put it in a block quote by preceding each line you want to preserve with a right angle bracket (`>`).
|
110
|
+
|
113
111
|
The `interactive` setting determines whether menus will be displayed. This should generally be true, but if you want silent operation that just displays the best match automatically, set it to false.
|
114
112
|
|
115
113
|
The `menus` setting will determine what method is used for displaying interactive menus. If this is not set, it will be automatically determined in the order of `fzf`, `gum`, and `console`. You can manually choose to use one of these options over another by making it the `menus` setting.
|
@@ -118,20 +116,25 @@ The `name_only` key will permanently set Snibbets to only search for snippets by
|
|
118
116
|
|
119
117
|
### Usage
|
120
118
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
-
|
119
|
+
```
|
120
|
+
Snibbets v2.0.13
|
121
|
+
|
122
|
+
Usage: snibbets [options] query
|
123
|
+
-a, --all If a file contains multiple snippets, output all of them (no menu)
|
124
|
+
-c, --[no-]copy Copy the output to the clibpoard (also displays on STDOUT)
|
125
|
+
-e, --edit Open the selected snippet in your configured editor
|
126
|
+
-n, --[no-]name-only Only search file names, not content
|
127
|
+
-o, --output FORMAT Output format (json|launchbar|*raw)
|
128
|
+
-p, --paste, --new Interactively create a new snippet from clipboard contents (Mac only)
|
129
|
+
-q, --quiet Skip menus and display first match
|
130
|
+
-s, --source FOLDER Snippets folder to search
|
131
|
+
--configure Open the configuration file in your default editor
|
132
|
+
--[no-]blockquotes Include block quotes in output
|
133
|
+
--highlight Use pygments or skylighting to syntax highlight (if installed)
|
134
|
+
--save Save the current command line options to the YAML configuration
|
135
|
+
-h, --help Display this screen
|
136
|
+
-v, --version Display version information
|
137
|
+
```
|
135
138
|
|
136
139
|
If your Snippets folder is set in the config, simply running `snibbets [search query]` will perform the search and output the code blocks, presenting a menu if more than one match is found or the target file contains more than one snippet. Selected contents are output raw to STDOUT.
|
137
140
|
|
@@ -173,4 +176,3 @@ Once installed, run the action (type `snib` and hit return on the result) to sel
|
|
173
176
|
### Usage
|
174
177
|
|
175
178
|
Type `snib` to bring the Action up, then hit Space to enter your query text. Matching files will be presented. If the selected file contains more than one snippet, a list of snippets (based on ATX headers in the file) will be presented as a child menu. Selecting a snippet and hitting return will copy the associated code block to the clipboard.
|
176
|
-
<!--END README-->
|
data/bin/snibbets
CHANGED
@@ -64,6 +64,10 @@ module Snibbets
|
|
64
64
|
@arguments[:edit_config] = true
|
65
65
|
end
|
66
66
|
|
67
|
+
opts.on('--[no-]blockquotes', 'Include block quotes in output') do |v|
|
68
|
+
options[:include_blockquotes] = v
|
69
|
+
end
|
70
|
+
|
67
71
|
opts.on('--highlight', 'Use pygments or skylighting to syntax highlight (if installed)') do
|
68
72
|
options[:highlight] = true
|
69
73
|
end
|
data/buildnotes.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
template: gem, git, gli, project
|
2
2
|
executable: na
|
3
|
-
readme: README.md
|
3
|
+
readme: src/README.md
|
4
4
|
changelog: CHANGELOG.md
|
5
5
|
project: snibbets
|
6
6
|
|
@@ -20,6 +20,7 @@ You no longer need to manually bump the version, it will be incremented when thi
|
|
20
20
|
#!/bin/bash
|
21
21
|
|
22
22
|
changelog -u
|
23
|
+
scripts/fixreadme.rb
|
23
24
|
changelog | git commit -a -F -
|
24
25
|
git pull
|
25
26
|
git push
|
@@ -29,6 +30,8 @@ git push
|
|
29
30
|
@include(project:Update Blog Project) Update Blog Project
|
30
31
|
@run(rake bump[patch]) Bump Version
|
31
32
|
|
33
|
+
@run(git commit -am 'Version bump')
|
34
|
+
|
32
35
|
@after
|
33
36
|
Don't forget to publish the website!
|
34
37
|
@end
|
data/lib/snibbets/config.rb
CHANGED
data/lib/snibbets/string.rb
CHANGED
@@ -20,8 +20,8 @@ module Snibbets
|
|
20
20
|
input = dup
|
21
21
|
lines = input.split(/\n/)
|
22
22
|
loop do
|
23
|
-
line = lines
|
24
|
-
|
23
|
+
line = lines[0]
|
24
|
+
lines.shift if line =~ /^\s*[A-Z\s]+\w:\s*\S+/i || line =~ /^-{3,}\s*$/
|
25
25
|
|
26
26
|
break
|
27
27
|
end
|
@@ -107,7 +107,17 @@ module Snibbets
|
|
107
107
|
counter = 0
|
108
108
|
code_blocks = {}
|
109
109
|
|
110
|
-
sans_blocks = content.
|
110
|
+
sans_blocks = content.dup
|
111
|
+
|
112
|
+
if Snibbets.options[:include_blockquotes]
|
113
|
+
sans_blocks = sans_blocks.gsub(/(?mi)(^(>.*?)(\n|$))+/) do
|
114
|
+
counter += 1
|
115
|
+
code_blocks["block#{counter}"] = Regexp.last_match(0).gsub(/^> *(?=\S)/, '# ')
|
116
|
+
"<block#{counter}>\n"
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
sans_blocks = sans_blocks.gsub(/^(`{3,})(\w+)?\s*\n(.*?)\n\1/m) do
|
111
121
|
counter += 1
|
112
122
|
code_blocks["block#{counter}"] = Regexp.last_match(3)
|
113
123
|
"<block#{counter}>\n"
|
@@ -133,7 +143,7 @@ module Snibbets
|
|
133
143
|
parts = sans_blocks.gsub(/\n{2,}/, "\n\n").split(/^#+/)
|
134
144
|
end
|
135
145
|
|
136
|
-
parts.shift if parts.count > 1
|
146
|
+
# parts.shift if parts.count > 1
|
137
147
|
|
138
148
|
parts.each do |part|
|
139
149
|
lines = part.split(/\n/).strip_empty
|
data/lib/snibbets/version.rb
CHANGED
data/lib/snibbets.rb
CHANGED
@@ -34,6 +34,10 @@ end
|
|
34
34
|
|
35
35
|
module Snibbets
|
36
36
|
class << self
|
37
|
+
def change_query(query)
|
38
|
+
@query = query
|
39
|
+
end
|
40
|
+
|
37
41
|
# Search the snippets directory for query using find and grep
|
38
42
|
def search(try: 0)
|
39
43
|
folder = File.expand_path(Snibbets.options[:source])
|
@@ -270,7 +274,7 @@ module Snibbets
|
|
270
274
|
else
|
271
275
|
snippets.push({ 'title' => 'All snippets', 'code' => '' })
|
272
276
|
|
273
|
-
answer =
|
277
|
+
answer = Menu.menu(snippets, filename: File.basename(filepath, '.md'), title: 'Select snippet', query: @query)
|
274
278
|
|
275
279
|
if answer['title'] == 'All snippets'
|
276
280
|
snippets.delete_if { |s| s['title'] == 'All snippets'}
|
data/snibbets.gemspec
CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.description = "A plain text code snippet manager"
|
13
13
|
spec.homepage = "https://github.com/ttscoff/snibbets"
|
14
14
|
spec.license = "MIT"
|
15
|
-
spec.required_ruby_version = ">=
|
15
|
+
spec.required_ruby_version = ">= 2.6.0"
|
16
16
|
|
17
17
|
spec.metadata["homepage_uri"] = spec.homepage
|
18
18
|
spec.metadata["source_code_uri"] = spec.homepage
|
metadata
CHANGED
@@ -1,11 +1,11 @@
|
|
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.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brett Terpstra
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2023-04-16 00:00:00.000000000 Z
|
@@ -174,22 +174,22 @@ dependencies:
|
|
174
174
|
name: tty-which
|
175
175
|
requirement: !ruby/object:Gem::Requirement
|
176
176
|
requirements:
|
177
|
-
- - "~>"
|
178
|
-
- !ruby/object:Gem::Version
|
179
|
-
version: '0.5'
|
180
177
|
- - ">="
|
181
178
|
- !ruby/object:Gem::Version
|
182
179
|
version: 0.5.0
|
180
|
+
- - "~>"
|
181
|
+
- !ruby/object:Gem::Version
|
182
|
+
version: '0.5'
|
183
183
|
type: :runtime
|
184
184
|
prerelease: false
|
185
185
|
version_requirements: !ruby/object:Gem::Requirement
|
186
186
|
requirements:
|
187
|
-
- - "~>"
|
188
|
-
- !ruby/object:Gem::Version
|
189
|
-
version: '0.5'
|
190
187
|
- - ">="
|
191
188
|
- !ruby/object:Gem::Version
|
192
189
|
version: 0.5.0
|
190
|
+
- - "~>"
|
191
|
+
- !ruby/object:Gem::Version
|
192
|
+
version: '0.5'
|
193
193
|
description: A plain text code snippet manager
|
194
194
|
email: me@brettterpstra.com
|
195
195
|
executables:
|
@@ -230,7 +230,7 @@ metadata:
|
|
230
230
|
bug_tracker_uri: https://github.com/ttscoff/snibbets/issues
|
231
231
|
changelog_uri: https://github.com/ttscoff/snibbets/blob/main/CHANGELOG.md
|
232
232
|
github_repo: git@github.com:ttscoff/snibbets.git
|
233
|
-
post_install_message:
|
233
|
+
post_install_message:
|
234
234
|
rdoc_options:
|
235
235
|
- "--title"
|
236
236
|
- na
|
@@ -245,15 +245,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
245
245
|
requirements:
|
246
246
|
- - ">="
|
247
247
|
- !ruby/object:Gem::Version
|
248
|
-
version:
|
248
|
+
version: 2.6.0
|
249
249
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
250
250
|
requirements:
|
251
251
|
- - ">="
|
252
252
|
- !ruby/object:Gem::Version
|
253
253
|
version: '0'
|
254
254
|
requirements: []
|
255
|
-
rubygems_version: 3.
|
256
|
-
signing_key:
|
255
|
+
rubygems_version: 3.0.3.1
|
256
|
+
signing_key:
|
257
257
|
specification_version: 4
|
258
258
|
summary: Snibbets
|
259
259
|
test_files: []
|