commit - e6924fe055d8c4646b5acf2f7eaab77808d5cc27
commit + 76ebdf31b4f697c5f276b1e8d23c153f21de0a1b
blob - ae284dfd353c14f6b2259cce4de3298ef58bdfcf
blob + 2fb827c32a8f8352dc71ebb24a5761047f91dc84
--- README.md
+++ README.md
# Fuzzy pick from any piped list
git ls-files | ./zig-out/bin/magdalena select
+
+# Embed the picker in an editor: write the pick to a file, do not open
+./zig-out/bin/magdalena --choose-file /tmp/pick look-file
```
+
+With `--choose-file`, any picker command writes the selection to the given
+file and exits instead of opening an editor. File pickers write the path and
+grep writes `file:line`. History logging is skipped because the embedding
+editor owns the open event.
blob - 01ca487d12d989efbfa1dc77f50065c18f0d9e8f
blob + 1cbf6afd6fe5f49b7d14aaa9c4665e8e72eccc7b
--- src/navigate.zig
+++ src/navigate.zig
}
}
const file = target orelse return error.UserAbort;
- try std.Io.Dir.accessAbsolute(input_output.runtime(), file, .{
+ std.Io.Dir.cwd().access(input_output.runtime(), file, .{
.follow_symlinks = true,
.read = false,
.write = false,
.execute = false,
- });
+ }) catch |err| {
+ input_output.warn("Selected file no longer exists or is inaccessible:" ++
+ " {s} ({})\n", .{ file, err });
+ return error.UserAbort;
+ };
try gotoFile(history, file, null, app_config, choose_file);
}
blob - 2bab06cf37cf060ccb8e1889d7f36c7720b56be6
blob + 62b925916033a27e96e57a2e281b10469721fdf7
--- src/picker.zig
+++ src/picker.zig
"--smart-case",
"--ignore-binary",
"--color=never",
+ "-Z1",
});
for (ignored_patterns) |pattern| {
assert(pattern.len > 0);
try argv.append(allocator, "--");
try argv.append(allocator, query);
}
- assert(argv.items.len >= 9);
+ assert(argv.items.len >= 10);
return argv;
}
"--smart-case",
"--ignore-binary",
"--color=never",
+ "-Z1",
"--exclude-dir",
"node_modules",
"--exclude",