Yazi: Improve openers.
This commit is contained in:
parent
3f4f48fa8b
commit
2dc3829b5c
|
@ -9,8 +9,8 @@
|
|||
charset = "utf-8";
|
||||
indent_style = "tab";
|
||||
indent_size = 2;
|
||||
insert_final_newline = "true";
|
||||
trim_trailing_whitespace = "true";
|
||||
insert_final_newline = false;
|
||||
trim_trailing_whitespace = true;
|
||||
};
|
||||
|
||||
"Makefile" = {
|
||||
|
|
|
@ -4,29 +4,39 @@
|
|||
manager = {
|
||||
prepend_keymap = [
|
||||
{
|
||||
desc = "Dangerous life.";
|
||||
on = "d";
|
||||
run = "remove --permanently";
|
||||
desc = "Dangerous life.";
|
||||
}
|
||||
{
|
||||
desc = "Dangerous life.";
|
||||
on = "D";
|
||||
run = "remove --permanently --force";
|
||||
desc = "Dangerous life.";
|
||||
}
|
||||
{
|
||||
desc = "Who wants files anyway?";
|
||||
on = "a";
|
||||
run = "create --dir";
|
||||
desc = "Who wants files anyway?";
|
||||
}
|
||||
{
|
||||
desc = "I want, sometimes.";
|
||||
on = "A";
|
||||
run = "create --force";
|
||||
desc = "I want, sometimes.";
|
||||
}
|
||||
{
|
||||
desc = "Spawn shell here.";
|
||||
on = "<Enter>";
|
||||
run = ''shell "SHELL_NAME=yazi $SHELL" --block --confirm'';
|
||||
desc = "Spawn shell here.";
|
||||
}
|
||||
{
|
||||
desc = "Open interactively";
|
||||
on = "o";
|
||||
run = "open --interactive";
|
||||
}
|
||||
{
|
||||
desc = "Open default";
|
||||
on = "O";
|
||||
run = "open";
|
||||
}
|
||||
];
|
||||
};
|
||||
|
|
|
@ -39,7 +39,13 @@
|
|||
archive = [
|
||||
{
|
||||
desc = "Archive";
|
||||
run = openWith "unpack";
|
||||
run = openWith "archive";
|
||||
}
|
||||
];
|
||||
archive_fast = [
|
||||
{
|
||||
desc = "Archive Fast";
|
||||
run = openWith "archive_fast";
|
||||
}
|
||||
];
|
||||
audio = [
|
||||
|
@ -118,13 +124,19 @@
|
|||
run = openWith "funlock";
|
||||
}
|
||||
];
|
||||
unpack = [
|
||||
{
|
||||
desc = "Unpack";
|
||||
run = openWith "unpack";
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
open = {
|
||||
rules =
|
||||
let
|
||||
defaultUse = [
|
||||
"text"
|
||||
"archive_fast"
|
||||
"hex"
|
||||
];
|
||||
mkMime = mime: use: {
|
||||
|
@ -139,11 +151,11 @@
|
|||
[
|
||||
# Use `file -i file.txt` to find file mime type.
|
||||
# Use `xdg-mime query default "text/plain"` to find default app.
|
||||
(mkMime "application/gzip" [ "archive" ])
|
||||
(mkMime "application/x-tar" [ "archive" ])
|
||||
(mkMime "application/x-xz" [ "archive" ])
|
||||
(mkMime "application/zip" [ "archive" ])
|
||||
(mkMime "application/x-7z-compressed" [ "archive" ])
|
||||
(mkMime "application/gzip" [ "unpack" ])
|
||||
(mkMime "application/x-tar" [ "unpack" ])
|
||||
(mkMime "application/x-xz" [ "unpack" ])
|
||||
(mkMime "application/zip" [ "unpack" ])
|
||||
(mkMime "application/x-7z-compressed" [ "unpack" ])
|
||||
(mkMime "application/x-iso9660-image" [ "mount" ])
|
||||
(mkMime "application/x-raw-disk-image" [ "unlock" ])
|
||||
(mkMime "application/pdf" [ "pdf" ])
|
||||
|
@ -155,7 +167,10 @@
|
|||
])
|
||||
(mkMime "video/*" [ "video" ])
|
||||
(mkMime "text/html" [ "browser" ])
|
||||
(mkMime "text/*" [ "text" ])
|
||||
(mkMime "application/vnd.openxmlformats-officedocument.*" [ "document" ])
|
||||
(mkMime "inode/directory" [ "archive" ])
|
||||
(mkMime "inode/x-empty" [ "text" ])
|
||||
(mkMime "*" [ ])
|
||||
];
|
||||
};
|
||||
|
|
|
@ -363,7 +363,8 @@
|
|||
|
||||
# Check if file is an archive.
|
||||
function _is_archive() {
|
||||
local out=$(echo "''${*}" | grep -E ''${_archive_pattern})
|
||||
local target="''${*}"
|
||||
local out=$(echo "''${target##*/}" | grep -E ''${_archive_pattern})
|
||||
|
||||
[[ "''${out}" != "" ]]
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
process() {
|
||||
# Skip archive.
|
||||
if $(_is_archive ''${target}); then
|
||||
if $(_is_archive "''${target}"); then
|
||||
_iterate_skip "File is an archive, skip."
|
||||
return 0
|
||||
fi
|
||||
|
@ -51,7 +51,7 @@
|
|||
|
||||
process() {
|
||||
# Skip archive.
|
||||
if $(_is_archive ''${target}); then
|
||||
if $(_is_archive "''${target}"); then
|
||||
_iterate_skip "File is an archive, skip."
|
||||
return 0
|
||||
fi
|
||||
|
|
|
@ -70,6 +70,12 @@
|
|||
# Use full path to file.
|
||||
target=''$(realpath "''${target}")
|
||||
|
||||
# Check for archive.
|
||||
if $(_is_archive "''${target}"); then
|
||||
unarchive "''${target}"
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Unpack file type.
|
||||
local type="''${target##*.}"
|
||||
|
||||
|
|
Loading…
Reference in a new issue