From 9d937fe376570ab9ce66c10c1ebec008252861b8 Mon Sep 17 00:00:00 2001 From: sxyazi Date: Sat, 12 Aug 2023 19:57:48 +0800 Subject: [PATCH] feat: add `inode/x-empty` and `application/json` as text --- config/preset/yazi.toml | 26 ++++++++++++++------------ config/src/open/opener.rs | 2 +- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/config/preset/yazi.toml b/config/preset/yazi.toml index e1e55f84..4d91f538 100644 --- a/config/preset/yazi.toml +++ b/config/preset/yazi.toml @@ -10,30 +10,30 @@ max_height = 900 [opener] folder = [ - { exec = "open -R $*", display_name = "Reveal in Finder" }, - { exec = "vim $*" }, + { exec = 'open -R "$@"', display_name = "Reveal in Finder" }, + { exec = 'vim "$@"' }, ] archive = [ - { exec = "unar $1", display_name = "Extract here" }, + { exec = 'unar "$1"', display_name = "Extract here" }, ] text = [ - { exec = "vim $*", block = true }, + { exec = 'vim "$@"', block = true }, ] image = [ - { exec = "open $*", display_name = "Open" }, - { exec = "exiftool $1; echo '\n\nPress enter to exit'; read", block = true, display_name = "Show EXIF" }, + { exec = 'open "$@"', display_name = "Open" }, + { exec = '''exiftool "$1"; echo "Press enter to exit"; read''', block = true, display_name = "Show EXIF" }, ] video = [ - { exec = "mpv $*" }, - { exec = "mediainfo $1; echo '\n\nPress enter to exit'; read", block = true, display_name = "Show media info" }, + { exec = 'mpv "$@"' }, + { exec = '''mediainfo "$1"; echo "Press enter to exit"; read''', block = true, display_name = "Show media info" }, ] audio = [ - { exec = "mpv $*" }, - { exec = "mediainfo $1; echo '\n\nPress enter to exit'; read", block = true, display_name = "Show media info" }, + { exec = 'mpv "$@"' }, + { exec = '''mediainfo "$1"; echo "Press enter to exit"; read''', block = true, display_name = "Show media info" }, ] fallback = [ - { exec = "open $*", display_name = "Open" }, - { exec = "open -R $*", display_name = "Reveal in Finder" }, + { exec = 'open "$@"', display_name = "Open" }, + { exec = 'open -R "$@"', display_name = "Reveal in Finder" }, ] [open] @@ -45,6 +45,8 @@ rules = [ { mime = "image/*", use = "image" }, { mime = "video/*", use = "video" }, { mime = "audio/*", use = "audio" }, + { mime = "inode/x-empty", use = "text" }, + { mime = "application/json", use = "text" }, { mime = "application/x-bzip", use = "archive" }, { mime = "application/x-bzip2", use = "archive" }, diff --git a/config/src/open/opener.rs b/config/src/open/opener.rs index 29c19236..fbc4eb5a 100644 --- a/config/src/open/opener.rs +++ b/config/src/open/opener.rs @@ -38,7 +38,7 @@ impl<'de> Deserialize<'de> for Opener { } println!( - "WARNING: `cmd` and `args` are deprecated in favor of `exec` in Yazi v0.1.5, see https://github.com/sxyazi/yazi/pull/45" + "WARNING: `cmd` and `args` will be deprecated in favor of `exec` in Yazi v0.1.5, see https://github.com/sxyazi/yazi/pull/45" ); // Replace the $0 to $1, $1 to $2, and so on