diff --git a/modules/shell.nix b/modules/shell.nix index 2d0a94c..c9782b6 100644 --- a/modules/shell.nix +++ b/modules/shell.nix @@ -8,6 +8,7 @@ environment.systemPackages = with pkgs; [ neovim + yazi git zoxide tlrc diff --git a/stow/.config/fish/functions/y.fish b/stow/.config/fish/functions/y.fish new file mode 100644 index 0000000..5dd6c61 --- /dev/null +++ b/stow/.config/fish/functions/y.fish @@ -0,0 +1,8 @@ +function y + set tmp (mktemp -t "yazi-cwd.XXXXXX") + command yazi $argv --cwd-file="$tmp" + if read -z cwd < "$tmp"; and [ -n "$cwd" ]; and [ "$cwd" != "$PWD" ] + builtin cd -- "$cwd" + end + rm -f -- "$tmp" +end diff --git a/stow/.config/yazi/yazi.toml b/stow/.config/yazi/yazi.toml new file mode 100644 index 0000000..5c13a34 --- /dev/null +++ b/stow/.config/yazi/yazi.toml @@ -0,0 +1,56 @@ +[mgr] +show_hidden = true +show_symlink = true + +sort_by = "alphabetical" +sort_reverse = false +sort_dir_first = true + +linemode = "permissions" +scrolloff = 8 + +[preview] +wrap = "no" +tab_size = 2 + +[opener] +edit = [ + { run = "$EDITOR %s", block = true, desc = "Open in text editor"}, +] + +editimg = [ + { run = "gimp %s", block = false, desc = "Open in image editor" }, +] + +play = [ + { run = "mpv %s", block = false, for = "linux", desc = "Play video"}, + { run = "iina %s", block = false, for = "macos", desc = "Play video"}, +] + +open = [ + { run = "xdg-open %s", block = false, for = "linux", desc = "Open with default program"}, + { run = "open %s", block = false, for = "macos", desc = "Open with default program"}, +] + +setwallpaper = [ + { run = "matugen --config ~/.config/matugen/config.toml image %s", block = false, for = "macos", desc = "Set as wallpaper"}, + { run = "matugen image %s", block = false, for = "linux", desc = "Set as wallpaper"}, +] + +setwallpaperlight = [ + { run = "matugen --config ~/.config/matugen/config.toml image -m light %s", block = false, for = "macos", desc = "Set as wallpaper (light)"}, + { run = "matugen image -m light %s", block = false, for = "linux", desc = "Set as wallpaper (light)"}, +] + +[open] +rules = [ + { mime = "text/*", use = "edit" }, + { mime = "video/*", use = "play" }, + { mime = "image/*", use = [ "open", "setwallpaper", "setwallpaperlight", "editimg" ] }, + + { url = "*.html", use = [ "open", "edit" ] }, + { mime = "application/json", use = "edit" }, + + # Multiple openers for a single rule + { url = "*", use = "open" }, +] diff --git a/stow/.zshrc b/stow/.zshrc index d0e1a53..92b4ea9 100644 --- a/stow/.zshrc +++ b/stow/.zshrc @@ -109,3 +109,11 @@ plugInstall https://github.com/Aloxaf/fzf-tab fzf-tab.zsh # load fzf and zoxide eval "$(fzf --zsh)" eval "$(zoxide init zsh)" + +function y() { + local tmp="$(mktemp -t "yazi-cwd.XXXXXX")" cwd + command yazi "$@" --cwd-file="$tmp" + IFS= read -r -d '' cwd < "$tmp" + [ -n "$cwd" ] && [ "$cwd" != "$PWD" ] && builtin cd -- "$cwd" + command rm -f -- "$tmp" +}