mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-21 23:01:05 +00:00
feat: add display_name to opener (#31)
This commit is contained in:
parent
ab5ff057c4
commit
2ac51faa93
4 changed files with 24 additions and 19 deletions
|
|
@ -10,30 +10,30 @@ max_height = 900
|
|||
|
||||
[opener]
|
||||
folder = [
|
||||
{ cmd = "open", args = [ "-R", "$*" ] },
|
||||
{ cmd = "open", args = [ "-R", "$*" ], display_name = "Reveal in Finder" },
|
||||
{ cmd = "vim", args = [ "$*" ] },
|
||||
]
|
||||
archive = [
|
||||
{ cmd = "unar", args = [ "$0" ] },
|
||||
{ cmd = "unar", args = [ "$0" ], display_name = "Extract here" },
|
||||
]
|
||||
text = [
|
||||
{ cmd = "vim", args = [ "$*" ], block = true },
|
||||
]
|
||||
image = [
|
||||
{ cmd = "open", args = [ "$*" ] },
|
||||
{ cmd = "exiftool", args = [ "$0" ], block = true },
|
||||
{ cmd = "open", args = [ "$*" ], display_name = "Open" },
|
||||
{ cmd = "exiftool", args = [ "$0" ], block = true, display_name = "Show EXIF" },
|
||||
]
|
||||
video = [
|
||||
{ cmd = "mpv", args = [ "$*" ] },
|
||||
{ cmd = "mediainfo", args = [ "$0" ], block = true },
|
||||
{ cmd = "mediainfo", args = [ "$0" ], block = true, display_name = "Show media info" },
|
||||
]
|
||||
audio = [
|
||||
{ cmd = "mpv", args = [ "$*" ] },
|
||||
{ cmd = "mediainfo", args = [ "$0" ], block = true },
|
||||
{ cmd = "mediainfo", args = [ "$0" ], block = true, display_name = "Show media info" },
|
||||
]
|
||||
fallback = [
|
||||
{ cmd = "open", args = [ "$*" ] },
|
||||
{ cmd = "open", args = [ "-R", "$*" ] },
|
||||
{ cmd = "open", args = [ "$*" ], display_name = "Open" },
|
||||
{ cmd = "open", args = [ "-R", "$*" ], display_name = "Reveal in Finder" },
|
||||
]
|
||||
|
||||
[open]
|
||||
|
|
|
|||
|
|
@ -2,10 +2,11 @@ use serde::{Deserialize, Deserializer};
|
|||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
pub struct Opener {
|
||||
pub cmd: String,
|
||||
pub args: Vec<String>,
|
||||
pub block: bool,
|
||||
pub spread: bool,
|
||||
pub cmd: String,
|
||||
pub args: Vec<String>,
|
||||
pub block: bool,
|
||||
pub display_name: String,
|
||||
pub spread: bool,
|
||||
}
|
||||
|
||||
impl<'de> Deserialize<'de> for Opener {
|
||||
|
|
@ -15,17 +16,20 @@ impl<'de> Deserialize<'de> for Opener {
|
|||
{
|
||||
#[derive(Deserialize)]
|
||||
pub struct Shadow {
|
||||
pub cmd: String,
|
||||
pub args: Vec<String>,
|
||||
pub cmd: String,
|
||||
pub args: Vec<String>,
|
||||
#[serde(default)]
|
||||
pub block: bool,
|
||||
pub block: bool,
|
||||
pub display_name: Option<String>,
|
||||
#[serde(skip)]
|
||||
pub spread: bool,
|
||||
pub spread: bool,
|
||||
}
|
||||
|
||||
let shadow = Shadow::deserialize(deserializer)?;
|
||||
|
||||
let display_name = if let Some(s) = shadow.display_name { s } else { shadow.cmd.clone() };
|
||||
let spread = shadow.args.contains(&"$*".to_string());
|
||||
Ok(Self { cmd: shadow.cmd, args: shadow.args, block: shadow.block, spread })
|
||||
|
||||
Ok(Self { cmd: shadow.cmd, args: shadow.args, block: shadow.block, display_name, spread })
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ impl Manager {
|
|||
|
||||
let result = emit!(Select(SelectOpt {
|
||||
title: "Open with:".to_string(),
|
||||
items: openers.iter().map(|o| o.cmd.clone()).collect(),
|
||||
items: openers.iter().map(|o| o.display_name.clone()).collect(),
|
||||
position: Position::Hovered,
|
||||
}));
|
||||
if let Ok(choice) = result.await {
|
||||
|
|
@ -236,6 +236,7 @@ impl Manager {
|
|||
cmd: "sh".to_string(),
|
||||
args: vec!["-c".to_string(), "$0".to_string()],
|
||||
block,
|
||||
display_name: Default::default(),
|
||||
spread: false,
|
||||
})
|
||||
));
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
{"language":"en","flagWords":[],"words":["Punct","KEYMAP","splitn","crossterm","YAZI","unar","peekable","ratatui","syntect","pbpaste","pbcopy","ffmpegthumbnailer","oneshot","Posix","Lsar","XADDOS","zoxide","cands","Deque","precache","imageops","IFBLK","IFCHR","IFDIR","IFIFO","IFLNK","IFMT","IFSOCK","IRGRP","IROTH","IRUSR","ISGID","ISUID","ISVTX","IWGRP","IWOTH","IWUSR","IXGRP","IXOTH","IXUSR","libc","winsize","TIOCGWINSZ","xpixel","ypixel","ioerr","appender","Catppuccin","macchiato","gitmodules","Dotfiles","bashprofile","vimrc","flac","webp","exiftool","mediainfo","ripgrep","nvim","indexmap","indexmap","unwatch","canonicalize","serde","fsevent","Ueberzug","iterm","wezterm","sixel","chafa","ueberzugpp","️ Überzug","️ Überzug","Konsole","Alacritty","Überzug","pkgs","paru","unarchiver","pdftoppm","poppler","prebuild","singlefile","jpegopt"],"version":"0.2"}
|
||||
{"version":"0.2","flagWords":[],"language":"en","words":["Punct","KEYMAP","splitn","crossterm","YAZI","unar","peekable","ratatui","syntect","pbpaste","pbcopy","ffmpegthumbnailer","oneshot","Posix","Lsar","XADDOS","zoxide","cands","Deque","precache","imageops","IFBLK","IFCHR","IFDIR","IFIFO","IFLNK","IFMT","IFSOCK","IRGRP","IROTH","IRUSR","ISGID","ISUID","ISVTX","IWGRP","IWOTH","IWUSR","IXGRP","IXOTH","IXUSR","libc","winsize","TIOCGWINSZ","xpixel","ypixel","ioerr","appender","Catppuccin","macchiato","gitmodules","Dotfiles","bashprofile","vimrc","flac","webp","exiftool","mediainfo","ripgrep","nvim","indexmap","indexmap","unwatch","canonicalize","serde","fsevent","Ueberzug","iterm","wezterm","sixel","chafa","ueberzugpp","️ Überzug","️ Überzug","Konsole","Alacritty","Überzug","pkgs","paru","unarchiver","pdftoppm","poppler","prebuild","singlefile","jpegopt","EXIF"]}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue