snibbets 2.0.37 → 2.0.38

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8c4679a3bc38da47aa45d83f80813da7fc15ab4c6ce543c262054e118fc28a15
4
- data.tar.gz: b902be45475479939390cf651b6c405ff692ca397bde731f2314a50c2ab02218
3
+ metadata.gz: dbd4e4bc29849bd8b02294a6773dde5b729b4cfd36dc0a6abe415857d856f79e
4
+ data.tar.gz: 8c998d26d1ca7938ff5275cbc5ba6a0c79f1d035b7b03a702cffc7dff1e91c27
5
5
  SHA512:
6
- metadata.gz: 466cdfa3acd6966e3942ab2a9d598132bb23833b85c7a293443b9346c5744b96d93a14d0858f489989e6e82e43dcd493c2404ecb25873a3e882912bbe624b644
7
- data.tar.gz: 69e63c3bf7aa31587f37956b4c8a370e663199292d3b7b21fb59298400887b4e4c441f22939d5e1de0048e8bba7f892d4d545e0b635050a306fb244e7a4c1148
6
+ metadata.gz: 3e2e1b0d3a082f6cc046f1033447d077a34f563f92e36396650c1c5122205a73314e9bba4fade2739c90bf98ed869d8667d39be08ef0d496fed7fc6644531770
7
+ data.tar.gz: 95a9c41d2f5ae6ffeba69946ceaf48c2c0f9f748555f1e8c32c5ed0369c8d4a5c0adf482f9064022a7a72c931fe7f03d2be17814e3b5d1edd31d6e00f369798e
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ### 2.0.38
2
+
3
+ 2024-08-21 08:54
4
+
5
+ #### NEW
6
+
7
+ - `--edit-new` will create a new snippet and open it in configured editor, prompting for title and language
8
+ - `--edit-new-titled FILENAME` will create and edit a new snippet with title, language determined by filename extension or prompted for if missing
9
+
1
10
  ### 2.0.36
2
11
 
3
12
  2024-04-08 14:25
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- snibbets (2.0.37)
4
+ snibbets (2.0.38)
5
5
  mdless (~> 1.0, >= 1.0.32)
6
6
  tty-reader (~> 0.9, >= 0.9.0)
7
7
  tty-which (~> 0.5, >= 0.5.0)
data/README.md CHANGED
@@ -1,17 +1,20 @@
1
1
 
2
+
2
3
  [![RubyGems.org](https://img.shields.io/gem/v/snibbets)](https://rubygems.org/gems/snibbets)
3
4
 
4
5
  A tool for accessing code snippets contained in a folder of plain text Markdown files.
5
6
 
6
- 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.
7
+ 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.
7
8
 
8
9
  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.
9
10
 
10
11
 
12
+
11
13
  ![Snibbets in action](https://cdn3.brettterpstra.com/uploads/2023/04/snibbets2.gif)
12
14
 
13
15
 
14
16
 
17
+
15
18
  ## Collecting Snippets
16
19
 
17
20
  Snibbets is designed to work with a folder containing Markdown files. Each Markdown file can have somewhat flexible formatting, as long as there's at least one code block (either indented by 4 spaces/1 tab or fenced with backticks).
@@ -22,7 +25,7 @@ The name of the file should be the description of the snippet, at least in the c
22
25
 
23
26
  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.)
24
27
 
25
- 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
+ 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 `>`.
26
29
 
27
30
  A file titled `unix find.bash.md`:
28
31
 
@@ -80,13 +83,13 @@ Default config:
80
83
  ---
81
84
  all: false
82
85
  copy: false
83
- editor:
86
+ editor:
84
87
  extension: md
85
88
  highlight: false
86
89
  include_blockquotes: false
87
90
  interactive: true
88
91
  launchbar: false
89
- menus:
92
+ menus:
90
93
  name_only: false
91
94
  output: raw
92
95
  source: "~/Dropbox/Snippets"
@@ -110,7 +113,7 @@ The `editor` setting is used to open the config file, and to open snippets for e
110
113
 
111
114
  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 (`>`).
112
115
 
113
- 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.
116
+ 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
117
 
115
118
  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.
116
119
 
@@ -118,11 +121,11 @@ The `name_only` key will permanently set Snibbets to only search for snippets by
118
121
 
119
122
  #### Syntax Highlighting
120
123
 
121
- The `highlight` key turns on syntax highlighting. This requires that either `pygmentize` or `skylighting` is available on your system (both available via package managers like Homebrew). This feature is still in development and results may be mixed. You can also set `highlighter` to `pygments` or `skylight` to force using one highlighter over the other.
124
+ The `highlight` key turns on syntax highlighting. This requires that either `pygmentize` or `skylighting` is available on your system (both available via package managers like Homebrew). This feature is still in development and results may be mixed. You can also set `highlighter` to `pygments` or `skylight` to force using one highlighter over the other.
122
125
 
123
- Highlighting using Skylighting requires that your snippets be named with extra extensions defining the lexer to use. The last extension before `.md` (or whatever your snippet extension is set to) should be the one that the highlighter will recognize as a valid lexer, e.g. `my code.jquery.js.md`.
126
+ Highlighting using Skylighting requires that your snippets be named with extra extensions defining the lexer to use. The last extension before `.md` (or whatever your snippet extension is set to) should be the one that the highlighter will recognize as a valid lexer, e.g. `my code.jquery.js.md`.
124
127
 
125
- You can also define languages in your fenced code blocks by putting the lexer name right after the opening fence. When defining multiple snippets in one file that are of different languages, this method will ensure that each one is properly highlighted.
128
+ You can also define languages in your fenced code blocks by putting the lexer name right after the opening fence. When defining multiple snippets in one file that are of different languages, this method will ensure that each one is properly highlighted.
126
129
 
127
130
  If you don't use either extensions or fenced code labels with Skylighting, code won't get highlighted.
128
131
 
@@ -157,13 +160,15 @@ Snibbet's implementation of Skylighting has limited but better-looking themes, a
157
160
  ### Usage
158
161
 
159
162
  ```
160
- Snibbets v2.0.37
163
+ Snibbets v2.0.38
161
164
 
162
165
  Usage: snibbets [options] query
163
166
  -a, --all If a file contains multiple snippets, output all of them (no menu)
164
167
  -c, --[no-]copy Copy the output to the clibpoard (also displays on STDOUT)
165
168
  -e, --edit Open the selected snippet in your configured editor
166
169
  -n, --[no-]name-only Only search file names, not content
170
+ --edit-new Create new snippet by opening editor. Title and language prompted.
171
+ --edit-new-titled TITLE Create new snippet by opening editor. Pass filename with language extension(s).
167
172
  --[no-]notes Display the full content of the snippet
168
173
  -o, --output FORMAT Output format (json|launchbar|*raw)
169
174
  -p, --paste, --new Interactively create a new snippet from clipboard contents (Mac only)
@@ -193,6 +198,8 @@ Use the `--edit` flag on any search to open the found snippet file in your edito
193
198
 
194
199
  #### Creating new snippets
195
200
 
201
+ ##### From clipboard
202
+
196
203
  I do most of my snippet editing in [nvUltra], but sometimes I have a function in my clipboard that just needs quick saving and there are so few moving parts to creating a snippet that it just feels like they could be automated/simplified. That's why I added the `--paste` flag. If you have a code snippet in your clipboard, you can just run `snibbets --paste` (or just `-p`) and you'll get a prompt asking you to describe the snippet (used for filename) and one asking what language(s) are represented.
197
204
 
198
205
  You can input the languages as names, e.g. `rust`, `typescript`, or `scala`, or you can just add file extensions that represent the language. If I say `ts` to that prompt, it will generate an extension of `.ts.md` and then add a metadata tag of `typescript` to the file. The code from the clipboard goes into a fenced code block in the document. You can always go add notes to it later, but it's a great way to save snippets as you come across them (or solutions you figure out after a week of banging your head).
@@ -201,6 +208,9 @@ This command requires that a clipboard utility be available. On macOS, you have
201
208
 
202
209
  [nvUltra]: https://nvultra.com "nvUltra for Mac"
203
210
 
211
+ ##### With editor
212
+
213
+ You can also create new snippets by opening a skeleton file in your editor with `--edit-new`. This will prompt for a title and languages, create the new file, and open it in your editor (or in nvUltra with the `--nvultra` flag). If you use `--edit-new-titled TITLE`, the new snippet will get a filename from `TITLE` and languages will be determined from any extension added to the title, or prompted for if none are found.
204
214
 
205
215
  #### Saving Settings When Running
206
216
 
@@ -212,7 +222,7 @@ _I'm currently reworking the LaunchBar action, and it doesn't function very well
212
222
 
213
223
  <!-- ### Installation
214
224
 
215
- The LaunchBar action can be installed simply by double clicking the `.lbaction` file in Finder. The CLI is not required for the LaunchBar action to function.
225
+ The LaunchBar action can be installed simply by double clicking the `.lbaction` file in Finder. The CLI is not required for the LaunchBar action to function.
216
226
 
217
227
  Once installed, run the action (type `snib` and hit return on the result) to select your Snippets folder.
218
228
 
data/bin/snibbets CHANGED
@@ -47,6 +47,18 @@ module Snibbets
47
47
  options[:name_only] = v
48
48
  end
49
49
 
50
+ opts.on('--edit-new', 'Create new snippet by opening editor. Title and language prompted.') do
51
+ arguments[:new] = true
52
+ arguments[:edit_snippet] = true
53
+ options[:filename] = nil
54
+ end
55
+
56
+ opts.on('--edit-new-titled TITLE', 'Create new snippet by opening editor. Pass filename with language extension(s).') do |v|
57
+ arguments[:new] = true
58
+ arguments[:edit_snippet] = true
59
+ options[:filename] = v
60
+ end
61
+
50
62
  opts.on('--[no-]notes', 'Display the full content of the snippet') do |v|
51
63
  options[:all_notes] = v
52
64
  end
@@ -94,19 +106,19 @@ module Snibbets
94
106
  arguments[:save_config] = true
95
107
  end
96
108
 
97
- opts.on('-h', '--help', 'Display this screen') do
109
+ opts.on_tail('-h', '--help', 'Display this screen') do
98
110
  puts "{by}Snibbets {w}v#{VERSION}".x
99
111
  puts
100
112
  puts optparse
101
113
  Process.exit 0
102
114
  end
103
115
 
104
- opts.on('-v', '--version', 'Display version information') do
116
+ opts.on_tail('-v', '--version', 'Display version information') do
105
117
  puts "{by}Snibbets {w}v#{VERSION}".x
106
118
  Process.exit 0
107
119
  end
108
120
 
109
- opts.on('--changes', 'Display the changelog (release notes)') do
121
+ opts.on_tail('--changes', 'Display the changelog (release notes)') do
110
122
  display_changelog
111
123
  Process.exit 0
112
124
  end
@@ -127,6 +139,11 @@ module Snibbets
127
139
  Process.exit 0
128
140
  end
129
141
 
142
+ if arguments[:new]
143
+ Snibbets.new_snippet_with_editor(options)
144
+ Process.exit 0
145
+ end
146
+
130
147
  unless File.directory?(options[:source])
131
148
  puts '{br}The Snippets folder doesn\'t exist, please configure it.'.x
132
149
  puts '{bg}Run `{bw}snibbets --configure{bg}` to open the config file for editing.'.x
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Snibbets
4
- VERSION = '2.0.37'
4
+ VERSION = '2.0.38'
5
5
  end
data/lib/snibbets.rb CHANGED
@@ -166,15 +166,17 @@ module Snibbets
166
166
  pb = OS.paste.outdent
167
167
  reader = TTY::Reader.new
168
168
 
169
- # printf 'What does this snippet do? '
170
- input = reader.read_line('{by}What does this snippet do{bw}? '.x).strip
171
- # input = $stdin.gets.chomp
172
- title = input unless input.empty?
173
-
174
- # printf 'What language(s) does it use (separate with spaces, full names or file extensions will work)? '
175
- input = reader.read_line('{by}What language(s) does it use ({xw}separate with spaces, full names or file extensions{by}){bw}? '.x).strip
176
- # input = $stdin.gets.chomp
177
- langs = input.split(/ +/).map(&:strip) unless input.empty?
169
+ begin
170
+ input = reader.read_line('{by}What does this snippet do{bw}? '.x).strip
171
+ title = input unless input.empty?
172
+
173
+ input = reader.read_line('{by}What language(s) does it use ({xw}separate with spaces, full names or file extensions{by}){bw}? '.x).strip
174
+ langs = input.split(/ +/).map(&:strip) unless input.empty?
175
+ rescue TTY::Reader::InputInterrupt
176
+ puts "\nCancelled"
177
+ Process.exit 1
178
+ end
179
+
178
180
  exts = langs.map { |lang| Lexers.lang_to_ext(lang) }.delete_if(&:nil?)
179
181
  tags = langs.map { |lang| Lexers.ext_to_lang(lang) }.concat(langs).delete_if(&:nil?).sort.uniq
180
182
 
@@ -196,6 +198,93 @@ module Snibbets
196
198
  open_snippet_in_nvultra(filepath) if Snibbets.arguments[:nvultra]
197
199
  end
198
200
 
201
+ def new_snippet_with_editor(options)
202
+ return false unless $stdout.isatty
203
+
204
+ trap('SIGINT') do
205
+ Howzit.console.info "\nCancelled"
206
+ exit!
207
+ end
208
+
209
+ reader = TTY::Reader.new
210
+ if options[:filename]
211
+ title = options[:filename].sub(/(\.#{Snibbets.options[:extension]})$/, '')
212
+ extensions = options[:filename].match(/(\.\w+)+$/)
213
+ langs = extensions ? extensions[0].split(/\./).delete_if(&:empty?) : []
214
+ title.sub!(/(\.\w+)+$/, '')
215
+ else
216
+ begin
217
+ input = reader.read_line('{by}What does this snippet do{bw}? '.x).strip
218
+ title = input unless input.empty?
219
+ rescue TTY::Reader::InputInterrupt
220
+ puts "\nCancelled"
221
+ Process.exit 1
222
+ end
223
+ end
224
+
225
+ if langs.nil? || langs.empty?
226
+ begin
227
+ # printf 'What language(s) does it use (separate with spaces, full names or file extensions will work)? '
228
+ input = reader.read_line('{by}What language(s) does it use ({xw}separate with spaces, full names or file extensions{by}){bw}? '.x).strip
229
+ # input = $stdin.gets.chomp
230
+ langs = input.split(/ +/).map(&:strip) unless input.empty?
231
+ rescue TTY::Reader::InputInterrupt
232
+ puts "\nCancelled"
233
+ Process.exit 1
234
+ end
235
+ end
236
+
237
+ exts = langs.map { |lang| Lexers.lang_to_ext(lang) }.delete_if(&:nil?)
238
+ tags = langs.map { |lang| Lexers.ext_to_lang(lang) }.concat(langs).delete_if(&:nil?).sort.uniq
239
+
240
+ exts = langs if exts.empty?
241
+
242
+ filename = "#{title}#{exts.map { |x| ".#{x}" }.join('')}.#{Snibbets.options[:extension]}"
243
+ filepath = File.join(File.expand_path(Snibbets.options[:source]), filename)
244
+
245
+ output =<<~EOOUTPUT
246
+ tags: #{tags.join(', ')}
247
+
248
+ > #{title}
249
+ EOOUTPUT
250
+
251
+ if langs.count.positive?
252
+ tags.each do |lang|
253
+ comment = case lang
254
+ when /(c|cpp|objectivec|java|javascript|dart|php|golang|typescript|kotlin)/
255
+ '// Code'
256
+ else
257
+ '# Code'
258
+ end
259
+
260
+ output << <<~EOLANGS
261
+
262
+ ```#{lang}
263
+ #{comment}
264
+ ```
265
+ EOLANGS
266
+ end
267
+ else
268
+ output << <<~EOCODE
269
+ ```LANG
270
+ ```
271
+ EOCODE
272
+ end
273
+
274
+ File.open(filepath, 'w') do |f|
275
+ f.puts output
276
+ end
277
+
278
+ puts "{bg}New snippet written to {bw}#{filename}.".x
279
+
280
+ if Snibbets.arguments[:nvultra]
281
+ sleep 2
282
+ open_snippet_in_nvultra(filepath)
283
+ else
284
+ open_snippet_in_editor(filepath)
285
+ end
286
+ end
287
+
199
288
  def handle_launchbar(results)
200
289
  output = []
201
290
 
data/src/_README.md CHANGED
@@ -1,16 +1,19 @@
1
1
  # Snibbets
2
2
 
3
3
  <!--README-->
4
+
4
5
  [![RubyGems.org](https://img.shields.io/gem/v/snibbets)](https://rubygems.org/gems/snibbets)
5
6
 
6
7
  A tool for accessing code snippets contained in a folder of plain text Markdown files.
7
8
 
8
- 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.
9
+ 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.
9
10
 
10
11
  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.
11
12
 
12
13
  <!--GITHUB-->
14
+
13
15
  ![Snibbets in action](https://cdn3.brettterpstra.com/uploads/2023/04/snibbets2.gif)
16
+
14
17
  <!--END GITHUB-->
15
18
  <!--JEKYLL{% gif /uploads/2023/04/snibbets2.gif %}-->
16
19
 
@@ -24,7 +27,7 @@ The name of the file should be the description of the snippet, at least in the c
24
27
 
25
28
  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
29
 
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 `>`.
30
+ 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
31
 
29
32
  A file titled `unix find.bash.md`:
30
33
 
@@ -82,13 +85,13 @@ Default config:
82
85
  ---
83
86
  all: false
84
87
  copy: false
85
- editor:
88
+ editor:
86
89
  extension: md
87
90
  highlight: false
88
91
  include_blockquotes: false
89
92
  interactive: true
90
93
  launchbar: false
91
- menus:
94
+ menus:
92
95
  name_only: false
93
96
  output: raw
94
97
  source: "~/Dropbox/Snippets"
@@ -112,7 +115,7 @@ The `editor` setting is used to open the config file, and to open snippets for e
112
115
 
113
116
  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 (`>`).
114
117
 
115
- 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.
118
+ 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.
116
119
 
117
120
  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
121
 
@@ -120,11 +123,11 @@ The `name_only` key will permanently set Snibbets to only search for snippets by
120
123
 
121
124
  #### Syntax Highlighting
122
125
 
123
- The `highlight` key turns on syntax highlighting. This requires that either `pygmentize` or `skylighting` is available on your system (both available via package managers like Homebrew). This feature is still in development and results may be mixed. You can also set `highlighter` to `pygments` or `skylight` to force using one highlighter over the other.
126
+ The `highlight` key turns on syntax highlighting. This requires that either `pygmentize` or `skylighting` is available on your system (both available via package managers like Homebrew). This feature is still in development and results may be mixed. You can also set `highlighter` to `pygments` or `skylight` to force using one highlighter over the other.
124
127
 
125
- Highlighting using Skylighting requires that your snippets be named with extra extensions defining the lexer to use. The last extension before `.md` (or whatever your snippet extension is set to) should be the one that the highlighter will recognize as a valid lexer, e.g. `my code.jquery.js.md`.
128
+ Highlighting using Skylighting requires that your snippets be named with extra extensions defining the lexer to use. The last extension before `.md` (or whatever your snippet extension is set to) should be the one that the highlighter will recognize as a valid lexer, e.g. `my code.jquery.js.md`.
126
129
 
127
- You can also define languages in your fenced code blocks by putting the lexer name right after the opening fence. When defining multiple snippets in one file that are of different languages, this method will ensure that each one is properly highlighted.
130
+ You can also define languages in your fenced code blocks by putting the lexer name right after the opening fence. When defining multiple snippets in one file that are of different languages, this method will ensure that each one is properly highlighted.
128
131
 
129
132
  If you don't use either extensions or fenced code labels with Skylighting, code won't get highlighted.
130
133
 
@@ -176,6 +179,8 @@ Use the `--edit` flag on any search to open the found snippet file in your edito
176
179
 
177
180
  #### Creating new snippets
178
181
 
182
+ ##### From clipboard
183
+
179
184
  I do most of my snippet editing in [nvUltra], but sometimes I have a function in my clipboard that just needs quick saving and there are so few moving parts to creating a snippet that it just feels like they could be automated/simplified. That's why I added the `--paste` flag. If you have a code snippet in your clipboard, you can just run `snibbets --paste` (or just `-p`) and you'll get a prompt asking you to describe the snippet (used for filename) and one asking what language(s) are represented.
180
185
 
181
186
  You can input the languages as names, e.g. `rust`, `typescript`, or `scala`, or you can just add file extensions that represent the language. If I say `ts` to that prompt, it will generate an extension of `.ts.md` and then add a metadata tag of `typescript` to the file. The code from the clipboard goes into a fenced code block in the document. You can always go add notes to it later, but it's a great way to save snippets as you come across them (or solutions you figure out after a week of banging your head).
@@ -184,6 +189,9 @@ This command requires that a clipboard utility be available. On macOS, you have
184
189
 
185
190
  [nvUltra]: https://nvultra.com "nvUltra for Mac"
186
191
 
192
+ ##### With editor
193
+
194
+ You can also create new snippets by opening a skeleton file in your editor with `--edit-new`. This will prompt for a title and languages, create the new file, and open it in your editor (or in nvUltra with the `--nvultra` flag). If you use `--edit-new-titled TITLE`, the new snippet will get a filename from `TITLE` and languages will be determined from any extension added to the title, or prompted for if none are found.
187
195
 
188
196
  #### Saving Settings When Running
189
197
 
@@ -195,7 +203,7 @@ _I'm currently reworking the LaunchBar action, and it doesn't function very well
195
203
 
196
204
  <!-- ### Installation
197
205
 
198
- The LaunchBar action can be installed simply by double clicking the `.lbaction` file in Finder. The CLI is not required for the LaunchBar action to function.
206
+ The LaunchBar action can be installed simply by double clicking the `.lbaction` file in Finder. The CLI is not required for the LaunchBar action to function.
199
207
 
200
208
  Once installed, run the action (type `snib` and hit return on the result) to select your Snippets folder.
201
209
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snibbets
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.37
4
+ version: 2.0.38
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Terpstra
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-12 00:00:00.000000000 Z
11
+ date: 2024-08-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -330,7 +330,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
330
330
  - !ruby/object:Gem::Version
331
331
  version: '0'
332
332
  requirements: []
333
- rubygems_version: 3.2.16
333
+ rubygems_version: 3.2.15
334
334
  signing_key:
335
335
  specification_version: 4
336
336
  summary: Snibbets