mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
..
This commit is contained in:
parent
96a894f67d
commit
e2013db97e
6 changed files with 52 additions and 145 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -2719,6 +2719,7 @@ dependencies = [
|
||||||
"clap_complete",
|
"clap_complete",
|
||||||
"clap_complete_fig",
|
"clap_complete_fig",
|
||||||
"clap_complete_nushell",
|
"clap_complete_nushell",
|
||||||
|
"regex",
|
||||||
"serde",
|
"serde",
|
||||||
"vergen",
|
"vergen",
|
||||||
"yazi-adaptor",
|
"yazi-adaptor",
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@
|
||||||
# Resize logo
|
# Resize logo
|
||||||
for RES in 16 24 32 48 64 128 256; do
|
for RES in 16 24 32 48 64 128 256; do
|
||||||
mkdir -p $out/share/icons/hicolor/"$RES"x"$RES"/apps
|
mkdir -p $out/share/icons/hicolor/"$RES"x"$RES"/apps
|
||||||
convert assets/logo.png -resize "$RES"x"$RES" $out/share/icons/hicolor/"$RES"x"$RES"/apps/yazi.png
|
magick assets/logo.png -resize "$RES"x"$RES" $out/share/icons/hicolor/"$RES"x"$RES"/apps/yazi.png
|
||||||
done
|
done
|
||||||
|
|
||||||
mkdir -p $out/share/applications
|
mkdir -p $out/share/applications
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ homepage = "https://yazi-rs.github.io"
|
||||||
repository = "https://github.com/sxyazi/yazi"
|
repository = "https://github.com/sxyazi/yazi"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
regex = "1.10.4"
|
||||||
yazi-adaptor = { path = "../yazi-adaptor", version = "0.2.5" }
|
yazi-adaptor = { path = "../yazi-adaptor", version = "0.2.5" }
|
||||||
yazi-config = { path = "../yazi-config", version = "0.2.5" }
|
yazi-config = { path = "../yazi-config", version = "0.2.5" }
|
||||||
yazi-shared = { path = "../yazi-shared", version = "0.2.5" }
|
yazi-shared = { path = "../yazi-shared", version = "0.2.5" }
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
use std::{collections::HashSet, env, ffi::OsString, fmt::Write, path::{Path, PathBuf}, process};
|
use std::{collections::HashSet, env, ffi::{OsStr, OsString}, fmt::Write, path::{Path, PathBuf}, process};
|
||||||
|
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
use regex::Regex;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use yazi_config::PREVIEW;
|
use yazi_config::PREVIEW;
|
||||||
use yazi_shared::{fs::{current_cwd, expand_path}, Xdg};
|
use yazi_shared::{fs::{current_cwd, expand_path}, Xdg};
|
||||||
|
|
@ -37,6 +38,22 @@ impl Boot {
|
||||||
(parent.unwrap().to_owned(), Some(entry.file_name().unwrap().to_owned()))
|
(parent.unwrap().to_owned(), Some(entry.file_name().unwrap().to_owned()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn process_output(name: impl AsRef<OsStr>, arg: impl AsRef<OsStr>) -> String {
|
||||||
|
match std::process::Command::new(name.as_ref()).arg(arg).output() {
|
||||||
|
Ok(out) if out.status.success() => {
|
||||||
|
let line =
|
||||||
|
String::from_utf8_lossy(&out.stdout).trim().lines().next().unwrap_or_default().to_owned();
|
||||||
|
Regex::new(r"\d+\.\d+(\.\d+-\d+|\.\d+|\b)")
|
||||||
|
.unwrap()
|
||||||
|
.find(&line)
|
||||||
|
.map(|m| m.as_str().to_owned())
|
||||||
|
.unwrap_or(line)
|
||||||
|
}
|
||||||
|
Ok(out) => format!("{:?}, {:?}", out.status, String::from_utf8_lossy(&out.stderr)),
|
||||||
|
Err(e) => format!("{e}"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn action_version() -> String {
|
fn action_version() -> String {
|
||||||
format!(
|
format!(
|
||||||
"{} ({} {})",
|
"{} ({} {})",
|
||||||
|
|
@ -47,37 +64,29 @@ impl Boot {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn action_debug() -> Result<String, std::fmt::Error> {
|
fn action_debug() -> Result<String, std::fmt::Error> {
|
||||||
use std::{env::consts::{ARCH, FAMILY, OS}, process::Command};
|
use std::env::consts::{ARCH, FAMILY, OS};
|
||||||
let mut s = String::new();
|
let mut s = String::new();
|
||||||
|
|
||||||
writeln!(s, "\nYazi")?;
|
writeln!(s, "\nYazi")?;
|
||||||
writeln!(s, " Version: {}", Self::action_version())?;
|
writeln!(s, " Version: {}", Self::action_version())?;
|
||||||
writeln!(s, " OS: {}-{} ({})", OS, ARCH, FAMILY)?;
|
writeln!(s, " Debug : {}", cfg!(debug_assertions))?;
|
||||||
writeln!(s, " Debug: {}", cfg!(debug_assertions))?;
|
writeln!(s, " OS : {}-{} ({})", OS, ARCH, FAMILY)?;
|
||||||
|
|
||||||
writeln!(s, "\nYa")?;
|
writeln!(s, "\nYa")?;
|
||||||
writeln!(
|
writeln!(s, " Version: {}", Self::process_output("ya", "--version"))?;
|
||||||
s,
|
|
||||||
" Version: {:?}",
|
|
||||||
Command::new("ya")
|
|
||||||
.arg("--version")
|
|
||||||
.output()
|
|
||||||
.and_then(|output| Ok(String::from_utf8(output.stdout)))
|
|
||||||
.unwrap_or(Ok("Nill".to_string()))
|
|
||||||
)?;
|
|
||||||
|
|
||||||
writeln!(s, "\nEmulator")?;
|
writeln!(s, "\nEmulator")?;
|
||||||
writeln!(s, " Emulator.via_env: {:?}", yazi_adaptor::Emulator::via_env())?;
|
writeln!(s, " Emulator.via_env: {:?}", yazi_adaptor::Emulator::via_env())?;
|
||||||
writeln!(s, " Emulator.via_csi: {:?}", yazi_adaptor::Emulator::via_csi())?;
|
writeln!(s, " Emulator.via_csi: {:?}", yazi_adaptor::Emulator::via_csi())?;
|
||||||
writeln!(s, " Emulator.detect: {:?}", yazi_adaptor::Emulator::detect())?;
|
writeln!(s, " Emulator.detect : {:?}", yazi_adaptor::Emulator::detect())?;
|
||||||
|
|
||||||
writeln!(s, "\nAdaptor")?;
|
writeln!(s, "\nAdaptor")?;
|
||||||
writeln!(s, " Adaptor.matches: {:?}", yazi_adaptor::Adaptor::matches())?;
|
writeln!(s, " Adaptor.matches: {:?}", yazi_adaptor::Adaptor::matches())?;
|
||||||
|
|
||||||
writeln!(s, "\nDesktop")?;
|
writeln!(s, "\nDesktop")?;
|
||||||
writeln!(s, " XDG_SESSION_TYPE: {:?}", env::var_os("XDG_SESSION_TYPE"))?;
|
writeln!(s, " XDG_SESSION_TYPE: {:?}", env::var_os("XDG_SESSION_TYPE"))?;
|
||||||
writeln!(s, " WAYLAND_DISPLAY: {:?}", env::var_os("WAYLAND_DISPLAY"))?;
|
writeln!(s, " WAYLAND_DISPLAY : {:?}", env::var_os("WAYLAND_DISPLAY"))?;
|
||||||
writeln!(s, " DISPLAY: {:?}", env::var_os("DISPLAY"))?;
|
writeln!(s, " DISPLAY : {:?}", env::var_os("DISPLAY"))?;
|
||||||
|
|
||||||
writeln!(s, "\nSSH")?;
|
writeln!(s, "\nSSH")?;
|
||||||
writeln!(s, " shared.in_ssh_connection: {:?}", yazi_shared::in_ssh_connection())?;
|
writeln!(s, " shared.in_ssh_connection: {:?}", yazi_shared::in_ssh_connection())?;
|
||||||
|
|
@ -90,22 +99,11 @@ impl Boot {
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
writeln!(s, "\nVariables")?;
|
writeln!(s, "\nVariables")?;
|
||||||
writeln!(s, " SHELL: {:?}", env::var_os("SHELL"))?;
|
writeln!(s, " SHELL : {:?}", env::var_os("SHELL"))?;
|
||||||
writeln!(s, " EDITOR: {:?}", env::var_os("EDITOR"))?;
|
writeln!(s, " EDITOR : {:?}", env::var_os("EDITOR"))?;
|
||||||
writeln!(s, " ZELLIJ_SESSION_NAME: {:?}", env::var_os("ZELLIJ_SESSION_NAME"))?;
|
writeln!(s, " ZELLIJ_SESSION_NAME: {:?}", env::var_os("ZELLIJ_SESSION_NAME"))?;
|
||||||
writeln!(s, " YAZI_FILE_ONE: {:?}", env::var_os("YAZI_FILE_ONE"))?;
|
writeln!(s, " YAZI_FILE_ONE : {:?}", env::var_os("YAZI_FILE_ONE"))?;
|
||||||
writeln!(s, " YAZI_CONFIG_HOME: {:?}", env::var_os("YAZI_CONFIG_HOME"))?;
|
writeln!(s, " YAZI_CONFIG_HOME : {:?}", env::var_os("YAZI_CONFIG_HOME"))?;
|
||||||
|
|
||||||
writeln!(s, "\nfile(1)")?;
|
|
||||||
writeln!(
|
|
||||||
s,
|
|
||||||
" Version: {:?}",
|
|
||||||
Command::new(env::var_os("YAZI_FILE_ONE").unwrap_or("file".into()))
|
|
||||||
.arg("--version")
|
|
||||||
.output()
|
|
||||||
.and_then(|output| Ok(String::from_utf8(output.stdout)))
|
|
||||||
.unwrap_or(Ok("Nill".to_string()))
|
|
||||||
)?;
|
|
||||||
|
|
||||||
writeln!(s, "\nText Opener")?;
|
writeln!(s, "\nText Opener")?;
|
||||||
writeln!(
|
writeln!(
|
||||||
|
|
@ -113,121 +111,28 @@ impl Boot {
|
||||||
" default: {:?}",
|
" default: {:?}",
|
||||||
yazi_config::OPEN.openers("f75a.txt", "text/plain").and_then(|a| a.first().cloned())
|
yazi_config::OPEN.openers("f75a.txt", "text/plain").and_then(|a| a.first().cloned())
|
||||||
)?;
|
)?;
|
||||||
writeln!(s, " block: {:?}", yazi_config::OPEN.block_opener("bulk.txt", "text/plain"))?;
|
writeln!(s, " block : {:?}", yazi_config::OPEN.block_opener("bulk.txt", "text/plain"))?;
|
||||||
|
|
||||||
writeln!(s, "\ntmux")?;
|
writeln!(s, "\ntmux")?;
|
||||||
writeln!(s, " TMUX: {:?}", *yazi_adaptor::TMUX)?;
|
writeln!(s, " TMUX : {:?}", *yazi_adaptor::TMUX)?;
|
||||||
|
writeln!(s, " Version: {}", Self::process_output("tmux", "-V"))?;
|
||||||
|
|
||||||
writeln!(s, "\nDependencies Versions")?;
|
writeln!(s, "\nDependencies")?;
|
||||||
writeln!(s, "\nffmpegthumbnailer")?;
|
|
||||||
writeln!(
|
writeln!(
|
||||||
s,
|
s,
|
||||||
" Version: {:?}",
|
" file : {}",
|
||||||
Command::new("ffmpegthumbnailer")
|
Self::process_output(env::var_os("YAZI_FILE_ONE").unwrap_or("file".into()), "--version")
|
||||||
.arg("-v")
|
|
||||||
.output()
|
|
||||||
.and_then(|output| Ok(String::from_utf8(output.stdout)))
|
|
||||||
.unwrap_or(Ok("Nill".to_string()))
|
|
||||||
)?;
|
|
||||||
|
|
||||||
writeln!(s, "\nUeberzug++")?;
|
|
||||||
writeln!(
|
|
||||||
s,
|
|
||||||
" Version: {:?}",
|
|
||||||
Command::new("ueberzugpp")
|
|
||||||
.arg("version")
|
|
||||||
.output()
|
|
||||||
.and_then(|output| Ok(String::from_utf8(output.stdout)))
|
|
||||||
.unwrap_or(Ok("Nill".to_string()))
|
|
||||||
)?;
|
|
||||||
|
|
||||||
writeln!(s, "\nunar")?;
|
|
||||||
writeln!(
|
|
||||||
s,
|
|
||||||
" Version: {:?}",
|
|
||||||
Command::new("unar")
|
|
||||||
.arg("--version")
|
|
||||||
.output()
|
|
||||||
.and_then(|output| Ok(String::from_utf8(output.stdout)))
|
|
||||||
.unwrap_or(Ok("Nill".to_string()))
|
|
||||||
)?;
|
|
||||||
|
|
||||||
writeln!(s, "\njq")?;
|
|
||||||
writeln!(
|
|
||||||
s,
|
|
||||||
" Version: {:?}",
|
|
||||||
Command::new("jq")
|
|
||||||
.arg("--version")
|
|
||||||
.output()
|
|
||||||
.and_then(|output| Ok(String::from_utf8(output.stdout)))
|
|
||||||
.unwrap_or(Ok("Nill".to_string()))
|
|
||||||
)?;
|
|
||||||
|
|
||||||
writeln!(s, "\nfd")?;
|
|
||||||
writeln!(
|
|
||||||
s,
|
|
||||||
" Version: {:?}",
|
|
||||||
Command::new("fd")
|
|
||||||
.arg("--version")
|
|
||||||
.output()
|
|
||||||
.and_then(|output| Ok(String::from_utf8(output.stdout)))
|
|
||||||
.unwrap_or(Ok("Nill".to_string()))
|
|
||||||
)?;
|
|
||||||
|
|
||||||
writeln!(s, "\nrg")?;
|
|
||||||
writeln!(
|
|
||||||
s,
|
|
||||||
" Version: {:?}",
|
|
||||||
Command::new("rg")
|
|
||||||
.arg("--version")
|
|
||||||
.output()
|
|
||||||
.and_then(|output| Ok(String::from_utf8(output.stdout)))
|
|
||||||
.unwrap_or(Ok("Nill".to_string()))
|
|
||||||
)?;
|
|
||||||
|
|
||||||
writeln!(s, "\nfzf")?;
|
|
||||||
writeln!(
|
|
||||||
s,
|
|
||||||
" Version: {:?}",
|
|
||||||
Command::new("fzf")
|
|
||||||
.arg("--version")
|
|
||||||
.output()
|
|
||||||
.and_then(|output| Ok(String::from_utf8(output.stdout)))
|
|
||||||
.unwrap_or(Ok("Nill".to_string()))
|
|
||||||
)?;
|
|
||||||
|
|
||||||
writeln!(s, "\nzoxide")?;
|
|
||||||
writeln!(
|
|
||||||
s,
|
|
||||||
" Version: {:?}",
|
|
||||||
Command::new("zoxide")
|
|
||||||
.arg("--version")
|
|
||||||
.output()
|
|
||||||
.and_then(|output| Ok(String::from_utf8(output.stdout)))
|
|
||||||
.unwrap_or(Ok("Nill".to_string()))
|
|
||||||
)?;
|
|
||||||
|
|
||||||
writeln!(s, "\nchafa")?;
|
|
||||||
writeln!(
|
|
||||||
s,
|
|
||||||
" Version: {:?}",
|
|
||||||
Command::new("chafa")
|
|
||||||
.arg("--version")
|
|
||||||
.output()
|
|
||||||
.and_then(|output| Ok(String::from_utf8(output.stdout)))
|
|
||||||
.unwrap_or(Ok("Nill".to_string()))
|
|
||||||
)?;
|
|
||||||
|
|
||||||
writeln!(s, "\ntmux")?;
|
|
||||||
writeln!(
|
|
||||||
s,
|
|
||||||
" Version: {:?}",
|
|
||||||
Command::new("tmux")
|
|
||||||
.arg("-V")
|
|
||||||
.output()
|
|
||||||
.and_then(|output| Ok(String::from_utf8(output.stdout)))
|
|
||||||
.unwrap_or(Ok("Nill".to_string()))
|
|
||||||
)?;
|
)?;
|
||||||
|
writeln!(s, " ueberzugpp : {}", Self::process_output("ueberzugpp", "--version"))?;
|
||||||
|
writeln!(s, " ffmpegthumbnailer: {}", Self::process_output("ffmpegthumbnailer", "-v"))?;
|
||||||
|
writeln!(s, " magick : {}", Self::process_output("magick", "--version"))?;
|
||||||
|
writeln!(s, " fzf : {}", Self::process_output("fzf", "--version"))?;
|
||||||
|
writeln!(s, " fd : {}", Self::process_output("fd", "--version"))?;
|
||||||
|
writeln!(s, " rg : {}", Self::process_output("rg", "--version"))?;
|
||||||
|
writeln!(s, " chafa : {}", Self::process_output("chafa", "--version"))?;
|
||||||
|
writeln!(s, " zoxide : {}", Self::process_output("zoxide", "--version"))?;
|
||||||
|
writeln!(s, " unar : {}", Self::process_output("unar", "--version"))?;
|
||||||
|
writeln!(s, " jq : {}", Self::process_output("jq", "--version"))?;
|
||||||
|
|
||||||
writeln!(s, "\n\n--------------------------------------------------")?;
|
writeln!(s, "\n\n--------------------------------------------------")?;
|
||||||
writeln!(
|
writeln!(
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ function M:preload()
|
||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
|
|
||||||
local child, code = Command("convert"):args({
|
local child, code = Command("magick"):args({
|
||||||
"-size",
|
"-size",
|
||||||
"800x560",
|
"800x560",
|
||||||
"-gravity",
|
"-gravity",
|
||||||
|
|
@ -41,7 +41,7 @@ function M:preload()
|
||||||
}):spawn()
|
}):spawn()
|
||||||
|
|
||||||
if not child then
|
if not child then
|
||||||
ya.err("spawn `convert` command returns " .. tostring(code))
|
ya.err("spawn `magick` command returns " .. tostring(code))
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ function M:preload()
|
||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
|
|
||||||
local child, code = Command("convert"):args({
|
local child, code = Command("magick"):args({
|
||||||
"-density",
|
"-density",
|
||||||
"200",
|
"200",
|
||||||
"-resize",
|
"-resize",
|
||||||
|
|
@ -32,7 +32,7 @@ function M:preload()
|
||||||
}):spawn()
|
}):spawn()
|
||||||
|
|
||||||
if not child then
|
if not child then
|
||||||
ya.err("spawn `convert` command returns " .. tostring(code))
|
ya.err("spawn `magick` command returns " .. tostring(code))
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue