Skip to content

Commit 173cc48

Browse files
committed
fix: allow previewing dirs other than cwd
1 parent a8ad8d0 commit 173cc48

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

bin/main.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ let handle_filetype ~filename ~width ~height = function
44
(* empty files *)
55
| "inode/x-empty" -> print_endline "Empty file"
66
(* directories *)
7-
| "inode/directory" -> Directory.directory ()
7+
| "inode/directory" -> Directory.directory filename
88
(* archives *)
99
| "application/x-tar" | "application/zip" | "application/x-zip-compressed"
1010
| "application/x-bzip" | "application/x-bzip2" | "application/gzip"
@@ -22,14 +22,14 @@ let handle_filetype ~filename ~width ~height = function
2222
Image.image filename ~width ~height
2323
(* videos *)
2424
| str when String.starts_with ~prefix:"video" str ->
25-
FFmpeg.thumbnail filename ~width ~height
25+
Ffmpeg.thumbnail filename ~width ~height
2626
(* everything else, print mime to find new possible filetypes to handle *)
2727
| mime ->
2828
print_endline mime;
2929
Text.text filename
3030

3131
let mlpreview ~width ~height ~horizontal ~vertical = function
32-
| None -> `Ok (Directory.directory ())
32+
| None -> `Ok (Directory.directory ".")
3333
| Some filename ->
3434
ignore horizontal;
3535
ignore vertical;

lib/directory.ml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
let directory () =
1+
let directory file_name =
22
let stream =
33
Unix.open_process_in
4-
@@ "eza -a1F --color=always --group-directories-first --icons=always --git"
4+
@@ Printf.sprintf
5+
"eza -a1F --color=always --group-directories-first --icons=always \
6+
--git \"%s\""
7+
file_name
58
in
69
print_endline @@ In_channel.input_all stream;
710
In_channel.close stream

lib/directory.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
val directory : unit -> unit
1+
val directory : string -> unit
22
(** Render directory using eza *)

0 commit comments

Comments
 (0)