elio 1.4.0

Snappy, batteries-included terminal file manager with rich previews, inline images, bulk actions, and trash support.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
use super::*;

#[test]
fn markdown_preview_formats_headings_and_lists() {
    let root = temp_path("markdown");
    fs::create_dir_all(&root).expect("failed to create temp root");
    let path = root.join("README.md");
    fs::write(&path, "# Heading\n- item\n`inline`\n").expect("failed to write markdown");

    let preview = build_preview(&file_entry(path.clone()));

    assert_eq!(preview.kind, PreviewKind::Markdown);
    assert_eq!(preview.lines[0].spans[0].content, "Heading");
    assert!(
        preview
            .lines
            .iter()
            .any(|line| line.spans.iter().any(|span| span.content == "inline"))
    );

    fs::remove_dir_all(root).expect("failed to remove temp root");
}

#[test]
fn markdown_preview_formats_inline_emphasis_mid_line() {
    let root = temp_path("markdown-inline");
    fs::create_dir_all(&root).expect("failed to create temp root");
    let path = root.join("README.md");
    fs::write(&path, "hello **bold** world\n").expect("failed to write markdown");

    let preview = build_preview(&file_entry(path.clone()));
    let line = &preview.lines[0];

    assert_eq!(preview.kind, PreviewKind::Markdown);
    assert!(line.spans.iter().any(|span| span.content == "hello "));
    assert!(line.spans.iter().any(|span| span.content == "bold"));
    assert!(line.spans.iter().any(|span| span.content == " world"));

    fs::remove_dir_all(root).expect("failed to remove temp root");
}

#[test]
fn markdown_preview_renders_fenced_code_blocks() {
    let root = temp_path("markdown-fence");
    fs::create_dir_all(&root).expect("failed to create temp root");
    let path = root.join("README.md");
    fs::write(&path, "```rust\nfn main() {}\n```\n").expect("failed to write markdown");

    let preview = build_preview(&file_entry(path.clone()));

    assert_eq!(preview.kind, PreviewKind::Markdown);
    assert_eq!(preview.lines[0].spans[1].content, "rust");
    assert!(
        preview
            .lines
            .iter()
            .any(|line| line_text(line).contains("fn main() {}"))
    );

    fs::remove_dir_all(root).expect("failed to remove temp root");
}

#[test]
fn markdown_preview_routes_fence_aliases_through_registry() {
    let root = temp_path("markdown-fence-aliases");
    fs::create_dir_all(&root).expect("failed to create temp root");
    let path = root.join("README.md");
    fs::write(
        &path,
        "```js\nconst value = 1;\n```\n\n```csharp\npublic class Greeter {}\n```\n\n```exs\ndefmodule Greeter do\nend\n```\n\n```clj\n(defn greet [name] (str \"hi \" name))\n```\n\n```pwsh\nfunction Invoke-Greeting { Write-Host \"hello\" }\n```\n\n```kitty\nfont_size 11.5\n```\n",
    )
    .expect("failed to write markdown");

    let preview = build_preview(&file_entry(path.clone()));
    let code_palette = theme::code_preview_palette();

    assert_eq!(preview.kind, PreviewKind::Markdown);
    assert!(
        preview
            .lines
            .iter()
            .any(|line| line.spans.iter().any(|span| span.content == "js"))
    );
    assert!(
        preview
            .lines
            .iter()
            .any(|line| line.spans.iter().any(|span| span.content == "kitty"))
    );

    let js_line = preview
        .lines
        .iter()
        .find(|line| line_text(line).contains("const value = 1;"))
        .expect("expected highlighted js line");
    assert_ne!(span_color(js_line, "const"), Some(code_palette.fg));

    let kitty_line = preview
        .lines
        .iter()
        .find(|line| line_text(line).contains("font_size 11.5"))
        .expect("expected highlighted kitty line");
    assert_eq!(
        span_color(kitty_line, "font_size"),
        Some(code_palette.function)
    );

    let csharp_line = preview
        .lines
        .iter()
        .find(|line| line_text(line).contains("public class Greeter {}"))
        .expect("expected highlighted csharp line");
    assert_ne!(span_color(csharp_line, "public"), Some(code_palette.fg));

    let elixir_line = preview
        .lines
        .iter()
        .find(|line| line_text(line).contains("defmodule Greeter do"))
        .expect("expected highlighted elixir line");
    assert_ne!(span_color(elixir_line, "defmodule"), Some(code_palette.fg));

    let powershell_line = preview
        .lines
        .iter()
        .find(|line| line_text(line).contains("function Invoke-Greeting"))
        .expect("expected highlighted powershell line");
    assert_ne!(
        span_color(powershell_line, "function"),
        Some(code_palette.fg)
    );

    let clojure_line = preview
        .lines
        .iter()
        .find(|line| line_text(line).contains("(defn greet [name]"))
        .expect("expected highlighted clojure line");
    assert_ne!(span_color(clojure_line, "defn"), Some(code_palette.fg));

    fs::remove_dir_all(root).expect("failed to remove temp root");
}

#[test]
fn markdown_preview_renders_links() {
    let root = temp_path("markdown-links");
    fs::create_dir_all(&root).expect("failed to create temp root");
    let path = root.join("README.md");
    fs::write(&path, "open [elio](https://example.com)\n").expect("failed to write markdown");

    let preview = build_preview(&file_entry(path));
    let line = &preview.lines[0];

    assert_eq!(preview.kind, PreviewKind::Markdown);
    let link_span = line
        .spans
        .iter()
        .find(|span| span.content == "elio")
        .expect("link label should be rendered");
    assert!(link_span.style.add_modifier.contains(Modifier::UNDERLINED));
    assert!(line_text(line).contains("(https://example.com)"));

    fs::remove_dir_all(root).expect("failed to remove temp root");
}

#[test]
fn markdown_preview_renders_images_with_icon_and_alt_text() {
    let root = temp_path("markdown-images");
    fs::create_dir_all(&root).expect("failed to create temp root");
    let path = root.join("README.md");
    fs::write(
        &path,
        "![Catppuccin Mocha](examples/themes/catppuccin-mocha/screenshot.png)\n",
    )
    .expect("failed to write markdown");

    let preview = build_preview(&file_entry(path.clone()));

    assert_eq!(preview.kind, PreviewKind::Markdown);
    let texts: Vec<String> = preview.lines.iter().map(line_text).collect();
    assert!(texts.iter().any(|t| t.contains("󰋩 Catppuccin Mocha")));
    // Alt text shown
    assert!(texts.iter().any(|t| t.contains("Catppuccin Mocha")));
    // Path not shown
    assert!(!texts.iter().any(|t| t.contains("screenshot.png")));

    fs::remove_dir_all(root).expect("failed to remove temp root");
}

#[test]
fn markdown_preview_adds_spacing_between_blocks() {
    let root = temp_path("markdown-spacing");
    fs::create_dir_all(&root).expect("failed to create temp root");
    let path = root.join("README.md");
    fs::write(
        &path,
        "# Heading\nParagraph text\n\n```rust\nlet x = 1;\n```\n",
    )
    .expect("failed to write markdown");

    let preview = build_preview(&file_entry(path));

    assert_eq!(preview.kind, PreviewKind::Markdown);
    assert!(preview.lines.iter().any(|line| line.spans.is_empty()));

    fs::remove_dir_all(root).expect("failed to remove temp root");
}

#[test]
fn markdown_preview_renders_nested_emphasis() {
    let root = temp_path("markdown-nested");
    fs::create_dir_all(&root).expect("failed to create temp root");
    let path = root.join("README.md");
    fs::write(&path, "**bold and *italic***\n").expect("failed to write markdown");

    let preview = build_preview(&file_entry(path));
    let line = &preview.lines[0];

    assert_eq!(preview.kind, PreviewKind::Markdown);
    let italic_span = line
        .spans
        .iter()
        .find(|span| span.content == "italic")
        .expect("nested italic content should be rendered");
    assert!(italic_span.style.add_modifier.contains(Modifier::BOLD));
    assert!(italic_span.style.add_modifier.contains(Modifier::ITALIC));

    fs::remove_dir_all(root).expect("failed to remove temp root");
}

#[test]
fn markdown_preview_renders_mixed_lists() {
    let root = temp_path("markdown-mixed-lists");
    fs::create_dir_all(&root).expect("failed to create temp root");
    let path = root.join("README.md");
    fs::write(&path, "1. first\n   - nested\n2. second\n").expect("failed to write markdown");

    let preview = build_preview(&file_entry(path));

    assert_eq!(preview.kind, PreviewKind::Markdown);
    assert!(
        preview
            .lines
            .iter()
            .any(|line| line.spans.iter().any(|span| span.content == "1. "))
    );
    assert!(
        preview
            .lines
            .iter()
            .any(|line| line.spans.iter().any(|span| span.content.contains("")))
    );
    assert!(
        preview
            .lines
            .iter()
            .any(|line| line.spans.iter().any(|span| span.content == "2. "))
    );

    fs::remove_dir_all(root).expect("failed to remove temp root");
}

#[test]
fn markdown_preview_renders_table_with_header_separator() {
    let root = temp_path("markdown-table");
    fs::create_dir_all(&root).expect("failed to create temp root");
    let path = root.join("README.md");
    fs::write(
        &path,
        "| Key | Description |\n|---|---|\n| Enter | Open |\n| Backspace | Go up |\n",
    )
    .expect("failed to write markdown");

    let preview = build_preview(&file_entry(path.clone()));

    assert_eq!(preview.kind, PreviewKind::Markdown);
    let texts: Vec<String> = preview.lines.iter().map(line_text).collect();
    // Box borders are present
    assert!(
        texts.iter().any(|t| t.contains('')),
        "expected top-left corner"
    );
    assert!(
        texts.iter().any(|t| t.contains('')),
        "expected header separator"
    );
    assert!(
        texts.iter().any(|t| t.contains('')),
        "expected bottom-left corner"
    );
    assert!(
        texts.iter().any(|t| t.contains('')),
        "expected vertical border"
    );
    // Header row content visible
    assert!(
        texts
            .iter()
            .any(|t| t.contains("Key") && t.contains("Description"))
    );
    // Data rows visible
    assert!(
        texts
            .iter()
            .any(|t| t.contains("Enter") && t.contains("Open"))
    );
    assert!(
        texts
            .iter()
            .any(|t| t.contains("Backspace") && t.contains("Go up"))
    );
    // Header cells are bold
    let header_line = preview
        .lines
        .iter()
        .find(|line| line_text(line).contains("Key") && line_text(line).contains("Description"))
        .expect("expected header line");
    let key_span = header_line
        .spans
        .iter()
        .find(|span| span.content.contains("Key"))
        .expect("expected Key span");
    assert!(
        key_span
            .style
            .add_modifier
            .contains(ratatui::style::Modifier::BOLD)
    );

    fs::remove_dir_all(root).expect("failed to remove temp root");
}

#[test]
fn markdown_preview_wraps_long_table_cells_without_ellipsis() {
    let root = temp_path("markdown-table-wrapping");
    fs::create_dir_all(&root).expect("failed to create temp root");
    let path = root.join("README.md");
    fs::write(
        &path,
        "| Key | Description |\n|---|---|\n| Enter | This description is deliberately longer than the markdown table preview column width so we can verify clipping behavior |\n",
    )
    .expect("failed to write markdown");

    let preview = build_preview(&file_entry(path.clone()));

    assert_eq!(preview.kind, PreviewKind::Markdown);
    let texts: Vec<String> = preview.lines.iter().map(line_text).collect();
    assert!(
        texts.iter().any(|t| t.contains("This description")),
        "expected wrapped table cell content to keep the leading text"
    );
    assert!(
        texts.iter().any(|t| t.contains("behavior")),
        "expected wrapped table cell content to keep the trailing text"
    );
    assert!(
        !texts.iter().any(|t| t.contains('')),
        "wrapped table cells should not render an ellipsis"
    );
    assert!(
        texts.iter().filter(|t| t.contains('')).count() > 2,
        "expected the long table row to wrap across multiple table lines"
    );
    let top_border = preview
        .lines
        .iter()
        .find(|line| line_text(line).contains(''))
        .expect("expected table top border");
    assert_eq!(
        top_border.width(),
        MARKDOWN_CONTENT_WIDTH,
        "wide markdown tables should use the same width budget as markdown prose"
    );

    fs::remove_dir_all(root).expect("failed to remove temp root");
}

#[test]
fn markdown_preview_renders_details_summary() {
    let root = temp_path("markdown-details");
    fs::create_dir_all(&root).expect("failed to create temp root");
    let path = root.join("README.md");
    fs::write(
        &path,
        "<details>\n<summary><strong>Controls and Navigation</strong></summary>\n\nSome content here.\n\n</details>\n",
    )
    .expect("failed to write markdown");

    let preview = build_preview(&file_entry(path.clone()));

    assert_eq!(preview.kind, PreviewKind::Markdown);
    let texts: Vec<String> = preview.lines.iter().map(line_text).collect();
    // Summary text is shown (tags stripped)
    assert!(texts.iter().any(|t| t.contains("Controls and Navigation")));
    // Bare <details> tags are not shown as raw HTML
    assert!(!texts.iter().any(|t| t.trim() == "<details>"));
    assert!(!texts.iter().any(|t| t.trim() == "</details>"));
    // The disclosure indicator is present
    assert!(texts.iter().any(|t| t.contains('')));
    // Body content is shown with gutter prefix
    let content_line = preview
        .lines
        .iter()
        .find(|line| line_text(line).contains("Some content here."))
        .expect("expected content line");
    assert!(
        content_line
            .spans
            .iter()
            .any(|span| span.content.contains('')),
        "content inside details should have gutter"
    );

    fs::remove_dir_all(root).expect("failed to remove temp root");
}

#[test]
fn markdown_license_preview_keeps_detected_detail() {
    let root = temp_path("markdown-license");
    fs::create_dir_all(&root).expect("failed to create temp root");
    let path = root.join("LICENSE.md");
    fs::write(
        &path,
        "# SPDX-License-Identifier: Apache-2.0\n\nFixture license notes.\n",
    )
    .expect("failed to write markdown license");

    let preview = build_preview(&file_entry(path));

    assert_eq!(preview.kind, PreviewKind::Markdown);
    assert_eq!(preview.detail.as_deref(), Some("Apache License 2.0"));

    fs::remove_dir_all(root).expect("failed to remove temp root");
}