diff options
Diffstat (limited to 'mac/.config/yazi')
| -rw-r--r-- | mac/.config/yazi/init.lua | 41 | ||||
| -rw-r--r-- | mac/.config/yazi/keymap-default.toml | 20 | ||||
| -rw-r--r-- | mac/.config/yazi/plugins/confirm-quit.yazi/main.lua | 20 | ||||
| -rw-r--r-- | mac/.config/yazi/plugins/folder-rules.yazi/main.lua | 12 | ||||
| -rw-r--r-- | mac/.config/yazi/plugins/parent-arrow.yazi/main.lua | 24 | ||||
| -rw-r--r-- | mac/.config/yazi/yazi.toml | 11 |
6 files changed, 128 insertions, 0 deletions
diff --git a/mac/.config/yazi/init.lua b/mac/.config/yazi/init.lua index 9d6b9ed..13d69a6 100644 --- a/mac/.config/yazi/init.lua +++ b/mac/.config/yazi/init.lua @@ -1,3 +1,33 @@ +Status:children_add(function(self) + local h = self._current.hovered + if h and h.link_to then + return " -> " .. tostring(h.link_to) + else + return "" + end +end, 3300, Status.LEFT) + +Status:children_add(function() + local h = cx.active.current.hovered + if not h or ya.target_family() ~= "unix" then + return "" + end + + return ui.Line({ + ui.Span(ya.user_name(h.cha.uid) or tostring(h.cha.uid)):fg("magenta"), + ":", + ui.Span(ya.group_name(h.cha.gid) or tostring(h.cha.gid)):fg("magenta"), + " ", + }) +end, 500, Status.RIGHT) + +Header:children_add(function() + if ya.target_family() ~= "unix" then + return "" + end + return ui.Span(ya.user_name() .. "@" .. ya.host_name() .. ":"):fg("blue") +end, 500, Header.LEFT) + if os.getenv("NVIM") then require("toggle-pane"):entry("min-preview") end @@ -13,6 +43,15 @@ require("full-border"):setup({ th.git = th.git or {} th.git.modified_sign = "M" th.git.deleted_sign = "D" +th.git.added_sign = "A" +th.git.renamed_sign = "R" +th.git.copied_sign = "C" +th.git.untracked_sign = "?" +th.git.ignored_sign = "!" +th.git.conflicted_sign = "U" +th.git.typechange_sign = "T" +th.git.staged_sign = "+" + require("git"):setup() require("mactag"):setup({ @@ -33,3 +72,5 @@ require("mactag"):setup({ Purple = "#cb88f8", }, }) + +require("folder-rules"):setup() diff --git a/mac/.config/yazi/keymap-default.toml b/mac/.config/yazi/keymap-default.toml index b0ecb37..d0ca6f2 100644 --- a/mac/.config/yazi/keymap-default.toml +++ b/mac/.config/yazi/keymap-default.toml @@ -226,6 +226,26 @@ on = "-" run = "plugin zoom -1" desc = "Zoom out hovered file" +[[mgr.prepend_keymap]] +on = "K" +run = "plugin parent-arrow -1" + +[[mgr.prepend_keymap]] +on = "J" +run = "plugin parent-arrow 1" + +[[mgr.prepend_keymap]] +on = "q" +run = "plugin confirm-quit" + +[[mgr.prepend_keymap]] +on = "<C-p>" +run = 'shell -- qlmanage -p "$@"' + +[[mgr.prepend_keymap]] +on = "<C-m>" +run = 'shell --block -- neomutt -a "$@"' + [tasks] keymap = [ diff --git a/mac/.config/yazi/plugins/confirm-quit.yazi/main.lua b/mac/.config/yazi/plugins/confirm-quit.yazi/main.lua new file mode 100644 index 0000000..f171bc0 --- /dev/null +++ b/mac/.config/yazi/plugins/confirm-quit.yazi/main.lua @@ -0,0 +1,20 @@ +local count = ya.sync(function() + return #cx.tabs +end) + +local function entry() + if count() < 2 then + return ya.emit("quit", {}) + end + + local yes = ya.confirm({ + pos = { "center", w = 60, h = 10 }, + title = "Quit?", + content = ui.Text("There are multiple tabs open. Are you sure you want to quit?"):wrap(ui.Wrap.YES), + }) + if yes then + ya.emit("quit", {}) + end +end + +return { entry = entry } diff --git a/mac/.config/yazi/plugins/folder-rules.yazi/main.lua b/mac/.config/yazi/plugins/folder-rules.yazi/main.lua new file mode 100644 index 0000000..556f610 --- /dev/null +++ b/mac/.config/yazi/plugins/folder-rules.yazi/main.lua @@ -0,0 +1,12 @@ +local function setup() + ps.sub("cd", function() + local cwd = cx.active.current.cwd + if cwd:ends_with("Downloads") then + ya.emit("sort", { "mtime", reverse = true, dir_first = false }) + else + ya.emit("sort", { "alphabetical", reverse = false, dir_first = true }) + end + end) +end + +return { setup = setup } diff --git a/mac/.config/yazi/plugins/parent-arrow.yazi/main.lua b/mac/.config/yazi/plugins/parent-arrow.yazi/main.lua new file mode 100644 index 0000000..a4fd880 --- /dev/null +++ b/mac/.config/yazi/plugins/parent-arrow.yazi/main.lua @@ -0,0 +1,24 @@ +--- @sync entry +local function entry(_, job) + local parent = cx.active.parent + if not parent then + return + end + + local offset = tonumber(job.args[1]) + if not offset then + return ya.err(job.args[1], "is not a number") + end + + local start = parent.cursor + 1 + offset + local end_ = offset < 0 and 1 or #parent.files + local step = offset < 0 and -1 or 1 + for i = start, end_, step do + local target = parent.files[i] + if target and target.cha.is_dir then + return ya.emit("cd", { target.url }) + end + end +end + +return { entry = entry } diff --git a/mac/.config/yazi/yazi.toml b/mac/.config/yazi/yazi.toml index 5cb5fc9..d1067fd 100644 --- a/mac/.config/yazi/yazi.toml +++ b/mac/.config/yazi/yazi.toml @@ -57,6 +57,13 @@ play = [ { run = '''mediainfo "$1"; echo "Press enter to exit"; read _''', block = true, desc = "Show media info", for = "unix" }, ] +[[opener.set-wallpaper]] +run = ''' + osascript -e 'on run {img}' -e 'tell application "System Events" to set picture of every desktop to img' -e 'end run' "$0" +''' +for = "macos" +desc = "Set as wallpaper" + [open] rules = [ # Folder @@ -78,6 +85,10 @@ rules = [ { name = "*", use = [ "open", "reveal" ] }, ] +[[open.prepend_rules]] +mime = "image/*" +use = [ "set-wallpaper", "open" ] + [tasks] micro_workers = 10 macro_workers = 10 |
