snibbets 2.0.22 → 2.0.24
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +31 -1
- data/Gemfile.lock +1 -1
- data/README.md +5 -4
- data/bin/snibbets +4 -0
- data/buildnotes.md +5 -5
- data/lib/snibbets/config.rb +2 -1
- data/lib/snibbets/version.rb +1 -1
- data/lib/snibbets.rb +25 -8
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26658cec9cb3753794a7f34d33e8f22f251096668251eb776e884e5f65834e4b
|
4
|
+
data.tar.gz: 151eb76ee1036d1724c7618e8c8c1aa454039aeaca90abb58e839e9906d616b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30f9cc2d5bf2dd06ddca1abbf7fb7c360811008b3f90f0066661cd57dfac02c936deb6ec5fc08441102bdaba06b9308f003cb7cf0a179788e6a907124ee21e8a
|
7
|
+
data.tar.gz: bd723669573ace92c3c8b10b8c39c22c0f6483d46e217852788e257cd924ef70c86fb25316b8e9b1a0144409d284947059955088e6b19ccf2ecc198dbd10b89e
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,33 @@
|
|
1
|
+
### 2.0.24
|
2
|
+
|
3
|
+
2023-04-16 10:49
|
4
|
+
|
5
|
+
#### NEW
|
6
|
+
|
7
|
+
- `--nvultra` will open the selected snippet in nvUltra
|
8
|
+
|
9
|
+
#### IMPROVED
|
10
|
+
|
11
|
+
- Use Readline for entering info with `--paste`, allows for better editing experience
|
12
|
+
- Allow `--edit` with `--paste` to open the new snippet in your editor immediately
|
13
|
+
|
14
|
+
#### FIXED
|
15
|
+
|
16
|
+
- Code indentation with `--paste`
|
17
|
+
|
18
|
+
### 2.0.23
|
19
|
+
|
20
|
+
2023-04-16 10:33
|
21
|
+
|
22
|
+
#### IMPROVED
|
23
|
+
|
24
|
+
- Use Readline for entering info with `--paste`, allows for better editing experience
|
25
|
+
- Allow `--edit` with `--paste` to open the new snippet in your editor immediately
|
26
|
+
|
27
|
+
#### FIXED
|
28
|
+
|
29
|
+
- Code indentation with `--paste`
|
30
|
+
|
1
31
|
### 2.0.22
|
2
32
|
|
3
33
|
2023-04-16 09:33
|
@@ -169,6 +199,6 @@
|
|
169
199
|
|
170
200
|
- Refactor script as modules and classes
|
171
201
|
|
172
|
-
|
202
|
+
### 2.0.2
|
173
203
|
|
174
204
|
Initial release as a gem
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -24,7 +24,7 @@ The name of the file should be the description of the snippet, at least in the c
|
|
24
24
|
|
25
25
|
You can combine multiple snippets in a file, though. For example, I have a file called 'Ruby hash snippets.rb.md'. That file contains an array of useful snippets, and each one has a descriptive title in an h3 header above it. Those (ATX) headers are used to split the file, and when you search from the command line, you'll get a menu of all of the snippets in the selected file. (And if you have [fzf](https://github.com/junegunn/fzf) or [gum](https://github.com/charmbracelet/gum) installed, you can quickly filter through with fuzzy searching and find exactly what you need.)
|
26
26
|
|
27
|
-
If a file contains multiple snippets, they should be separated by ATX-style headers (one or more `#`) describing the snippets. Additional
|
27
|
+
If a file contains multiple snippets, they should be separated by ATX-style headers (one or more `#`) describing the snippets. Additional descriptions and notes can be included outside of the code block. Notes are not output on the console, only the code is displayed. If you want a note to be included in console output, make it a blockquote by preceding it with `>`.
|
28
28
|
|
29
29
|
A file titled `unix find.bash.md`:
|
30
30
|
|
@@ -45,13 +45,13 @@ A file titled `unix find.bash.md`:
|
|
45
45
|
|
46
46
|
find /dir/dir -type f -mtime +540 -mtime -720 -printf \"%p\",\"%s\",\"%AD\",|"%TD\"\\n > /dir/dir/output.csv
|
47
47
|
|
48
|
-
You can include MultiMarkdown metadata in your snippets, either in a YAML block or just at the top of the file with raw key/value pairs. I mostly use this for adding tags, which are then synced to macOS tags when I save. It makes it easy to search for snippets in [nvUltra](https://nvultra.com/), and also allows you to do searches like `snibbets tag:javascript url parser`
|
48
|
+
You can include MultiMarkdown metadata in your snippets, either in a YAML block or just at the top of the file with raw key/value pairs. I mostly use this for adding tags, which are then synced to macOS tags when I save. It makes it easy to search for snippets in [nvUltra](https://nvultra.com/), and also allows you to do searches like `snibbets tag:javascript url parser` with Snibbets.
|
49
49
|
|
50
50
|
## CLI
|
51
51
|
|
52
52
|
### Dependencies
|
53
53
|
|
54
|
-
Snibbets requires Ruby 3.0+. On recent versions of macOS, this is not included by default. You can install it via the Command Line Tools from Apple. On macOS and most other systems, you can use something like [Homebrew], [rbenv], [rvm], or [asdf] to install Ruby 3.
|
54
|
+
Snibbets requires Ruby 3.0+. On recent versions of macOS, this is not included by default. You can install it via the Command Line Tools from Apple. On macOS and most other systems, you can also use something like [Homebrew], [rbenv], [rvm], or [asdf] to install Ruby 3.
|
55
55
|
|
56
56
|
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.
|
57
57
|
|
@@ -155,7 +155,7 @@ Snibbet's implementation of Skylighting has limited but better-looking themes, a
|
|
155
155
|
### Usage
|
156
156
|
|
157
157
|
```
|
158
|
-
Snibbets v2.0.
|
158
|
+
Snibbets v2.0.24
|
159
159
|
|
160
160
|
Usage: snibbets [options] query
|
161
161
|
-a, --all If a file contains multiple snippets, output all of them (no menu)
|
@@ -169,6 +169,7 @@ Usage: snibbets [options] query
|
|
169
169
|
--configure Open the configuration file in your default editor
|
170
170
|
--[no-]blockquotes Include block quotes in output
|
171
171
|
--[no-]highlight Use pygments or skylighting to syntax highlight (if installed)
|
172
|
+
--nvultra Open the result in nvUltra
|
172
173
|
--save Save the current command line options to the YAML configuration
|
173
174
|
-h, --help Display this screen
|
174
175
|
-v, --version Display version information
|
data/bin/snibbets
CHANGED
@@ -81,6 +81,10 @@ module Snibbets
|
|
81
81
|
options[:highlight] = v
|
82
82
|
end
|
83
83
|
|
84
|
+
opts.on('--nvultra', 'Open the result in nvUltra') do
|
85
|
+
arguments[:nvultra] = true
|
86
|
+
end
|
87
|
+
|
84
88
|
opts.on('--save', 'Save the current command line options to the YAML configuration') do
|
85
89
|
arguments[:save_config] = true
|
86
90
|
end
|
data/buildnotes.md
CHANGED
@@ -8,7 +8,11 @@ project: snibbets
|
|
8
8
|
|
9
9
|
A plain text snippet manager
|
10
10
|
|
11
|
-
##
|
11
|
+
## Develop
|
12
|
+
|
13
|
+
@run(subl .)
|
14
|
+
|
15
|
+
## Dummy
|
12
16
|
|
13
17
|
@run(bundle exec bin/snibbets $@)
|
14
18
|
|
@@ -35,7 +39,3 @@ git push
|
|
35
39
|
@after
|
36
40
|
Don't forget to publish the website!
|
37
41
|
@end
|
38
|
-
|
39
|
-
## Plans
|
40
|
-
|
41
|
-
|
data/lib/snibbets/config.rb
CHANGED
data/lib/snibbets/version.rb
CHANGED
data/lib/snibbets.rb
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'cgi'
|
4
|
+
require 'erb'
|
5
|
+
require 'fileutils'
|
6
|
+
require 'json'
|
7
|
+
require 'open3'
|
3
8
|
require 'optparse'
|
4
9
|
require 'readline'
|
5
|
-
require 'json'
|
6
|
-
require 'cgi'
|
7
10
|
require 'shellwords'
|
8
|
-
require 'yaml'
|
9
|
-
require 'fileutils'
|
10
|
-
require 'tty-which'
|
11
11
|
require 'tty-reader'
|
12
|
-
require '
|
12
|
+
require 'tty-which'
|
13
|
+
require 'yaml'
|
13
14
|
require_relative 'snibbets/version'
|
14
15
|
require_relative 'snibbets/config'
|
15
16
|
require_relative 'snibbets/which'
|
@@ -111,6 +112,14 @@ module Snibbets
|
|
111
112
|
search(try: try + 1) if matches.empty?
|
112
113
|
end
|
113
114
|
|
115
|
+
def open_snippet_in_nvultra(filepath)
|
116
|
+
notebook = Snibbets.options[:source].gsub(/ /, '%20')
|
117
|
+
note = ERB::Util.url_encode(File.basename(filepath, '.md'))
|
118
|
+
url = "x-nvultra://open?notebook=#{notebook}¬e=#{note}"
|
119
|
+
puts url
|
120
|
+
`open '#{url}'`
|
121
|
+
end
|
122
|
+
|
114
123
|
def open_snippet_in_editor(filepath)
|
115
124
|
editor = Snibbets.options[:editor] || Snibbets::Config.best_editor
|
116
125
|
|
@@ -169,8 +178,8 @@ module Snibbets
|
|
169
178
|
exts = langs if exts.empty?
|
170
179
|
|
171
180
|
filename = "#{title}#{exts.map { |x| ".#{x}"}.join('')}.#{Snibbets.options[:extension]}"
|
172
|
-
|
173
|
-
File.open(
|
181
|
+
filepath = File.join(File.expand_path(Snibbets.options[:source]), filename)
|
182
|
+
File.open(filepath, 'w') do |f|
|
174
183
|
f.puts "tags: #{tags.join(', ')}
|
175
184
|
|
176
185
|
```
|
@@ -179,6 +188,9 @@ module Snibbets
|
|
179
188
|
end
|
180
189
|
|
181
190
|
puts "New snippet written to #{filename}."
|
191
|
+
|
192
|
+
open_snippet_in_editor(filepath) if Snibbets.arguments[:edit_snippet]
|
193
|
+
open_snippet_in_nvultra(filepath) if Snibbets.arguments[:nvultra]
|
182
194
|
end
|
183
195
|
|
184
196
|
def handle_launchbar(results)
|
@@ -252,6 +264,11 @@ module Snibbets
|
|
252
264
|
Process.exit 0
|
253
265
|
end
|
254
266
|
|
267
|
+
if Snibbets.arguments[:nvultra]
|
268
|
+
open_snippet_in_nvultra(filepath)
|
269
|
+
Process.exit 0
|
270
|
+
end
|
271
|
+
|
255
272
|
snippets = input.snippets
|
256
273
|
|
257
274
|
if snippets.empty?
|