diff --git a/config/HybridBar/scripts/change-active-workspace b/config/HybridBar/scripts/change-active-workspace old mode 100755 new mode 100644 diff --git a/config/HybridBar/scripts/get-active-workspace b/config/HybridBar/scripts/get-active-workspace old mode 100755 new mode 100644 diff --git a/config/HybridBar/scripts/get-window-title b/config/HybridBar/scripts/get-window-title old mode 100755 new mode 100644 diff --git a/config/HybridBar/scripts/get-workspaces b/config/HybridBar/scripts/get-workspaces old mode 100755 new mode 100644 diff --git a/config/awesome/rc-laptop.lua b/config/awesome/rc-laptop.lua index 296b7f26..e34752d6 100644 --- a/config/awesome/rc-laptop.lua +++ b/config/awesome/rc-laptop.lua @@ -496,7 +496,8 @@ local globalkeys = gears.table.join( end, { description = "lua execute prompt", group = "awesome" }), -- Menubar awful.key({ modkey }, "p", function() - menubar.show() + -- menubar.show() + awful.spawn("rofi -show drun -show-icons") end, { description = "show the menubar", group = "launcher" }) ) diff --git a/config/btop/btop.conf b/config/btop/btop.conf index d03c26e1..b30149c3 100644 --- a/config/btop/btop.conf +++ b/config/btop/btop.conf @@ -57,7 +57,7 @@ update_ms = 500 #* Processes sorting, "pid" "program" "arguments" "threads" "user" "memory" "cpu lazy" "cpu direct", #* "cpu lazy" sorts top process over time (easier to follow), "cpu direct" updates top process directly. -proc_sorting = "user" +proc_sorting = "cpu lazy" #* Reverse sorting order, True or False. proc_reversed = False diff --git a/config/eww/scripts/change-active-workspace b/config/eww/scripts/change-active-workspace old mode 100755 new mode 100644 diff --git a/config/eww/scripts/get-active-workspace b/config/eww/scripts/get-active-workspace old mode 100755 new mode 100644 diff --git a/config/eww/scripts/get-music b/config/eww/scripts/get-music old mode 100755 new mode 100644 diff --git a/config/eww/scripts/get-network b/config/eww/scripts/get-network old mode 100755 new mode 100644 diff --git a/config/eww/scripts/get-window-title b/config/eww/scripts/get-window-title old mode 100755 new mode 100644 diff --git a/config/eww/scripts/get-workspaces b/config/eww/scripts/get-workspaces old mode 100755 new mode 100644 diff --git a/config/eww/scripts/getvol b/config/eww/scripts/getvol old mode 100755 new mode 100644 diff --git a/config/eww/scripts/github b/config/eww/scripts/github old mode 100755 new mode 100644 diff --git a/config/flameshot.ini b/config/flameshot.ini index a24d626e..464875ee 100644 --- a/config/flameshot.ini +++ b/config/flameshot.ini @@ -1,6 +1,6 @@ [General] contrastOpacity=188 -drawColor=#ff0000 +drawColor=#ffffff drawThickness=3 filenamePattern=%Y-%m-%d_%H-%M-%S saveAfterCopy=true diff --git a/config/lf/cleaner b/config/lf/cleaner old mode 100755 new mode 100644 diff --git a/config/lf/lfrc b/config/lf/lfrc old mode 100755 new mode 100644 diff --git a/config/nsxiv/exec/image-info b/config/nsxiv/exec/image-info old mode 100755 new mode 100644 diff --git a/config/nsxiv/exec/key-handler b/config/nsxiv/exec/key-handler old mode 100755 new mode 100644 diff --git a/config/nsxiv/exec/nsxiv-url b/config/nsxiv/exec/nsxiv-url old mode 100755 new mode 100644 diff --git a/config/nsxiv/exec/thumb-info b/config/nsxiv/exec/thumb-info old mode 100755 new mode 100644 diff --git a/config/nsxiv/exec/win-title b/config/nsxiv/exec/win-title old mode 100755 new mode 100644 diff --git a/config/shell/env (conflicted copy 2024-12-22 170642) b/config/shell/env (conflicted copy 2024-12-22 170642) deleted file mode 100644 index b59204e8..00000000 --- a/config/shell/env (conflicted copy 2024-12-22 170642) +++ /dev/null @@ -1,122 +0,0 @@ -#!/bin/zsh -typeset -U PATH path - - -# profile file. Runs on login. Environmental variables are set here. - -# If you don't plan on reverting to bash, you can remove the link in ~/.profile -# to clean up. - -# Adds `~/.local/bin` to $PATH -export PATH="$PATH:${$(find ~/.local/bin -type d -printf %p:)%%:}" -export PATH="$PATH:~/.spicetify" -export PATH="$PATH:${$(find ~/.cache/.bun/bin -type d -printf %p:)%%:}" - -# Disable files -export LESSHISTFILE=- -# export $(dbus-launch) - -export LIBSEAT_BACKEND=logind -# export XDG_RUNTIME_DIR="/run/user/$UID" - -unsetopt PROMPT_SP - - -# Default Apps -export BROWSER="floorp" -export EDITOR="nvim" -export IMAGE="nsxiv" -export READER="zathura" -export TERMINAL="alacritty" -export VIDEO="mpv" -export VISUAL="$EDITOR" -export WM="awesome" - - -# $HOME Clean-up -export XDG_CACHE_HOME="$HOME/.cache" -export XDG_CONFIG_HOME="$HOME/.config" -export XDG_DATA_HOME="$HOME/.local/share" -export XDG_RUNTIME_DIR="$HOME/.cache/xdgr" -export XDG_STATE_HOME="$HOME/.local/share" - -export HYPRSHOT_DIR="$HOME/Pictures/screenshots" -# export XDG_CURRENT_DESKTOP=Hyprland -# export XDG_SESSION_TYPE=wayland -# export XDG_SESSION_DESKTOP=Hyprland -# export HYPRLAND_INSTANCE_SIGNATURE=/tmp/hypr - - -export ANDROID_HOME="$XDG_CONFIG_HOME/android" -export ANDROID_SDK_HOME="$XDG_CONFIG_HOME/android" -export ANDROID_USER_HOME="$XDG_DATA_HOME/android" -export ANSIBLE_CONFIG="$XDG_CONFIG_HOME/ansible/ansible.cfg" -export CARGO_HOME="$XDG_DATA_HOME/cargo" -export CUDA_CACHE_PATH="$XDG_CACHE_HOME/nv" -export DOCKER_CONFIG="$XDG_CONFIG_HOME/docker" -export ELECTRUMDIR="$XDG_DATA_HOME/electrum" -export GNUPGHOME="$XDG_DATA_HOME/gnupg" -export GOPATH="$XDG_DATA_HOME/go" -export GRADLE_USER_HOME="$XDG_DATA_HOME/gradle" -export GTK2_RC_FILES="$XDG_CONFIG_HOME/gtk-2.0/gtkrc" -export HISTFILE="$XDG_CONFIG_HOME/zsh/history" -export HISTFILE="$XDG_DATA_HOME/history" -export HISTFILE="$XDG_STATE_HOME/bash/history" -export INPUTRC="$XDG_CONFIG_HOME/shell/inputrc" -export IPYTHONDIR="$XDG_CONFIG_HOME/ipython" -export KERAS_HOME="$XDG_DATA_HOME/keras" -export KODI_DATA="$XDG_DATA_HOME/kodi" -export MBSYNCRC="$XDG_CONFIG_HOME/mbsync/config" -export MYPY_CACHE_DIR="$XDG_CACHE_HOME/mypy" -export MYSQL_HISTFILE="$XDG_DATA_HOME/mysql_history" -export NODE_REPL_HISTORY="$XDG_DATA_HOME/node_repl_history" -export NOTMUCH_CONFIG="$XDG_CONFIG_HOME/notmuch-config" -export NPM_CONFIG_USERCONFIG="$XDG_CACHE_HOME/npm/npmrc" -export PARALLEL_HOME="$XDG_CONFIG_HOME/parallel" -export PASSWORD_STORE_DIR="$XDG_DATA_HOME/password-store" -export PYENV_ROOT="$XDG_DATA_HOME/pyenv" -export PYTHONSTARTUP="$HOME/python/pythonrc" -export REDISCLI_HISTFILE="$XDG_DATA_HOME/redis/rediscli_history" -export RUSTUP_HOME="$XDG_DATA_HOME/rustup" -export RYE_HOME="$XDG_DATA_HOME/rye" -export SSB_HOME="$XDG_DATA_HOME/zoom" -export STARSHIP_CONFIG="$XDG_CONFIG_HOME/starship/starship.toml" -export TEXMFVAR="$XDG_CACHE_HOME/texlive/texmf-var" -export TMUX_TMPDIR="$XDG_RUNTIME_DIR" -export UNISON="$XDG_DATA_HOME/unison" -export W3M_DIR="$XDG_DATA_HOME/w3m" -export WEECHAT_HOME="$XDG_CONFIG_HOME/weechat" -export WGETRC="$XDG_CONFIG_HOME/wget/wgetrc" -export WINEPREFIX="$XDG_DATA_HOME/wineprefixes/default" -export XAUTHORITY="$XDG_RUNTIME_DIR/Xauthority" -export XCURSOR_PATH="/usr/share/icons:$XDG_DATA_HOME/icons" -export XINITRC="$XDG_CONFIG_HOME/x11/xinitrc" -export ZDOTDIR="$XDG_CONFIG_HOME/zsh" -export _JAVA_OPTIONS="-Djava.util.prefs.userRoot=${XDG_CONFIG_HOME}/java - Djavafx.cachedir=${XDG_CACHE_HOME}/openjfx" -export _JAVA_OPTIONS=-Djava.util.prefs.userRoot="$XDG_CONFIG_HOME/java" - -# Other program settings -export AWT_TOOLKIT="MToolkit wmname LG3D" # May have to install wmname -export DICS="/usr/share/stardict/dic/" -export FZF_DEFAULT_OPTS="--layout=reverse --height 40%" -export LESS=-R -export LESSOPEN="| /usr/bin/highlight -O ansi %s 2>/dev/null" -export LESS_TERMCAP_mb="$(printf '%b' '')" -export LESS_TERMCAP_md="$(printf '%b' '')" -export LESS_TERMCAP_me="$(printf '%b' '')" -export LESS_TERMCAP_se="$(printf '%b' '')" -export LESS_TERMCAP_so="$(printf '%b' '')" -export LESS_TERMCAP_ue="$(printf '%b' '')" -export LESS_TERMCAP_us="$(printf '%b' '')" -export MOZ_USE_XINPUT2="1" # Mozilla smooth scrolling/touchpads. -# export QT_QPA_PLATFORMTHEME="gtk2" # Have QT use gtk2 theme. -# export QT_QPA_PLATFORMTHEME="gtk3" # Have QT use gtk3 theme. -export QT_QPA_PLATFORMTHEME="qt5ct" -export QT_SCREEN_SCALE_FACTORS="1;1" -export SUDO_ASKPASS="$HOME/.local/bin/dmenupass" -export _JAVA_AWT_WM_NONREPARENTING=1 # Fix for Java applications in dwm - -. "$XDG_DATA_HOME/cargo/env" -. "$XDG_DATA_HOME/rye/env" -. "$XDG_CACHE_HOME/deno/.deno/env" - diff --git a/config/x11/opt-apps b/config/x11/opt-apps old mode 100755 new mode 100644 diff --git a/config/yazi/package.toml b/config/yazi/package.toml index fe573385..aceec22d 100644 --- a/config/yazi/package.toml +++ b/config/yazi/package.toml @@ -1,21 +1,21 @@ [plugin] deps = [ {use = "AnirudhG07/nbpreview", rev = "1d85745" }, - {use = "Reledia/glow", rev = "c2ed51e" }, + {use = "Reledia/glow", rev = "5ce76dc" }, {use = "Reledia/hexyl", rev = "39d3d4e" }, {use = "Reledia/miller", rev = "40e0265" }, {use = "Sonico98/exifaudio", rev = "d794614" }, {use = "dedukun/relative-motions", rev = "df97039" }, - {use = "hankertrix/augment-command", rev = "3fa924a" }, - {use = "imsi32/yatline", rev = "1b4a9a1" }, - {use = "kirasok/torrent-preview", rev = "76970b6" }, + {use = "hankertrix/augment-command", rev = "6a367db" }, + {use = "imsi32/yatline", rev = "600ed1f" }, + {use = "kirasok/torrent-preview", rev = "c9e67df" }, {use = "ndtoan96/ouch", rev = "b869886" }, - {use = "pirafrank/what-size", rev = "f08f7f2" }, - {use = "yazi-rs/plugins:chmod", rev = "7afba3a" }, - {use = "yazi-rs/plugins:full-border", rev = "7afba3a" }, - {use = "yazi-rs/plugins:git", rev = "7afba3a" }, - {use = "yazi-rs/plugins:hide-preview", rev = "7afba3a" }, - {use = "yazi-rs/plugins:max-preview", rev = "7afba3a" }, + {use = "pirafrank/what-size", rev = "b23e3a4" }, + {use = "yazi-rs/plugins:chmod", rev = "71c4fc2" }, + {use = "yazi-rs/plugins:full-border", rev = "71c4fc2" }, + {use = "yazi-rs/plugins:git", rev = "71c4fc2" }, + {use = "yazi-rs/plugins:hide-preview", rev = "71c4fc2" }, + {use = "yazi-rs/plugins:max-preview", rev = "71c4fc2" }, ] [flavor] diff --git a/config/yazi/plugins/augment-command.yazi/README.md b/config/yazi/plugins/augment-command.yazi/README.md index 3317a215..5cb5459a 100644 --- a/config/yazi/plugins/augment-command.yazi/README.md +++ b/config/yazi/plugins/augment-command.yazi/README.md @@ -1,7 +1,6 @@ # augment-command.yazi -A [Yazi](https://github.com/sxyazi/yazi) -plugin that enhances Yazi's default commands. +A [Yazi][yazi-link] plugin that enhances Yazi's default commands. This plugin is inspired by the [Yazi tips page](https://yazi-rs.github.io/docs/tips), the [bypass.yazi](https://github.com/Rolv-Apneseth/bypass.yazi) plugin @@ -13,7 +12,7 @@ plugin. - [Requirements](#requirements) - [Installation](#installation) - [Configuration](#configuration) -- [What about the commands are augmented?](#what-about-the-commands-are-augmented) +- [What about the commands are augmented?][augment-section] - [Augmented commands](#augmented-commands) - [New commands](#new-commands) - [Usage](#usage) @@ -22,8 +21,8 @@ plugin. ## Requirements - [Yazi](https://github.com/sxyazi/yazi) v0.4.2+ -- [`7z` or `7zz` command](https://github.com/p7zip-project/p7zip) -- [`file` command](https://www.darwinsys.com/file/) +- [`7z` or `7zz` command][7z-link] +- [`file` command][file-command-link] ## Installation @@ -40,26 +39,24 @@ ya pack -u ## Configuration -| Configuration | Values | Default | Description | -| ----------------------------------- | ------------------------------------- | --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `prompt` | `true` or `false` | `false` | Create a prompt to choose between hovered and selected items when both exist. If this option is disabled, selected items will only be operated on when the hovered item is selected, otherwise the hovered item will be the default item that is operated on. | -| `default_item_group_for_prompt` | `hovered`, `selected` or `none` | `hovered` | The default item group to operate on when the prompt is submitted without any value. This only takes effect if `prompt` is set to `true`, otherwise this option doesn't do anything. `hovered` means the hovered item is operated on, `selected` means the selected items are operated on, and `none` just cancels the operation. | -| `smart_enter` | `true` or `false` | `true` | Use one command to open files or enter a directory. With this option set, the `enter` and `open` commands will both call the `enter` command when a directory is hovered and call the `open` command when a regular file is hovered. You can also enable this behaviour by passing the `--smart` flag to the `enter` or `open` commands. | -| `smart_paste` | `true` or `false` | `false` | Paste items into a directory without entering it. The behaviour is exactly the same as the [smart paste tip on Yazi's documentation](https://yazi-rs.github.io/docs/tips#smart-paste). Setting this option to `false` will use the default `paste` behaviour. You can also enable this behaviour by passing the `--smart` flag to the `paste` command. | -| `smart_tab_create` | `true` or `false` | `false` | Create tabs in the directory that is being hovered instead of the current directory. The behaviour is exactly the same as the [smart tab tip on Yazi's documentation](https://yazi-rs.github.io/docs/tips#smart-tab). Setting this option to `false` will use the default `tab_create` behaviour, which means you need to pass the `--current` flag to the command. You can also enable this behaviour by passing the `--smart` flag to the `tab_create` command. | -| `smart_tab_switch` | `true` or `false` | `false` | If the tab that is being switched to does not exist yet, setting this option to `true` will create all the tabs in between the current number of open tabs, and the tab that is being switched to. The behaviour is exactly the same as [this tip](https://github.com/sxyazi/yazi/issues/918#issuecomment-2058157773). Setting this option to `false` will use the default `tab_switch` behaviour. You can also enable this behaviour by passing the `--smart` flag to the `tab_switch` command. | -| `open_file_after_creation` | `true` or `false` | `false` | This option determines whether the plugin will open a file after it has been created. Setting this option to `true` will cause the plugin to open created file. You can also enable this behaviour by passing the `--open` flag to the `create` command. | -| `enter_directory_after_creation` | `true` or `false` | `false` | This option determines whether the plugin will enter a directory after it has been created. Setting this option to `true` will cause the plugin enter the created directory. You can also enable this behaviour by passing the `--enter` flag to the `create` command. | -| `use_default_create_behaviour` | `true` or `false` | `false` | This option determines whether the plugin will use the behaviour of Yazi's `create` command. Setting this option to `true` will use the behaviour of Yazi's `create` command. You can also enable this behaviour by passing the `--default-behaviour` flag to the `create` command. | -| `enter_archives` | `true` or `false` | `true` | Automatically extract and enter archive files. This option requires the [7z or 7zz command](https://github.com/p7zip-project/p7zip) to be present. | -| `extract_retries` | An integer, like `1`, `3`, `10`, etc. | `3` | This option determines how many times the plugin will retry opening an encrypted or password-protected archive when a wrong password is given. This value plus 1 is the total number of times the plugin will try opening an encrypted or password-protected archive. | -| `extract_archives_recursively` | `true` or `false` | `true` | This option determines whether the plugin will extract all archives inside an archive file recursively. If this option is set to `false`, archive files inside an archive will not be extracted, and you will have to manually extract them yourself. | -| `must_have_hovered_item` | `true` or `false` | `true` | This option stops the plugin from executing any commands when there is no hovered item. | -| `skip_single_subdirectory_on_enter` | `true` or `false` | `true` | Skip directories when there is only one subdirectory and no other files when entering directories. This behaviour can be turned off by passing the `--no-skip` flag to the `enter` or `open` commands. | -| `skip_single_subdirectory_on_leave` | `true` or `false` | `true` | Skip directories when there is only one subdirectory and no other files when leaving directories. This behaviour can be turned off by passing the `--no-skip` flag to the `leave` command. | -| `ignore_hidden_items` | `true` or `false` | `false` | Ignore hidden items when determining whether a directory only has one subdirectory and no other items. Setting this option to `false` will mean that hidden items in a directory will stop the plugin from skipping the single subdirectory. | -| `wraparound_file_navigation` | `true` or `false` | `false` | Wrap around from the bottom to the top or from the top to the bottom when using the `arrow` or `parent_arrow` command to navigate. | -| `sort_directories_first` | `true` or `false` | `true` | This option tells the plugin if you have sorted directories first in your [`yazi.toml` file](https://yazi-rs.github.io/docs/configuration/yazi#manager.sort_dir_first), located at `~/.config/yazi/yazi.toml` on Linux and macOS or `C:\Users\USERNAME\AppData\Roaming\yazi\config\yazi.toml` on Windows, where `USERNAME` is your Windows username. If you have set [`sort_dir_first`](https://yazi-rs.github.io/docs/configuration/yazi#manager.sort_dir_first) to `true` in your [`yazi.toml` file](https://yazi-rs.github.io/docs/configuration/yazi#manager.sort_dir_first), set this option to `true` as well. If you have set [`sort_dir_first`](https://yazi-rs.github.io/docs/configuration/yazi#manager.sort_dir_first) to `false` instead, set this option to `false` as well. This option only affects the `parent_arrow` command with `wraparound_file_navigation` set to `true`. If the [`sort_dir_first`](https://yazi-rs.github.io/docs/configuration/yazi#manager.sort_dir_first) setting doesn't match the plugin's `sort_directories_first` setting, i.e. Yazi's `sort_dir_first` is `true` but the plugin's `sort_directories_first` is `false`, or Yazi's `sort_dir_first` is `false` but the plugin's `sort_directories_first` is `true`, the wraparound functionality of the `parent_arrow` command will not work properly and may act erratically. The default value of `sort_directories_first` follows Yazi's [`sort_dir_first`](https://yazi-rs.github.io/docs/configuration/yazi#manager.sort_dir_first) default value, which is `true`. | +| Configuration | Values | Default | Description | +| ----------------------------------- | ------------------------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `prompt` | `true` or `false` | `false` | Create a prompt to choose between hovered and selected items when both exist. If this option is disabled, selected items will only be operated on when the hovered item is selected, otherwise the hovered item will be the default item that is operated on. | +| `default_item_group_for_prompt` | `hovered`, `selected` or `none` | `hovered` | The default item group to operate on when the prompt is submitted without any value. This only takes effect if `prompt` is set to `true`, otherwise this option doesn't do anything. `hovered` means the hovered item is operated on, `selected` means the selected items are operated on, and `none` just cancels the operation. | +| `smart_enter` | `true` or `false` | `true` | Use one command to open files or enter a directory. With this option set, the `enter` and `open` commands will both call the `enter` command when a directory is hovered and call the `open` command when a regular file is hovered. You can also enable this behaviour by passing the `--smart` flag to the `enter` or `open` commands. | +| `smart_paste` | `true` or `false` | `false` | Paste items into a directory without entering it. The behaviour is exactly the same as the [smart paste tip on Yazi's documentation][smart-paste-tip]. Setting this option to `false` will use the default `paste` behaviour. You can also enable this behaviour by passing the `--smart` flag to the `paste` command. | +| `smart_tab_create` | `true` or `false` | `false` | Create tabs in the directory that is being hovered instead of the current directory. The behaviour is exactly the same as the [smart tab tip on Yazi's documentation][smart-tab-tip]. Setting this option to `false` will use the default `tab_create` behaviour, which means you need to pass the `--current` flag to the command. You can also enable this behaviour by passing the `--smart` flag to the `tab_create` command. | +| `smart_tab_switch` | `true` or `false` | `false` | If the tab that is being switched to does not exist yet, setting this option to `true` will create all the tabs in between the current number of open tabs, and the tab that is being switched to. The behaviour is exactly the same as the [smart switch tip on Yazi's documentation][smart-switch-tip]. Setting this option to `false` will use the default `tab_switch` behaviour. You can also enable this behaviour by passing the `--smart` flag to the `tab_switch` command. | +| `open_file_after_creation` | `true` or `false` | `false` | This option determines whether the plugin will open a file after it has been created. Setting this option to `true` will cause the plugin to open the created file. You can also enable this behaviour by passing the `--open` flag to the `create` command. | +| `enter_directory_after_creation` | `true` or `false` | `false` | This option determines whether the plugin will enter a directory after it has been created. Setting this option to `true` will cause the plugin to enter the created directory. You can also enable this behaviour by passing the `--enter` flag to the `create` command. | +| `use_default_create_behaviour` | `true` or `false` | `false` | This option determines whether the plugin will use the behaviour of Yazi's `create` command. Setting this option to `true` will use the behaviour of Yazi's `create` command. You can also enable this behaviour by passing the `--default-behaviour` flag to the `create` command. | +| `enter_archives` | `true` or `false` | `true` | Automatically extract and enter archive files. This option requires the [`7z` or `7zz` command][7z-link] to be present. | +| `extract_retries` | An integer, like `1`, `3`, `10`, etc. | `3` | This option determines how many times the plugin will retry opening an encrypted or password-protected archive when a wrong password is given. This value plus 1 is the total number of times the plugin will try opening an encrypted or password-protected archive. | +| `recursively_extract_archives` | `true` or `false` | `true` | This option determines whether the plugin will extract all archives inside an archive file recursively. If this option is set to `false`, archive files inside an archive will not be extracted, and you will have to manually extract them yourself. | +| `must_have_hovered_item` | `true` or `false` | `true` | This option stops the plugin from executing any commands when there is no hovered item. | +| `skip_single_subdirectory_on_enter` | `true` or `false` | `true` | Skip directories when there is only one subdirectory and no other files when entering directories. This behaviour can be turned off by passing the `--no-skip` flag to the `enter` or `open` commands. | +| `skip_single_subdirectory_on_leave` | `true` or `false` | `true` | Skip directories when there is only one subdirectory and no other files when leaving directories. This behaviour can be turned off by passing the `--no-skip` flag to the `leave` command. | +| `wraparound_file_navigation` | `true` or `false` | `false` | Wrap around from the bottom to the top or from the top to the bottom when using the `arrow` or `parent_arrow` command to navigate. | If you would like to use the default configuration, which is shown below, you don't need to add anything to your `~/.config/yazi/init.lua` @@ -84,13 +81,11 @@ require("augment-command"):setup({ use_default_create_behaviour = false, enter_archives = true, extract_retries = 3, - extract_archives_recursively = true, + recursively_extract_archives = true, must_have_hovered_item = true, skip_single_subdirectory_on_enter = true, skip_single_subdirectory_on_leave = true, - ignore_hidden_items = false, wraparound_file_navigation = false, - sort_directories_first = true, }) ``` @@ -114,9 +109,7 @@ require("augment-command"):setup({ open_file_after_creation = true, enter_directory_after_creation = true, extract_retries = 5, - ignore_hidden_items = true, wraparound_file_navigation = true, - sort_directories_first = false, }) ``` @@ -143,6 +136,19 @@ then it will operate on the selected items. ### Open (`open`) +- The `open` command is augmented as stated in + [this section above][augment-section]. + + Videos: + + - When `prompt` is set to `true`: + + [open-prompt-video] + + - When `prompt` is set to `false`: + + [open-behaviour-video] + - When `smart_enter` is set to `true`, it calls the `enter` command when the hovered item is a directory. - `--smart` flag to use one command to `open` files and `enter` directories. @@ -151,6 +157,11 @@ then it will operate on the selected items. This allows you to set a key to use this behaviour with the `open` command instead of using it for every `open` command. + + Video: + + [smart-enter-video] + - `--no-skip` flag, which only applies when `smart_enter` is used as it is passed to the `enter` command. More details about this flag can be found at the documentation @@ -161,15 +172,20 @@ then it will operate on the selected items. This can be disabled by setting `enter_archives` to `false` in the configuration. This feature requires the - [`7z` or `7zz` command](https://github.com/p7zip-project/p7zip) + [`7z` or `7zz` command][7z-link] to be present to extract the archives. + + Video: + + [open-auto-extract-archives-video] + - If the extracted archive file contains other archive files in it, those archives will be automatically extracted, keeping the directory structure of the archive if the archive doesn't only contain a single archive file. This feature requires the - [`file` command](https://www.darwinsys.com/file/) + [`file` command][file-command-link] to detect the mime type of the extracted file, and to check whether it is an archive file or not. This makes extracting binaries from @@ -177,17 +193,17 @@ then it will operate on the selected items. to press a key twice to decompress and extract the compressed tarballs. You can disable this feature by setting - `extract_archives_recursively` to `false` + `recursively_extract_archives` to `false` in the configuration. + Video: + + [open-recursively-extract-archives-video] + ### Enter (`enter`) - When `smart_enter` is set to `true`, it calls the `open` command when the hovered item is a file. -- Automatically skips directories that - contain only one subdirectory when entering directories. - This can be turned off by setting - `skip_single_subdirectory_on_enter` to `false` in the configuration. - `--smart` flag to use one command to `enter` directories and `open` files. This flag will cause the `enter` command to call the `open` command when the selected items or the hovered item is a file, @@ -195,6 +211,20 @@ then it will operate on the selected items. This allows you to set a key to use this behaviour with the `enter` command instead of using it for every `enter` command. + + Video: + + [smart-enter-video] + +- Automatically skips directories that + contain only one subdirectory when entering directories. + This can be turned off by setting + `skip_single_subdirectory_on_enter` to `false` in the configuration. + + Video: + + [enter-skip-single-subdirectory-video] + - `--no-skip` flag. It stops the plugin from skipping directories that contain only one subdirectory when entering directories, even when `skip_single_subdirectory_on_enter` is set to `true`. @@ -208,6 +238,11 @@ then it will operate on the selected items. This can be turned off by setting `skip_single_subdirectory_on_leave` to `false` in the configuration. + + Video: + + [leave-skip-single-subdirectory-video] + - `--no-skip` flag. It stops the plugin from skipping directories that contain only one subdirectory, even when `skip_single_subdirectory_on_leave` is set to `true`. @@ -217,12 +252,48 @@ then it will operate on the selected items. ### Rename (`rename`) - The `rename` command is augmented as stated in - [this section above](#what-about-the-commands-are-augmented). + [this section above][augment-section]. + + Videos: + + - When `must_have_hovered_item` is `true`: + + [rename-must-have-hovered-item-video] + + - When `must_have_hovered_item` is `false`: + + [rename-hovered-item-optional-video] + + - When `prompt` is set to `true`: + + [rename-prompt-video] + + - When `prompt` is set to `false`: + + [rename-behaviour-video] ### Remove (`remove`) - The `remove` command is augmented as stated in - [this section above](#what-about-the-commands-are-augmented). + [this section above][augment-section]. + + Videos: + + - When `must_have_hovered_item` is `true`: + + [remove-must-have-hovered-item-video] + + - When `must_have_hovered_item` is `false`: + + [remove-hovered-item-optional-video] + + - When `prompt` is set to `true`: + + [remove-prompt-video] + + - When `prompt` is set to `false`: + + [remove-behaviour-video] ### Create (`create`) @@ -246,31 +317,81 @@ then it will operate on the selected items. component to prompt for a confirmation, like in Yazi v0.3.0 and below. This is not ideal, but it shouldn't happen that often and hopefully wouldn't be too annoying. + If you are using the latest version of Yazi from the main branch, + the `confirm` component is now exposed to plugin developers and + the plugin will use the `confirm` component instead. + However, the separator in the `confirm` component will be the text colour + instead of your configured border colour for the `confirm` component as + the `list` part of the `confirm` component has not been exposed to plugin + developers, so the separator is made using text. - The rationale for this behaviour is that creating a path without a file extension usually means you intend to create a directory instead of a file, as files usually have file extensions. + + Video: + + [create-behaviour-video] + - When `open_file_after_creation` is set to `true`, the `create` command will `open` the created file. This behaviour can also be enabled by passing the `--open` flag to the `create` command. + + Video: + + [create-and-open-files-video] + Likewise, when `enter_directory_after_creation` is set to `true`, the `create` command will `enter` the created directory. This behaviour can also be enabled by passing the `--enter` flag to the `create` command. + + Video: + + [create-and-open-directories-video] + To enable both behaviours with flags, just pass both the `--open` flag and the `--enter` flag to the `create` command. + + Video: + + [create-and-open-files-and-directories-video] + - If you would like to use the behaviour of Yazi's `create` command, probably because you would like to automatically open and enter the created file and directory respectively, you can either set `use_default_create_behaviour` to `true`, or pass the `--default-behaviour` flag to the `create` command. + Video: + + [create-default-behaviour-video] + ### Shell (`shell`) - This command runs the shell command given with the augment stated in - [this section above](#what-about-the-commands-are-augmented). You should + [this section above][augment-section]. You should only use this command if you need the plugin to determine a suitable item group for the command to operate on. Otherwise, you should just use the default `shell` command provided by Yazi. + + Videos: + + - When `must_have_hovered_item` is `true`: + + [shell-must-have-hovered-item-video] + + - When `must_have_hovered_item` is `false`: + + [shell-hovered-item-optional-video] + + - When `prompt` is set to `true`: + + [shell-prompt-video] + + - When `prompt` is set to `false`: + + [shell-behaviour-video] + - To use this command, the syntax is exactly the same as the default `shell` command provided by Yazi. You just provide the command you want and provide any Yazi shell variable, which is documented @@ -332,6 +453,25 @@ then it will operate on the selected items. desc = "Open the pager" ``` + It is also used in the `editor` command, since you usually wouldn't use + your text editor to open directories, especially if you are already using + a terminal file manager like [Yazi][yazi-link]. + The `editor` command is essentially: + + ```toml + # ~/.config/yazi/keymap.toml on Linux and macOS + # C:\Users\USERNAME\AppData\Roaming\yazi\config\keymap.toml on Windows + + [[manager.prepend_keymap]] + on = [ "i" ] + run = '''plugin augment-command --args="shell '$EDITOR $@' --block --exit-if-dir"''' + desc = "Open the pager" + ``` + + Video: + + [shell-exit-if-directory-video] + ### Paste (`paste`) - When `smart_paste` is set to `true`, @@ -350,6 +490,10 @@ then it will operate on the selected items. with the `paste` command instead of using it for every `paste` command. + Video: + + [smart-paste-video] + ### Tab create (`tab_create`) - When `smart_tab_create` is set to `true`, @@ -372,6 +516,10 @@ then it will operate on the selected items. behaviour with the `tab_create` command instead of using it for every `tab_create` command. + Video: + + [smart-tab-create-video] + ### Tab switch (`tab_switch`) - When `smart_tab_switch` is set to `true`, @@ -406,11 +554,20 @@ then it will operate on the selected items. behaviour with the `tab_switch` command instead of using it for every `tab_switch` command. + Video: + + [smart-tab-switch-video] + ### Arrow (`arrow`) - When `wraparound_file_navigation` is set to `true`, the arrow command will wrap around from the bottom to the top or from the top to the bottom when navigating. + + Video: + + [wraparound-arrow-video] + Otherwise, it'll behave like the default `arrow` command. ## New commands @@ -421,74 +578,18 @@ then it will operate on the selected items. but in the parent directory. It allows you to navigate in the parent directory without leaving the current directory. + + Video: + + [parent-arrow-video] + - When `wraparound_file_navigation` is set to `true`, this command will also wrap around from the bottom to the top or from top to the bottom when navigating in the parent directory. - For this feature to work properly, the - [`sort_dir_first`](https://yazi-rs.github.io/docs/configuration/yazi#manager.sort_dir_first) - option in your `~/.config/yazi/yazi.toml` file on Linux and macOS, - or your `C:\Users\USERNAME\AppData\Roaming\yazi\config\yazi.toml` - file on Windows, where `USERNAME` is your Windows username, - has to match the plugin's `sort_directories_first` option, - i.e. if you have set the - [`sort_dir_first`](https://yazi-rs.github.io/docs/configuration/yazi#manager.sort_dir_first) - to `true` in your `~/.config/yazi/yazi.toml` file on Linux and macOS, - or your `C:\Users\USERNAME\AppData\Roaming\yazi\config\yazi.toml` - on Windows, like so: - ```toml - # ~/.config/yazi/yazi.toml on Linux and macOS - # C:\Users\USERNAME\AppData\Roaming\yazi\config\yazi.toml on Windows + Video: - [manager] - sort_dir_first = true - ``` - - Then `sort_directories_first` should be set to `true` - as well in your `~/.config/yazi/init.lua` file on Linux and macOS, - or your `C:\Users\USERNAME\AppData\Roaming\yazi\config\yazi.toml` - file on Windows, where `USERNAME` is your Windows username, like so: - - ```lua - -- ~/.config/yazi/init.lua on Linux and macOS - -- C:\Users\USERNAME\AppData\Roaming\yazi\config\init.lua on Windows - - require("augment-command"):setup({ - sort_directories_first = true - }) - ``` - - If your `~/.config/yazi/yazi.toml` file on Linux and macOS, or your - `C:\Users\USERNAME\AppData\Roaming\yazi\config\yazi.toml` file on Windows, - where `USERNAME` is your Windows username, has - [`sort_dir_first`](https://yazi-rs.github.io/docs/configuration/yazi#manager.sort_dir_first) - set to `false`, like so: - - ```toml - # ~/.config/yazi/yazi.toml on Linux and macOS - # C:\Users\USERNAME\AppData\Roaming\yazi\config\yazi.toml on Windows - - [manager] - sort_dir_first = false - ``` - - Then `sort_directories_first` should be set to `false` - as well in your `~/.config/yazi/init.lua` file on Linux and macOS, - or your `C:\Users\USERNAME\AppData\Roaming\yazi\config\yazi.toml` - file on Windows, where `USERNAME` is your Windows username, like so: - - ```lua - -- ~/.config/yazi/init.lua on Linux and macOS - -- C:\Users\USERNAME\AppData\Roaming\yazi\config\init.lua on Windows - - require("augment-command"):setup({ - sort_directories_first = false - }) - ``` - - The default value of `sort_directories_first` follows Yazi's - [`sort_dir_first`](https://yazi-rs.github.io/docs/configuration/yazi#manager.sort_dir_first) - default value, which is `true`. + [wraparound-parent-arrow-video] - You can also replicate this using this series of commands below, but it doesn't work as well, @@ -517,14 +618,32 @@ then it will operate on the selected items. - The `editor` command opens the default editor set by the `$EDITOR` environment variable. - The command is also augmented as stated in - [this section above](#what-about-the-commands-are-augmented). + [this section above][augment-section]. + + Videos: + + - When `must_have_hovered_item` is `true`: + + [editor-must-have-hovered-item-video] + + - When `must_have_hovered_item` is `false`: + + [editor-hovered-item-optional-video] + + - When `prompt` is set to `true`: + + [editor-prompt-video] + + - When `prompt` is set to `false`: + + [editor-behaviour-video] ### Pager (`pager`) - The `pager` command opens the default pager set by the `$PAGER` environment variable. - The command is also augmented as stated in - [this section above](#what-about-the-commands-are-augmented). + [this section above][augment-section]. - The `pager` command will also skip opening directories, as the pager cannot open directories and will error out. Hence, the command will not do anything when the hovered item @@ -533,6 +652,24 @@ then it will operate on the selected items. try to open a directory and then immediately fail with an error, causing a flash and causing Yazi to send a notification. + Videos: + + - When `must_have_hovered_item` is `true`: + + [pager-must-have-hovered-item-video] + + - When `must_have_hovered_item` is `false`: + + [pager-hovered-item-optional-video] + + - When `prompt` is set to `true`: + + [pager-prompt-video] + + - When `prompt` is set to `false`: + + [pager-behaviour-video] + ## Usage Add the commands that you would like to use to your `keymap.toml` file, @@ -585,9 +722,8 @@ run = "plugin augment-command --args='remove --permanently'" desc = "Permanently delete the files" ``` -For the default descriptions of the commands, -you can refer to -[Yazi's `keymap.toml` file](https://github.com/sxyazi/yazi/blob/main/yazi-config/preset/keymap.toml). +For the default descriptions of the commands, you can refer to +[Yazi's default `keymap.toml` file][yazi-keymap-toml]. Essentially, all you need to do to use this plugin is to wrap a Yazi command in single quotes, @@ -599,10 +735,105 @@ in front of it, which results in ### Full configuration example For a full configuration example, -you can take a look at -[my `keymap.toml` file](https://github.com/hankertrix/Dotfiles/blob/master/.config/yazi/keymap.toml). +you can take a look at [my `keymap.toml` file][my-keymap-toml]. -## [Licence](LICENSE) +## [Licence] -This plugin is licenced under the [GNU AGPL v3 licence](LICENSE). -You can view the full licence in the [`LICENSE`](LICENSE) file. +This plugin is licenced under the [GNU AGPL v3 licence][Licence]. +You can view the full licence in the [`LICENSE`][Licence] file. + + + +[yazi-link]: https://github.com/sxyazi/yazi +[smart-paste-tip]: https://yazi-rs.github.io/docs/tips#smart-paste +[smart-tab-tip]: https://yazi-rs.github.io/docs/tips#smart-tab +[smart-switch-tip]: https://yazi-rs.github.io/docs/tips#smart-switch +[augment-section]: #what-about-the-commands-are-augmented +[7z-link]: https://www.7-zip.org/ +[file-command-link]: https://www.darwinsys.com/file/ +[my-keymap-toml]: https://github.com/hankertrix/Dotfiles/blob/main/.config/yazi/keymap.toml +[yazi-keymap-toml]: https://github.com/sxyazi/yazi/blob/main/yazi-config/preset/keymap-default.toml +[Licence]: LICENSE + + + + + +[open-behaviour-video]: https://github.com/user-attachments/assets/5636ffc0-fe24-4da3-9f0e-98de9cd74096 +[open-prompt-video]: https://github.com/user-attachments/assets/6bad5a20-e5d3-491d-9c7c-0f5962b77c1c +[open-auto-extract-archives-video]: https://github.com/user-attachments/assets/aeb3368b-4f7d-431e-9f7a-69a443af7153 +[open-recursively-extract-archives-video]: https://github.com/user-attachments/assets/44228646-3e82-41e4-a445-f93ab5649309 + + + +[smart-enter-video]: https://github.com/user-attachments/assets/d3507110-1385-4029-bf64-da3225446d72 +[enter-skip-single-subdirectory-video]: https://github.com/user-attachments/assets/2cdb9289-ef41-454f-817b-81beb8a8d030 + + + +[leave-skip-single-subdirectory-video]: https://github.com/user-attachments/assets/49acdddb-4d04-4624-8d29-057ada33fd01 + + + +[rename-hovered-item-optional-video]: https://github.com/user-attachments/assets/3f592893-cda6-4759-ae32-3059f0c285f0 +[rename-must-have-hovered-item-video]: https://github.com/user-attachments/assets/074c6713-60e8-4249-867f-926ac6ee2bd6 +[rename-behaviour-video]: https://github.com/user-attachments/assets/ba6c79e0-9062-43ae-a76b-2782f28a9a18 +[rename-prompt-video]: https://github.com/user-attachments/assets/4d42653e-9595-4322-b0c9-451b112dc596 + + + +[remove-hovered-item-optional-video]: https://github.com/user-attachments/assets/dd033b80-b8b0-46db-ab02-9fc1f1b7002d +[remove-must-have-hovered-item-video]: https://github.com/user-attachments/assets/5533b8b6-a966-4453-a86a-09d2ab2340e9 +[remove-behaviour-video]: https://github.com/user-attachments/assets/cc0617b1-fedf-45d3-b894-00524ba31434 +[remove-prompt-video]: https://github.com/user-attachments/assets/d23283fd-5068-429d-b06d-72b0c6a3bb36 + + + +[create-and-open-directories-video]: https://github.com/user-attachments/assets/52b244db-50a8-4adc-912f-239e01a10cc6 +[create-and-open-files-video]: https://github.com/user-attachments/assets/8f2306ea-b795-4da4-9867-9a5ed34f7e12 +[create-and-open-files-and-directories-video]: https://github.com/user-attachments/assets/ed14e451-a8ca-4622-949f-1469e1d17643 +[create-behaviour-video]: https://github.com/user-attachments/assets/0bee02b7-f0c3-4b24-8e8d-43c9d3ada3d6 +[create-default-behaviour-video]: https://github.com/user-attachments/assets/8c59f579-8f32-443c-8ae1-edd8d18e5ba0 + + + +[shell-hovered-item-optional-video]: https://github.com/user-attachments/assets/db4b0a30-0cbb-4747-9788-2fb2f8857449 +[shell-must-have-hovered-item-video]: https://github.com/user-attachments/assets/f7699493-99e7-4926-92c7-8811d3428cd4 +[shell-behaviour-video]: https://github.com/user-attachments/assets/5d898205-e5ca-487e-b731-4624ca0123ee +[shell-prompt-video]: https://github.com/user-attachments/assets/d1790105-1e40-4639-bf65-d395a488ae94 +[shell-exit-if-directory-video]: https://github.com/user-attachments/assets/a992300a-2eed-40a1-97e4-d4efef57f7f0 + + + +[smart-paste-video]: https://github.com/user-attachments/assets/9796fbf1-6807-4f74-a0eb-a36c6306c761 + + + +[smart-tab-create-video]: https://github.com/user-attachments/assets/2738598c-ccdf-49e4-9d57-90a6378f6155 + + + +[smart-tab-switch-video]: https://github.com/user-attachments/assets/78240347-7d5e-4b45-85df-8446cfb61edf + + + +[wraparound-arrow-video]: https://github.com/user-attachments/assets/28d96bb3-276d-41c8-aa17-eebd7fde9390 + + + +[parent-arrow-video]: https://github.com/user-attachments/assets/d58a841d-0c05-4555-bf1b-f4d539b9d9c9 +[wraparound-parent-arrow-video]: https://github.com/user-attachments/assets/72dcd01a-63f0-4193-9a23-cefa61142d73 + + + +[editor-hovered-item-optional-video]: https://github.com/user-attachments/assets/97e7f313-afcd-4619-bdec-539ffa0ce9a4 +[editor-must-have-hovered-item-video]: https://github.com/user-attachments/assets/4fb901d2-9a86-44ec-9896-453f6df16ea1 +[editor-behaviour-video]: https://github.com/user-attachments/assets/af057282-8f75-4662-8b4b-29e594cf4163 +[editor-prompt-video]: https://github.com/user-attachments/assets/6c12380c-36fb-4a57-bd82-8452fdcad7e6 + + + +[pager-hovered-item-optional-video]: https://github.com/user-attachments/assets/e63af138-b553-4598-b6da-c7e3de57f328 +[pager-must-have-hovered-item-video]: https://github.com/user-attachments/assets/aa9e27e0-39ed-466f-ae84-812c08d93293 +[pager-behaviour-video]: https://github.com/user-attachments/assets/d18aec12-8be3-483a-a24a-2929ad8fc6c2 +[pager-prompt-video]: https://github.com/user-attachments/assets/ac3cd3b3-2624-4ea2-b22d-5ab6a49a98c6 diff --git a/config/yazi/plugins/augment-command.yazi/init.lua b/config/yazi/plugins/augment-command.yazi/init.lua index 6cc27802..c32a7051 100644 --- a/config/yazi/plugins/augment-command.yazi/init.lua +++ b/config/yazi/plugins/augment-command.yazi/init.lua @@ -6,18 +6,19 @@ -- The type for the arguments ---@alias Arguments table --- The type for the job object ----@alias Job { args: Arguments } - --- The type for the input event +-- The type for the function to handle a command -- --- The event for the input function --- can be one of 3 values: --- 0: Unknown error --- 1: The user has confirmed the input --- 2: The user has cancelled the input --- 3: The user has changed the input (only if realtime is true) ----@alias InputEvent integer +-- Description of the function parameters: +-- args: The arguments to pass to the command +-- config: The configuration object +-- command_table: The command table containing all the command functions +---@alias CommandFunction fun( +--- args: Arguments, +--- config: Configuration, +--- command_table: CommandTable): nil + +-- The type of the command table +---@alias CommandTable table -- The type for the extractor command ---@alias ExtractorFunction fun( @@ -40,13 +41,11 @@ ---@field use_default_create_behaviour boolean Use Yazi's create behaviour? ---@field enter_archives boolean Whether to enter archives ---@field extract_retries number How many times to retry extracting ----@field extract_archives_recursively boolean Re-extract inner archives or not +---@field recursively_extract_archives boolean Extract inner archives or not ---@field must_have_hovered_item boolean Whether to stop when no item is hovered ---@field skip_single_subdirectory_on_enter boolean Skip single subdir on enter ---@field skip_single_subdirectory_on_leave boolean Skip single subdir on leave ----@field ignore_hidden_items boolean Whether to ignore hidden items ---@field wraparound_file_navigation boolean Have wraparound navigation or not ----@field sort_directories_first boolean Informs the plugin if dirs are first -- The additional data passed to the function to initialise the configuration ---@class (exact) AdditionalData @@ -59,28 +58,6 @@ ---@class (exact) State ---@field config Configuration --- The type for the Command output ----@class (exact) CommandOutput ----@field stdout string ----@field stderr string ----@field status { success: boolean, code: number } - ---- The type for the Url object ----@class (exact) Url ----@field frag string ----@field is_regular boolean ----@field is_search boolean ----@field is_archive boolean ----@field is_absolute boolean ----@field has_root boolean ----@field name fun(self): string|nil ----@field stem fun(self): string|nil ----@field join fun(self, url: Url|string): Url ----@field parent fun(self): Url|nil ----@field starts_with fun(self, url: Url|string): boolean ----@field ends_with fun(self, url: Url|string): boolean ----@field strip_prefix fun(self, url: Url|string): boolean - -- The type for the extraction results ---@class (exact) ExtractionResult ---@field archive_path string @@ -140,32 +117,42 @@ local DEFAULT_CONFIG = { use_default_create_behaviour = false, enter_archives = true, extract_retries = 3, - extract_archives_recursively = true, + recursively_extract_archives = true, must_have_hovered_item = true, skip_single_subdirectory_on_enter = true, skip_single_subdirectory_on_leave = true, - ignore_hidden_items = false, wraparound_file_navigation = false, - sort_directories_first = true, +} + +-- The default input options for this plugin +local DEFAULT_INPUT_OPTIONS = { + position = { "top-center", x = 0, y = 2, w = 50, h = 3 }, +} + +-- The default confirm options for this plugin +local DEFAULT_CONFIRM_OPTIONS = { + pos = { "center", x = 0, y = 0, w = 50, h = 15 }, } -- The default notification options for this plugin ----@class (exact) NotificationOptions ----@field title string ----@field timeout number ----@field content string ----@field level "info" | "warn" | "error" local DEFAULT_NOTIFICATION_OPTIONS = { title = "Augment Command Plugin", timeout = 5, } --- The default input options for this plugin ----@class (exact) InputOptions ----@field position { x: number, y: number, w: number } ----@field title string -local DEFAULT_INPUT_OPTIONS = { - position = { "top-center", y = 2, w = 50 }, +-- The tab preference keys. +-- The values are just dummy values +-- so that I don't have to maintain two +-- different types for the same thing. +---@type tab.Preference +local TAB_PREFERENCE_KEYS = { + sort_by = "alphabetical", + sort_sensitive = false, + sort_reverse = false, + sort_dir_first = true, + sort_translit = false, + linemode = "none", + show_hidden = false, } -- The table of input options for the prompt @@ -176,18 +163,17 @@ local INPUT_OPTIONS_TABLE = { [ItemGroup.None] = "(h/s)", } --- The list of archive mime types ----@type string[] +-- The table of archive mime types +---@type table local ARCHIVE_MIME_TYPES = { - "application/zip", - "application/gzip", - "application/tar", - "application/bzip", - "application/bzip2", - "application/7z-compressed", - "application/rar-compressed", - "application/rar", - "application/xz", + ["application/zip"] = true, + ["application/gzip"] = true, + ["application/tar"] = true, + ["application/bzip"] = true, + ["application/bzip2"] = true, + ["application/7z-compressed"] = true, + ["application/rar"] = true, + ["application/xz"] = true, -- Bug in file(1) that classifies -- some zip archives as a data stream, @@ -195,20 +181,32 @@ local ARCHIVE_MIME_TYPES = { -- -- Link to bug report: -- https://bugs.astron.com/view.php?id=571 - "application/octet-stream", + ["application/octet-stream"] = true, } -- The list of archive file extensions ----@type string[] +---@type table local ARCHIVE_FILE_EXTENSIONS = { - "zip", - "tar", - "boz", - "bz", - "bz2", - "7z", - "rar", - "xz", + ["7z"] = true, + boz = true, + bz = true, + bz2 = true, + bzip2 = true, + cb7 = true, + cbr = true, + cbt = true, + cbz = true, + gz = true, + gzip = true, + rar = true, + s7z = true, + tar = true, + tbz = true, + tbz2 = true, + tgz = true, + txz = true, + xz = true, + zip = true, } -- The list of mime type prefixes to remove @@ -298,26 +296,6 @@ local function merge_tables(...) return new_table end --- Function to check if a list contains a given value ----@param list any[] The list to check ----@param value any The value to check for ----@return boolean value_is_in_list Whether the value is in the list -local function list_contains(list, value) - -- - - -- Iterate over all of the items in the list - for _, item in ipairs(list) do - -- - - -- If the item is equal to the given value, - -- then return true - if item == value then return true end - end - - -- Otherwise, return false if the item isn't in the list - return false -end - -- Function to split a string into a list ---@param given_string string The string to split ---@param separator string The character to split the string by @@ -354,9 +332,16 @@ local function string_trim(string) return string:match("^%s*(.-)%s*$") end +-- Function to get a value from a table +-- and return the default value if the key doesn't exist +---@param table table The table to get the value from +---@param key string|number The key to get the value from +---@param default any The default value to return if the key doesn't exist +local function table_get(table, key, default) return table[key] or default end + -- Function to pop a key from a table ---@param table table The table to pop from ----@param key string The key to pop +---@param key string|number The key to pop ---@param default any The default value to return if the key doesn't exist ---@return any value The value of the key or the default value local function table_pop(table, key, default) @@ -373,6 +358,20 @@ local function table_pop(table, key, default) return value or default end +-- Function to escape a percentage sign % +-- in the string that is being replaced +---@param replacement_string string The string to escape +---@return string replacement_result The escaped string +local function escape_replacement_string(replacement_string) + -- + + -- Get the result of the replacement + local replacement_result = replacement_string:gsub("%%", "%%%%") + + -- Return the result of the replacement + return replacement_result +end + -- Function to parse the number arguments to the number type ---@param args Arguments The arguments to parse ---@return Arguments parsed_args The parsed arguments @@ -431,12 +430,30 @@ local function get_user_input(prompt) end -- Function to get the user's confirmation --- TODO: Switch to `ya.confirm()` when it's available +-- TODO: Remove the `ya.input` version once `ya.confirm` is stable ---@param prompt string The prompt to show to the user +---@param title string|ui.Line The title of the confirmation prompt +---@param content string|ui.Text The content of the confirmation prompt ---@return boolean confirmation Whether the user has confirmed or not -local function get_user_confirmation(prompt) +local function get_user_confirmation(prompt, title, content) -- + -- If the ya.confirm API exists, use it + if ya.confirm then + -- + + -- Get the user's confirmation + local confirmation = ya.confirm(merge_tables(DEFAULT_CONFIRM_OPTIONS, { + title = title, + content = content, + })) + + -- Return the result of the confirmation + return confirmation + end + + -- TODO: Remove everything after this when `ya.confirm` is stable + -- Get the user's input local user_input, event = get_user_input(prompt) @@ -651,7 +668,8 @@ local function is_archive_mime_type(mime_type) local standardised_mime_type = standardise_mime_type(mime_type) -- Get if the mime type is an archive - local is_archive = list_contains(ARCHIVE_MIME_TYPES, standardised_mime_type) + local is_archive = + table_get(ARCHIVE_MIME_TYPES, standardised_mime_type, false) -- Return if the mime type is an archive return is_archive @@ -674,7 +692,7 @@ local function is_archive_file_extension(file_extension) file_extension = string_trim(file_extension) -- Get if the file extension is an archive - local is_archive = list_contains(ARCHIVE_FILE_EXTENSIONS, file_extension) + local is_archive = table_get(ARCHIVE_FILE_EXTENSIONS, file_extension, false) -- Return if the file extension is an archive file extension return is_archive @@ -691,10 +709,9 @@ local get_config = ya.sync(function(state) end) -- Function to get the current working directory ----@param _ any ----@return string current_working_directory The current working directory -local get_current_directory = ya.sync( - function(_) return tostring(cx.active.current.cwd) end +---@type fun(_): Url Returns the current working directory as a url +local get_current_directory_url = ya.sync( + function(_) return cx.active.current.cwd end ) -- Function to get the path of the hovered item @@ -782,13 +799,41 @@ local get_paths_of_selected_items = ya.sync(function(_, quote) return paths_of_selected_items end) +-- Function to get the tab preferences +---@param _ State +---@return tab.Preference +local get_tab_preferences = ya.sync(function(_) + -- + + -- Create the table to store the tab preferences + local tab_preferences = {} + + -- Iterate over the tab preference keys + for key, _ in pairs(TAB_PREFERENCE_KEYS) do + -- + + -- Set the key in the table to the value + -- from the state + tab_preferences[key] = cx.active.pref[key] + end + + -- Return the tab preferences + return tab_preferences +end) + -- Function to get if Yazi is loading ----@param _ any ----@return boolean is_loading Whether Yazi is loading +---@type fun(_): boolean Returns whether Yazi is loading local yazi_is_loading = ya.sync( function(_) return cx.active.current.stage.is_loading end ) +-- Function to wait until Yazi is loaded +---@return nil +local function wait_until_yazi_is_loaded() + while yazi_is_loading() do + end +end + -- Function to choose which group of items to operate on. -- It returns ItemGroup.Hovered for the hovered item, -- ItemGroup.Selected for the selected items, @@ -913,13 +958,13 @@ local function get_item_group() end -- Function to get all the items in the given directory ----@param directory string The path to the directory ----@param ignore_hidden_items boolean Whether to ignore hidden items +---@param directory_url Url The url to the directory +---@param get_hidden_items boolean Whether to get hidden items ---@param directories_only boolean|nil Whether to only get directories ----@return string[] directory_items The list of paths to the directory items +---@return Url[] directory_items The list of urls to the directory items local function get_directory_items( - directory, - ignore_hidden_items, + directory_url, + get_hidden_items, directories_only ) -- @@ -928,7 +973,7 @@ local function get_directory_items( local directory_items = {} -- Read the contents of the directory - local directory_contents, _ = fs.read_dir(Url(directory), {}) + local directory_contents, _ = fs.read_dir(directory_url, {}) -- If there are no directory contents, -- then return the empty list of directory items @@ -938,18 +983,18 @@ local function get_directory_items( for _, item in ipairs(directory_contents) do -- - -- If the ignore hidden items flag is passed + -- If the get hidden items flag is set to false -- and the item is a hidden item, -- then continue the loop - if ignore_hidden_items and item.cha.is_hidden then goto continue end + if not get_hidden_items and item.cha.is_hidden then goto continue end -- If the directories only flag is passed -- and the item is not a directory, -- then continue the loop if directories_only and not item.cha.is_dir then goto continue end - -- Otherwise, add the item path to the list of directory items - table.insert(directory_items, tostring(item.url)) + -- Otherwise, add the item url to the list of directory items + table.insert(directory_items, item.url) -- The continue label to continue the loop ::continue:: @@ -960,25 +1005,16 @@ local function get_directory_items( end -- Function to skip child directories with only one directory ----@param args Arguments The arguments passed to the plugin ----@param config Configuration The configuration object ----@param initial_directory string The path of the initial directory +---@param initial_directory_url Url The url of the initial directory ---@return nil -local function skip_single_child_directories(args, config, initial_directory) +local function skip_single_child_directories(initial_directory_url) -- - -- If the user doesn't want to skip single subdirectories on enter, - -- or one of the arguments passed is no skip, - -- then exit the function - if - not config.skip_single_subdirectory_on_enter - or table_pop(args, "no_skip", false) - then - return - end - -- Initialise the directory variable to the initial directory given - local directory = initial_directory + local directory = initial_directory_url + + -- Get the tab preferences + local tab_preferences = get_tab_preferences() -- Start an infinite loop while true do @@ -986,25 +1022,30 @@ local function skip_single_child_directories(args, config, initial_directory) -- Get all the items in the current directory local directory_items = - get_directory_items(directory, config.ignore_hidden_items) + get_directory_items(directory, tab_preferences.show_hidden) -- If the number of directory items is not 1, -- then break out of the loop. if #directory_items ~= 1 then break end -- Otherwise, get the directory item - local directory_item = table.unpack(directory_items) + ---@type Url + local directory_item_url = table.unpack(directory_items) -- Get the cha object of the directory item -- and don't follow symbolic links - local directory_item_cha = fs.cha(Url(directory_item), false) + local directory_item_cha = fs.cha(directory_item_url, false) + + -- If the cha object of the directory item is nil + -- then break the loop + if not directory_item_cha then break end -- If the directory item is not a directory, -- break the loop if not directory_item_cha.is_dir then break end -- Otherwise, set the directory to the inner directory - directory = directory_item + directory = directory_item_url end -- Emit the change directory command to change to the directory variable @@ -1078,7 +1119,7 @@ local function retry_extractor( local output, err = extractor_function(password, config) -- If there is no output - -- then return false, the error code as a string, + -- then return false, the error as a string, -- nil for the output, and nil for the password if not output then return false, tostring(err), nil, nil end @@ -1182,6 +1223,9 @@ local function list_archive_items_command( -- List the items in the archive "l", + -- Use UTF-8 encoding for console input and output + "-sccUTF-8", + -- Pass the password to the command "-p" .. password, } @@ -1378,6 +1422,9 @@ local function extract_command( -- Assume yes to all prompts "-y", + -- Use UTF-8 encoding for console input and output + "-sccUTF-8", + -- Configure the extraction behaviour extract_behaviour, @@ -1539,6 +1586,22 @@ local function move_extracted_items_to_archive_parent_directory( ) end + -- Get the file name of the archive without the extension + local archive_file_name = archive_url:stem() + + -- If the archive file name is nil, + -- then return the move successful variable, + -- the error message, and the extracted item path + if not archive_file_name then + return clean_up_temporary_directory( + temporary_directory_url, + "dir_all", + move_successful, + "Archive's file name is empty", + extracted_items_path + ) + end + -- Get the first extracted item local first_extracted_item = table.unpack(extracted_items) @@ -1553,7 +1616,7 @@ local function move_extracted_items_to_archive_parent_directory( -- Initialise the target directory url to move the extracted items to, -- which is the parent directory of the archive -- joined with the file name of the archive without the extension - local target_url = parent_directory_url:join(archive_url:stem()) + local target_url = parent_directory_url:join(archive_file_name) -- If there is only one item in the archive if #extracted_items == 1 then @@ -1562,19 +1625,35 @@ local function move_extracted_items_to_archive_parent_directory( -- Set the only one item in archive variable to true only_one_item_in_archive = true + -- Get the name of the first extracted item + local first_extracted_item_name = first_extracted_item_url:name() + + -- If the first extracted item name is nil, + -- then clean up the temporary directory + -- and exit the function + if not first_extracted_item_name then + return clean_up_temporary_directory( + temporary_directory_url, + "dir_all", + move_successful, + "Failed to get a name for the extracted item.", + extracted_items_path + ) + end + -- Set the target url to the parent directory of the archive -- joined with the file name of the extracted item - target_url = parent_directory_url:join(first_extracted_item_url:name()) + target_url = parent_directory_url:join(first_extracted_item_name) end -- Get a unique name for the target url - target_url = fs.unique_name(target_url) + local unique_target_url = fs.unique_name(target_url) - -- If the target url is nil somehow, + -- If the unique target url is nil somehow, -- clean up the temporary directory and -- return the move successful variable, -- the error message and the extracted item path - if not target_url then + if not unique_target_url then return clean_up_temporary_directory( temporary_directory_url, "dir_all", @@ -1584,6 +1663,9 @@ local function move_extracted_items_to_archive_parent_directory( ) end + -- Otherwise, set the target url to the unique target url + target_url = unique_target_url + -- Set the extracted items path to the target path extracted_items_path = tostring(target_url) @@ -1794,7 +1876,7 @@ local function recursively_extract_archives(archive_path, config) if not extraction_results.successful or not extracted_items_path - or not config.extract_archives_recursively + or not config.recursively_extract_archives then return list_of_extraction_results, extracted_items_path end @@ -1870,10 +1952,7 @@ local function recursively_extract_archives(archive_path, config) end -- Function to handle the open command ----@param args Arguments The arguments passed to the plugin ----@param config Configuration The configuration object ----@param command_table CommandTable The command table ----@return nil +---@type CommandFunction local function handle_open(args, config, command_table) -- @@ -1973,16 +2052,23 @@ local function handle_open(args, config, command_table) -- Enter the archive directory ya.manager_emit("cd", { extracted_items_path }) + -- If the user doesn't want to skip single subdirectories on enter, + -- or one of the arguments passed is no skip, + -- then exit the function + if + not config.skip_single_subdirectory_on_enter + or table_pop(args, "no_skip", false) + then + return + end + -- Calls the function to skip child directories -- with only a single directory inside - skip_single_child_directories(args, config, extracted_items_path) + skip_single_child_directories(Url(extracted_items_path)) end -- Function to handle the enter command ----@param args Arguments The arguments passed to the plugin ----@param config Configuration The configuration object ----@param command_table CommandTable The command table ----@return nil +---@type CommandFunction local function handle_enter(args, config, command_table) -- @@ -2007,15 +2093,23 @@ local function handle_enter(args, config, command_table) -- Otherwise, always emit the enter command, ya.manager_emit("enter", args) - -- Calls the function to skip child directories + -- If the user doesn't want to skip single subdirectories on enter, + -- or one of the arguments passed is no skip, + -- then exit the function + if + not config.skip_single_subdirectory_on_enter + or table_pop(args, "no_skip", false) + then + return + end + + -- Otherwise, call the function to skip child directories -- with only a single directory inside - skip_single_child_directories(args, config, get_current_directory()) + skip_single_child_directories(get_current_directory_url()) end -- Function to handle the leave command ----@param args Arguments The arguments passed to the plugin ----@param config Configuration The configuration object ----@return nil +---@type CommandFunction local function handle_leave(args, config) -- @@ -2033,7 +2127,11 @@ local function handle_leave(args, config) end -- Otherwise, initialise the directory to the current directory - local directory = get_current_directory() + ---@type Url + local directory = get_current_directory_url() + + -- Get the tab preferences + local tab_preferences = get_tab_preferences() -- Start an infinite loop while true do @@ -2041,22 +2139,22 @@ local function handle_leave(args, config) -- Get all the items in the current directory local directory_items = - get_directory_items(directory, config.ignore_hidden_items) + get_directory_items(directory, tab_preferences.show_hidden) -- If the number of directory items is not 1, -- then break out of the loop. if #directory_items ~= 1 then break end -- Get the parent directory of the current directory - ---@type Url - local parent_directory = Url(directory):parent() + ---@type Url|nil + local parent_directory = directory:parent() -- If the parent directory is nil, -- break the loop if not parent_directory then break end -- Otherwise, set the new directory to the parent directory - directory = tostring(parent_directory) + directory = parent_directory end -- Emit the change directory command to change to the directory variable @@ -2117,33 +2215,27 @@ local function enter_or_open_created_item(item_url, is_directory, args, config) end -- Otherwise, call the function change to the created directory - ya.manager_emit("cd", { tostring(item_url) }) + return ya.manager_emit("cd", { tostring(item_url) }) + end -- Otherwise, the item is a file - else - -- - -- If the user does not want to open the file - -- after creating it, exit the function - if - not ( - config.open_file_after_creation - or table_pop(args, "open", false) - ) - then - return - end - - -- Otherwise, call the function to reveal the created file - ya.manager_emit("reveal", { tostring(item_url) }) - - -- Wait for Yazi to finish loading - while yazi_is_loading() do - end - - -- Call the function to open the file - ya.manager_emit("open", { hovered = true }) + -- If the user does not want to open the file + -- after creating it, exit the function + if + not (config.open_file_after_creation or table_pop(args, "open", false)) + then + return end + + -- Otherwise, call the function to reveal the created file + ya.manager_emit("reveal", { tostring(item_url) }) + + -- Wait for Yazi to finish loading + wait_until_yazi_is_loaded() + + -- Call the function to open the file + return ya.manager_emit("open", { hovered = true }) end -- Function to execute the create command @@ -2208,36 +2300,32 @@ local function execute_create(item_url, is_directory, args, config) end -- Function to handle the create command ----@param args Arguments The arguments passed to the plugin ----@param config Configuration The configuration object ----@return nil +---@type CommandFunction local function handle_create(args, config) -- - -- Otherwise, get the user's input for the item to create - local user_input, event = get_user_input("Create:") + -- Get the directory flag + local dir_flag = table_pop(args, "dir", false) - -- If the user did not confirm the input, - -- or the user input is nil, + -- Get the user's input for the item to create + local user_input, event = + get_user_input(dir_flag and "Create (dir):" or "Create:") + + -- If the user input is nil, + -- or if the user did not confirm the input, -- exit the function if not user_input or event ~= 1 then return end -- Get the current working directory as a url - local current_working_directory = fs.cwd() - - -- If there's not current working directory, - -- then show an error and exit the function - if not current_working_directory then - return show_error("Current working directory doesn't exist") - end + ---@type Url + local current_working_directory = get_current_directory_url() -- Get whether the url ends with a path delimiter local ends_with_path_delimiter = user_input:find("[/\\]$") -- Get the whether the given item is a directory or not based -- on the default conditions for a directory - local is_directory = ends_with_path_delimiter - or table_pop(args, "dir", false) + local is_directory = ends_with_path_delimiter or dir_flag -- Get the url from the user's input ---@type Url @@ -2270,8 +2358,19 @@ local function handle_create(args, config) -- Get the user's confirmation for -- whether they want to overwrite the item - local user_confirmation = - get_user_confirmation("The item already exists, overwrite? (y/N)") + local user_confirmation = get_user_confirmation( + + -- TODO: Remove the line below + "The item already exists, overwrite? (y/N)", + "Overwrite file?", + ui.Text({ + ui.Line("Will overwrite the following file:") + :align(ui.Line.CENTER), + ui.Line(string.rep("-", DEFAULT_CONFIRM_OPTIONS.pos.w - 2)) + :align(ui.Line.LEFT), + ui.Line(tostring(full_url)):align(ui.Line.LEFT), + }):wrap(ui.Text.WRAP_TRIM) + ) -- If the user did not confirm the overwrite, -- then exit the function @@ -2346,7 +2445,7 @@ local function fix_shell_command_containing_less(command) -- Add the less environment variable flags to the less command fixed_command = fixed_command:gsub( "%f[%a]less%f[%A]", - less_command_with_modified_env_variables + escape_replacement_string(less_command_with_modified_env_variables) ) -- Unset the LESS environment variable before calling the command @@ -2424,17 +2523,30 @@ local function fix_shell_command(command) end -- Function to handle a shell command ----@param args Arguments The arguments passed to the plugin ----@return nil -local function handle_shell(args) +---@type CommandFunction +local function handle_shell(args, _, _) -- -- Get the first item of the arguments given -- and set it to the command variable local command = table.remove(args, 1) - -- If the command isn't a string, exit the function - if type(command) ~= "string" then return end + -- Get the type of the command variable + local command_type = type(command) + + -- If the command isn't a string, + -- show an error message and exit the function + if command_type ~= "string" then + return show_error( + string.format( + "Shell command given is not a string, " + .. "instead it is a '%s', " + .. "with value '%s'", + command_type, + tostring(command) + ) + ) + end -- Fix the given command command = fix_shell_command(command) @@ -2467,7 +2579,7 @@ local function handle_shell(args) local item_cha = fs.cha(Url(item), false) -- If the item isn't a directory - if not item_cha.is_dir then + if not (item_cha or {}).is_dir then -- -- Increment the number of files @@ -2483,7 +2595,9 @@ local function handle_shell(args) -- with the quoted paths of the selected items command = command:gsub( shell_variable_pattern, - table.concat(get_paths_of_selected_items(true), " ") + escape_replacement_string( + table.concat(get_paths_of_selected_items(true), " ") + ) ) -- If the item group is the hovered item @@ -2497,8 +2611,10 @@ local function handle_shell(args) -- Replace the shell variable in the command -- with the quoted path of the hovered item - command = - command:gsub(shell_variable_pattern, get_path_of_hovered_item(true)) + command = command:gsub( + shell_variable_pattern, + escape_replacement_string(get_path_of_hovered_item(true)) + ) -- Otherwise, exit the function else @@ -2513,9 +2629,7 @@ local function handle_shell(args) end -- Function to handle the paste command ----@param args Arguments The arguments passed to the plugin ----@param config Configuration The configuration object ----@return nil +---@type CommandFunction local function handle_paste(args, config) -- @@ -2551,29 +2665,32 @@ local execute_tab_create = ya.sync(function(state, args) -- Get the hovered item local hovered_item = cx.active.current.hovered - -- Get if the hovered item is a directory - local hovered_item_is_directory = hovered_item and hovered_item.cha.is_dir - - -- If the hovered item is a directory, - -- and the user wants to create a tab - -- in the hovered directory + -- If the hovered item is nil, + -- or if the hovered item is not a directory, + -- or if the user doesn't want to smartly + -- create a tab in the hovered directory if - hovered_item_is_directory - and (state.config.smart_tab_create or table_pop(args, "smart", false)) + not hovered_item + or not hovered_item.cha.is_dir + or not ( + state.config.smart_tab_create + or table_pop(args, "smart", false) + ) then -- - -- Set the arguments to the url of the hovered item - args = { hovered_item.url } + -- Emit the command to create a new tab with the arguments + -- and exit the function + return ya.manager_emit("tab_create", args) end - -- Emit the command to create a new tab with the arguments - ya.manager_emit("tab_create", args) + -- Otherwise, emit the command to create a new tab + -- with the hovered item's url + ya.manager_emit("tab_create", { hovered_item.url }) end) -- Function to handle the tab create command ----@param args Arguments The arguments passed to the plugin ----@return nil +---@type CommandFunction local function handle_tab_create(args) -- @@ -2622,8 +2739,7 @@ local execute_tab_switch = ya.sync(function(state, args) end) -- Function to handle the tab switch command ----@param args Arguments The arguments passed to the plugin ----@return nil +---@type CommandFunction local function handle_tab_switch(args) -- @@ -2665,9 +2781,7 @@ local wraparound_arrow = ya.sync(function(_, args) end) -- Function to handle the arrow command ----@param args Arguments The arguments passed to the plugin ----@param config Configuration The configuration object ----@return nil +---@type CommandFunction local function handle_arrow(args, config) -- @@ -2736,8 +2850,23 @@ local execute_parent_arrow = ya.sync(function(state, args) -- Get the offset from the arguments given local offset = table.remove(args, 1) - -- If the offset is not a number, then exit the function - if type(offset) ~= "number" then return end + -- Get the type of the offset + local offset_type = type(offset) + + -- If the offset is not a number, + -- then show an error that the offset is not a number + -- and exit the function + if offset_type ~= "number" then + return show_error( + string.format( + "The given offset is not of the type 'number', " + .. "instead it is a '%s', " + .. "with value '%s'", + offset_type, + tostring(offset) + ) + ) + end -- Get the number of items in the parent directory local number_of_items = #parent_directory.files @@ -2746,12 +2875,15 @@ local execute_parent_arrow = ya.sync(function(state, args) -- to the current cursor index local new_cursor_index = parent_directory.cursor + -- Get whether the user wants to sort directories first + local sort_directories_first = cx.active.pref.sort_dir_first + -- If wraparound file navigation is wanted if state.config.wraparound_file_navigation then -- -- If the user sorts their directories first - if state.config.sort_directories_first then + if sort_directories_first then -- -- Get the directories in the parent directory @@ -2830,8 +2962,7 @@ local execute_parent_arrow = ya.sync(function(state, args) end) -- Function to handle the parent arrow command ----@param args Arguments The arguments passed to the plugin ----@return nil +---@type CommandFunction local function handle_parent_arrow(args) -- @@ -2841,17 +2972,10 @@ local function handle_parent_arrow(args) end -- Function to handle the editor command ----@param args Arguments The arguments passed to the plugin ----@return nil -local function handle_editor(args) +---@type CommandFunction +local function handle_editor(args, config, command_table) -- - -- Call the function to get the item group - local item_group = get_item_group() - - -- If no item group is returned, exit the function - if not item_group then return end - -- Get the editor environment variable local editor = os.getenv("EDITOR") @@ -2860,17 +2984,20 @@ local function handle_editor(args) -- Call the handle shell function -- with the editor command - handle_shell(merge_tables({ - editor .. " $@", - block = true, - exit_if_dir = true, - }, args)) + handle_shell( + merge_tables({ + editor .. " $@", + block = true, + exit_if_dir = true, + }, args), + config, + command_table + ) end -- Function to handle the pager command ----@param args Arguments The arguments passed to the plugin ----@return nil -local function handle_pager(args) +---@type CommandFunction +local function handle_pager(args, config, command_table) -- -- Get the pager environment variable @@ -2879,21 +3006,17 @@ local function handle_pager(args) -- If the pager is not set, exit the function if not pager then return end - -- If the pager is the less command - if pager:find("^less") ~= nil then - -- - - -- Remove the F flag from the command - pager = pager:gsub("%-F", ""):gsub("(%a*)F(%a*)", "%1%2") - end - -- Call the handle shell function -- with the pager command - handle_shell(merge_tables({ - pager .. " $@", - block = true, - exit_if_dir = true, - }, args)) + handle_shell( + merge_tables({ + pager .. " $@", + block = true, + exit_if_dir = true, + }, args), + config, + command_table + ) end -- Function to run the commands given @@ -2905,7 +3028,7 @@ local function run_command_func(command, args, config) -- -- The command table - ---@enum CommandTable + ---@type CommandTable local command_table = { [Commands.Open] = handle_open, [Commands.Enter] = handle_enter, @@ -2924,6 +3047,7 @@ local function run_command_func(command, args, config) } -- Get the function for the command + ---@type CommandFunction|nil local command_func = command_table[command] -- If the function isn't found, notify the user and exit the function @@ -2948,7 +3072,7 @@ end -- Function to be called to use the plugin ---@param _ any ----@param job Job The job object given by Yazi +---@param job { args: Arguments } The job object given by Yazi ---@return nil local function entry(_, job) -- diff --git a/config/yazi/plugins/chmod.yazi/init.lua b/config/yazi/plugins/chmod.yazi/init.lua index bfb09706..183c31e2 100644 --- a/config/yazi/plugins/chmod.yazi/init.lua +++ b/config/yazi/plugins/chmod.yazi/init.lua @@ -30,7 +30,7 @@ return { if not status or not status.success then ya.notify { title = "Chmod", - content = string.format("Chmod with selected files failed, exit code %s", status and status.code or err), + content = string.format("Chmod on selected files failed, error: %s", status and status.code or err), level = "error", timeout = 5, } diff --git a/config/yazi/plugins/full-border.yazi/init.lua b/config/yazi/plugins/full-border.yazi/init.lua index 958ae67a..233ebf0f 100644 --- a/config/yazi/plugins/full-border.yazi/init.lua +++ b/config/yazi/plugins/full-border.yazi/init.lua @@ -1,12 +1,3 @@ --- TODO: remove this once v0.4 is released -local v4 = function(typ, area, ...) - if typ == "bar" then - return ui.Table and ui.Bar(...):area(area) or ui.Bar(area, ...) - else - return ui.Table and ui.Border(...):area(area) or ui.Border(area, ...) - end -end - local function setup(_, opts) local type = opts and opts.type or ui.Border.ROUNDED local old_build = Tab.build @@ -14,14 +5,14 @@ local function setup(_, opts) Tab.build = function(self, ...) local bar = function(c, x, y) if x <= 0 or x == self._area.w - 1 then - return v4("bar", ui.Rect.default, ui.Bar.TOP) + return ui.Bar(ui.Bar.TOP) end - return v4( - "bar", - ui.Rect { x = x, y = math.max(0, y), w = ya.clamp(0, self._area.w - x, 1), h = math.min(1, self._area.h) }, - ui.Bar.TOP - ):symbol(c) + return ui.Bar(ui.Bar.TOP) + :area( + ui.Rect { x = x, y = math.max(0, y), w = ya.clamp(0, self._area.w - x, 1), h = math.min(1, self._area.h) } + ) + :symbol(c) end local c = self._chunks @@ -33,9 +24,9 @@ local function setup(_, opts) local style = THEME.manager.border_style self._base = ya.list_merge(self._base or {}, { - v4("border", self._area, ui.Border.ALL):type(type):style(style), - v4("bar", self._chunks[1], ui.Bar.RIGHT):style(style), - v4("bar", self._chunks[3], ui.Bar.LEFT):style(style), + ui.Border(ui.Border.ALL):area(self._area):type(type):style(style), + ui.Bar(ui.Bar.RIGHT):area(self._chunks[1]):style(style), + ui.Bar(ui.Bar.LEFT):area(self._chunks[3]):style(style), bar("┬", c[1].right - 1, c[1].y), bar("┴", c[1].right - 1, c[1].bottom - 1), diff --git a/config/yazi/plugins/git.yazi/init.lua b/config/yazi/plugins/git.yazi/init.lua index a64b7496..64c3e8eb 100644 --- a/config/yazi/plugins/git.yazi/init.lua +++ b/config/yazi/plugins/git.yazi/init.lua @@ -154,10 +154,7 @@ local function setup(st, opts) end, opts.order) end -local function fetch(self, job) - -- TODO: remove this once Yazi 0.4 is released - job = job or self - +local function fetch(_, job) local cwd = job.files[1].url:parent() local repo = root(cwd) if not repo then @@ -178,7 +175,7 @@ local function fetch(self, job) :stdout(Command.PIPED) :output() if not output then - ya.err("Cannot spawn git command, error code " .. tostring(err)) + ya.err("Cannot spawn git command, error: " .. err) return 0 end diff --git a/config/yazi/plugins/glow.yazi/README.md b/config/yazi/plugins/glow.yazi/README.md index abcacac6..c67f7cc7 100644 --- a/config/yazi/plugins/glow.yazi/README.md +++ b/config/yazi/plugins/glow.yazi/README.md @@ -16,3 +16,15 @@ prepend_previewers = [ ``` Make sure you have [glow](https://github.com/charmbracelet/glow) installed, and can be found in `PATH`. + +## Feature + ++ You can modify line wrap in `init.lua`, the current value is 55. ++ You can press `ctrl+e` to scroll up and `ctrl+y` to scroll down the readme file in preview panel in yazi: (add this to `keymap.toml`) +```toml +prepend_keymap = [ + # glow.yazi + { on = [""], run = "seek 5" }, + { on = [""], run = "seek -5" }, +] +``` diff --git a/config/yazi/plugins/glow.yazi/init.lua b/config/yazi/plugins/glow.yazi/init.lua index c19e48b6..cc813e9d 100644 --- a/config/yazi/plugins/glow.yazi/init.lua +++ b/config/yazi/plugins/glow.yazi/init.lua @@ -1,13 +1,16 @@ local M = {} -function M:peek() +function M:peek(job) + -- Set a fixed width of 55 characters for the preview + local preview_width = 55 + local child = Command("glow") :args({ "--style", "dark", "--width", - tostring(self.area.w), - tostring(self.file.url), + tostring(preview_width), -- Use fixed width instead of job.area.w + tostring(job.file.url), }) :env("CLICOLOR_FORCE", "1") :stdout(Command.PIPED) @@ -15,36 +18,59 @@ function M:peek() :spawn() if not child then - return require("code").peek(self) + return require("code").peek(job) end - local limit = self.area.h + local limit = job.area.h local i, lines = 0, "" repeat local next, event = child:read_line() if event == 1 then - return require("code").peek(self) + return require("code").peek(job) elseif event ~= 0 then break end i = i + 1 - if i > self.skip then + if i > job.skip then lines = lines .. next end - until i >= self.skip + limit + until i >= job.skip + limit child:start_kill() - if self.skip > 0 and i < self.skip + limit then - ya.manager_emit("peek", { math.max(0, i - limit), only_if = self.file.url, upper_bound = true }) + if job.skip > 0 and i < job.skip + limit then + ya.manager_emit("peek", { + tostring(math.max(0, i - limit)), + only_if = job.file.url, + upper_bound = true + }) else lines = lines:gsub("\t", string.rep(" ", PREVIEW.tab_size)) - ya.preview_widgets(self, { ui.Text.parse(lines):area(self.area) }) + ya.preview_widgets(job, { ui.Text.parse(lines):area(job.area) }) end end -function M:seek(units) - require("code").seek(self, units) +function M:seek(job) + local h = cx.active.current.hovered + if not h or h.url ~= job.file.url then + return + end + + local scroll_amount = 1 + local scroll_offset = job.units + + if job.key == "ctrl-e" then + scroll_offset = scroll_amount + elseif job.key == "ctrl-y" then + scroll_offset = -scroll_amount + else + scroll_offset = job.units + end + + ya.manager_emit('peek', { + math.max(0, cx.active.preview.skip + scroll_offset), + only_if = job.file.url, + }) end return M diff --git a/config/yazi/plugins/torrent-preview.yazi/init.lua b/config/yazi/plugins/torrent-preview.yazi/init.lua index 1f12324e..d692ce33 100644 --- a/config/yazi/plugins/torrent-preview.yazi/init.lua +++ b/config/yazi/plugins/torrent-preview.yazi/init.lua @@ -1,53 +1,46 @@ local M = {} -function M:peek() - -- launch process - local process, code = Command("transmission-show") +function M:peek(job) + local child = Command("transmission-show") :args({ - tostring(self.file.url), + tostring(job.file.url), }) :stdout(Command.PIPED) + :stderr(Command.PIPED) :spawn() - local limit = self.area.h - -- read and count lines from process + if not child then + return require("code"):peek(job) + end + + local limit = job.area.h local i, lines = 0, "" repeat - local next, event = process:read_line() - if event ~= 0 then + local next, event = child:read_line() + if event == 1 then + return require("code"):peek(job) + elseif event ~= 0 then break end i = i + 1 - -- only concatenate lines that are past 'skip' number of STDOUT - if i > self.skip then + if i > job.skip then lines = lines .. next end - until i >= self.skip + limit -- until reader reaches max number of lines on screen plus skip + until i >= job.skip + limit - process:start_kill() - - -- if paged below all output, run peek again with smaller skip - if self.skip > 0 and i < self.skip + limit then - ya.manager_emit( - "peek", - { tostring(math.max(0, i - limit)), only_if = tostring(self.file.url), upper_bound = "" } - ) - -- preview torrent + child:start_kill() + if job.skip > 0 and i < job.skip + limit then + ya.manager_emit("peek", { math.max(0, i - limit), only_if = job.file.url, upper_bound = true }) else - ya.preview_widgets(self, { ui.Paragraph.parse(self.area, lines):wrap(ui.Paragraph.WRAP) }) + lines = lines:gsub("\t", string.rep(" ", PREVIEW.tab_size)) + ya.preview_widgets(job, { ui.Text.parse(lines):area(job.area) }) end end -function M:seek(units) - local h = cx.active.current.hovered - if h and h.url == self.file.url then - local step = math.floor(units * self.area.h / 10) - ya.manager_emit("peek", { - math.max(0, cx.active.preview.skip + step), - only_if = self.file.url, - }) - end +function M:seek(job) + require("code"):seek(job) end return M + diff --git a/config/yazi/plugins/what-size.yazi/README.md b/config/yazi/plugins/what-size.yazi/README.md index f2be2cd7..c1c86d82 100644 --- a/config/yazi/plugins/what-size.yazi/README.md +++ b/config/yazi/plugins/what-size.yazi/README.md @@ -2,9 +2,14 @@ A plugin for [yazi](https://github.com/sxyazi/yazi) to calculate the size of the current selection or the current working directory (if no selection is made). +## Compatibility + +- yazi `0.4.x` since commit `2780de5aeef1ed16d1973dd6e0cd4d630c900d56` ([link](https://github.com/pirafrank/what-size.yazi/commit/2780de5aeef1ed16d1973dd6e0cd4d630c900d56)). +- yazi `0.3.x` up to commit `f08f7f2d5c94958ac4cb66c51a7c24b4319c6c93` ([link](https://github.com/pirafrank/what-size.yazi/commit/f08f7f2d5c94958ac4cb66c51a7c24b4319c6c93)). + ## Requirements -- `du` +- `du` on Linux. macOS and Windows support is planned. ## Installation diff --git a/config/yazi/plugins/what-size.yazi/init.lua b/config/yazi/plugins/what-size.yazi/init.lua index f4eea8b1..e84e1c12 100644 --- a/config/yazi/plugins/what-size.yazi/init.lua +++ b/config/yazi/plugins/what-size.yazi/init.lua @@ -43,9 +43,9 @@ local function format_size(size) end return { - entry = function(self, args) + entry = function(self, job) -- defaults not to use clipboard, use it only if required by the user - local clipboard = args[1] == '--clipboard' or args[1] == '-c' + local clipboard = job.args.clipboard or job.args[1] == '-c' local items = get_paths() local cmd = "du" diff --git a/config/yazi/plugins/yatline.yazi/init.lua b/config/yazi/plugins/yatline.yazi/init.lua index 100ff0b3..a1e35c31 100644 --- a/config/yazi/plugins/yatline.yazi/init.lua +++ b/config/yazi/plugins/yatline.yazi/init.lua @@ -235,7 +235,7 @@ function Yatline.string.get:hovered_size() end --- Gets the hovered file's path of the current active tab. ---- @return string mime Current active tab's hovered file's path. +--- @return string mime Current active tab's hovered file's mime. function Yatline.string.get:hovered_mime() local hovered = cx.active.current.hovered if hovered then @@ -246,7 +246,7 @@ function Yatline.string.get:hovered_mime() end --- Gets the hovered file's user and group ownership of the current active tab. ---- @return string ownership active tab's hovered file's path. +--- @return string ownership Current active tab's hovered file's user and group ownership. function Yatline.string.get:hovered_ownership() local hovered = cx.active.current.hovered diff --git a/dotter b/dotter old mode 100755 new mode 100644 diff --git a/dotter.arm b/dotter.arm old mode 100755 new mode 100644 diff --git a/dotter.exe b/dotter.exe old mode 100755 new mode 100644 diff --git a/local/bin/typst-port b/local/bin/typst-port old mode 100644 new mode 100755