From 8e7e617baaeea5ce227944969c83b0ba95a9faf2 Mon Sep 17 00:00:00 2001 From: FollieHiyuki Date: Thu, 11 Mar 2021 15:12:18 +0300 Subject: [PATCH] nnn: add `renamer` plugin --- README.md | 2 +- home/.bashrc-bloated | 8 +++--- home/.config/fish/conf.d/env.fish | 2 +- home/.config/fish/conf.d/evaluate.fish | 6 ++-- home/.config/mimeapps.list | 2 ++ home/.config/nnn/plugins/renamer | 40 ++++++++++++++++++++++++++ home/.config/zsh/.zshenv | 2 +- home/.config/zsh/.zshrc | 4 +-- 8 files changed, 54 insertions(+), 12 deletions(-) create mode 100755 home/.config/nnn/plugins/renamer diff --git a/README.md b/README.md index a27ffa8..c77cdcc 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ - **Shell prompt:** [starship](https://starship.rs/) - **Anime/Manga/Wallpaper:** [gallery-dl](https://github.com/mikf/gallery-dl) / [mangadl-bash](https://github.com/Akianonymus/mangadl-bash), [anime-downloader](https://github.com/anime-dl/anime-downloader) + [trackma](https://github.com/z411/trackma) + [adl](https://github.com/RaitaroH/adl) / [anigrab](https://github.com/ngomile/anigrab) - **CLI/TUI for the Internet:** [translate-shell](https://github.com/soimort/translate-shell) / [argos-translate](https://github.com/argosopentech/argos-translate), [ddgr](https://github.com/jarun/ddgr), [howdoi](https://github.com/gleitz/howdoi), [amfora](https://github.com/makeworld-the-better-one/amfora), [cointop](https://github.com/miguelmota/cointop), [newsboat](https://github.com/newsboat/newsboat), [youtube-dl](https://github.com/ytdl-org/youtube-dl) + [ytmdl](https://github.com/deepjyoti30/ytmdl), [github-cli](https://github.com/cli/cli), [pup](https://github.com/ericchiang/pup), [weechat](https://github.com/weechat/weechat), [curl](https://curl.haxx.se) / [wget](https://www.gnu.org/software/wget/wget.html) / [aria2](https://github.com/aria2/aria2), [tremc](https://github.com/tremc/tremc) + [transmission](https://github.com/transmission/transmission) / [rtorrent](https://github.com/rakshasa/rtorrent), [goaccess](https://github.com/allinurl/goaccess) - - **CLI/TUI for other things:** [tt](https://github.com/runrin/tt), [forgit](https://github.com/wfxr/forgit), [borg](https://github.com/borgbackup/borg), [wendy](https://git.z3bra.org/wendy/log.html), [tokei](https://github.com/XAMPPRocky/tokei), [onefetch](https://github.com/o2sh/onefetch), [calcurse](https://github.com/lfos/calcurse), [qalculate](https://github.com/Qalculate/libqalculate), [fzf](https://github.com/junegunn/fzf), [fd](https://github.com/sharkdp/fd), [ripgrep](https://github.com/BurntSushi/ripgrep), [atool](http://www.nongnu.org/atool/), [rsync](https://rsync.samba.org/), [bottom](https://github.com/clementtsang/bottom), [hyperfine](https://github.com/sharkdp/hyperfine), [delta](https://github.com/dandavison/delta), [bat](https://github.com/sharkdp/bat), [glow](https://github.com/charmbracelet/glow) / [mdcat](https://github.com/lunaryorn/mdcat) / [mdr](https://github.com/MichaelMure/mdr), [exa](https://github.com/ogham/exa), [pandoc](https://github.com/jgm/pandoc), [csview](https://github.com/wfxr/csview), [libsixel](https://github.com/saitoha/libsixel), [buku](https://github.com/jarun/buku), [jq](https://github.com/stedolan/jq), [zoxide](https://github.com/ajeetdsouza/zoxide) / [z.lua](https://github.com/skywind3000/z.lua), [xlsx2csv](https://github.com/dilshod/xlsx2csv), sysstat, psmisc, wireless_tools, tree + - **CLI/TUI for other things:** [tt](https://github.com/runrin/tt), [forgit](https://github.com/wfxr/forgit), [borg](https://github.com/borgbackup/borg), [wendy](https://git.z3bra.org/wendy/log.html), [tokei](https://github.com/XAMPPRocky/tokei), [onefetch](https://github.com/o2sh/onefetch), [calcurse](https://github.com/lfos/calcurse), [qalculate](https://github.com/Qalculate/libqalculate), [fzf](https://github.com/junegunn/fzf), [fd](https://github.com/sharkdp/fd), [ripgrep](https://github.com/BurntSushi/ripgrep), [atool](http://www.nongnu.org/atool/), [rsync](https://rsync.samba.org/), [bottom](https://github.com/clementtsang/bottom), [hyperfine](https://github.com/sharkdp/hyperfine), [delta](https://github.com/dandavison/delta), [bat](https://github.com/sharkdp/bat), [glow](https://github.com/charmbracelet/glow) / [mdcat](https://github.com/lunaryorn/mdcat) / [mdr](https://github.com/MichaelMure/mdr), [exa](https://github.com/ogham/exa), [pandoc](https://github.com/jgm/pandoc), [csview](https://github.com/wfxr/csview), [libsixel](https://github.com/saitoha/libsixel), [buku](https://github.com/jarun/buku), [jq](https://github.com/stedolan/jq), [zoxide](https://github.com/ajeetdsouza/zoxide) / [z.lua](https://github.com/skywind3000/z.lua), [xlsx2csv](https://github.com/dilshod/xlsx2csv), sysstat, psmisc, wireless_tools, tree, renameutils - **Selfhosted service:** [LibreTranslate](https://github.com/uav4geo/LibreTranslate), [searx](https://github.com/searx/searx), [yacy](https://github.com/yacy/yacy_search_server), [synapse](https://github.com/matrix-org/synapse), [mastodon](https://github.com/tootsuite/mastodon), [gitea](https://gitea.io/) > `Emacs` deserves its own set of dependencies listed, but I'm lazy -> Check my Doom config for details diff --git a/home/.bashrc-bloated b/home/.bashrc-bloated index 40742ed..3ddbc04 100644 --- a/home/.bashrc-bloated +++ b/home/.bashrc-bloated @@ -100,7 +100,7 @@ export POETRY_HOME="$HOME/.local/share/poetry" if command -v nnn >/dev/null then export TERMINAL=alacritty # for the preview script - export NNN_PLUG='t:preview-tui;m:nmount;f:fzcd;c:chksum;n:nuke;z:fzz;b:bulknew;d:dups:h:hexview;o:organize;p:pdfview;s:suedit' + export NNN_PLUG='t:preview-tui;m:nmount;f:fzcd;c:chksum;n:nuke;z:fzz;b:bulknew;d:dups:h:hexview;o:organize;p:pdfview;s:suedit;r:renamer' export NNN_FIFO="/tmp/nnn.fifo" export NNN_ARCHIVE='\\.(7z|a|ace|alz|arc|arj|bz|bz2|cab|cpio|deb|gz|jar|lha|lz|lzh|lzma|lzo|rar|rpm|rz|t7z|tar|tbz|tbz2|tgz|tlz|txz|tZ|tzo|war|xpi|xz|Z|zip)$' export NNN_OPENER="$XDG_CONFIG_HOME/nnn/plugins/nuke" @@ -710,9 +710,9 @@ shopt -s expand_aliases shopt -s histappend # this is overkilled but it works conveniently -[[ -d $HOME/.local/share/bash/basher/cellar/packages/junegunn/fzf ]] || basher install junegunn/fzf -include junegunn/fzf shell/key-bindings.bash -include junegunn/fzf shell/completion.bash +# [[ -d $HOME/.local/share/bash/basher/cellar/packages/junegunn/fzf ]] || basher install junegunn/fzf +# include junegunn/fzf shell/key-bindings.bash +# include junegunn/fzf shell/completion.bash export FZF_COMPLETION_OPTS='-x' # Use fd instead of find for fzf_completion diff --git a/home/.config/fish/conf.d/env.fish b/home/.config/fish/conf.d/env.fish index 12d7578..1be9036 100644 --- a/home/.config/fish/conf.d/env.fish +++ b/home/.config/fish/conf.d/env.fish @@ -103,7 +103,7 @@ set -gx _ZO_RESOLVE_SYMLINKS 1 # nnn if command -v nnn >/dev/null set -gx TERMINAL alacritty - set -gx NNN_PLUG 't:preview-tui;m:nmount;f:fzcd;c:chksum;n:nuke;z:fzz;b:bulknew;d:dups:h:hexview;o:organize;p:pdfview;s:suedit' + set -gx NNN_PLUG 't:preview-tui;m:nmount;f:fzcd;c:chksum;n:nuke;z:fzz;b:bulknew;d:dups:h:hexview;o:organize;p:pdfview;s:suedit;r:renamer' set -gx NNN_FIFO /tmp/nnn.fifo set -gx NNN_ARCHIVE '\\.(7z|a|ace|alz|arc|arj|bz|bz2|cab|cpio|deb|gz|jar|lha|lz|lzh|lzma|lzo|rar|rpm|rz|t7z|tar|tbz|tbz2|tgz|tlz|txz|tZ|tzo|war|xpi|xz|Z|zip)$' set -gx NNN_OPENER $XDG_CONFIG_HOME/nnn/plugins/nuke diff --git a/home/.config/fish/conf.d/evaluate.fish b/home/.config/fish/conf.d/evaluate.fish index e1bc8be..554763c 100644 --- a/home/.config/fish/conf.d/evaluate.fish +++ b/home/.config/fish/conf.d/evaluate.fish @@ -53,9 +53,9 @@ end fish_vi_key_bindings # fzf -if not test -f "$HOME/.config/fish/functions/fzf_key_bindings.fish" - curl -fLo $HOME/.config/fish/functions/fzf_key_bindings.fish https://raw.githubusercontent.com/junegunn/fzf/master/shell/key-bindings.fish -end +# if not test -f "$HOME/.config/fish/functions/fzf_key_bindings.fish" +# curl -fLo $HOME/.config/fish/functions/fzf_key_bindings.fish https://raw.githubusercontent.com/junegunn/fzf/master/shell/key-bindings.fish +# end fzf_key_bindings # z.lua diff --git a/home/.config/mimeapps.list b/home/.config/mimeapps.list index 152f805..951076d 100644 --- a/home/.config/mimeapps.list +++ b/home/.config/mimeapps.list @@ -5,6 +5,8 @@ x-scheme-handler/https=org.qutebrowser.qutebrowser.desktop x-scheme-handler/about=org.qutebrowser.qutebrowser.desktop x-scheme-handler/unknown=org.qutebrowser.qutebrowser.desktop video/*=mpv.desktop +application/pdf=org.pwmt.zathura-pdf-mupdf.desktop [Added Associations] video/*=mpv.desktop; +application/pdf=org.pwmt.zathura-pdf-mupdf.desktop; diff --git a/home/.config/nnn/plugins/renamer b/home/.config/nnn/plugins/renamer new file mode 100755 index 0000000..2d064c5 --- /dev/null +++ b/home/.config/nnn/plugins/renamer @@ -0,0 +1,40 @@ +#!/usr/bin/env sh + +# Description: Batch rename selection or current directory with qmv +# +# Notes: +# - Try to mimic current batch rename functionality but with correct +# handling of edge cases by qmv or vidir. +# Qmv opens with hidden files if no selection is used. Selected +# directories are shown. +# Vidir don't show directories nor hidden files. +# +# Shell: POSIX compliant +# Author: José Neder + +selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection} + +if which qmv >/dev/null 2>&1; then + batchrenamesel="qmv -fdo -da" + batchrename="qmv -fdo -a" +elif which vidir >/dev/null 2>&1; then + batchrenamesel="vidir" + batchrename="vidir" +else + printf "there is not batchrename program installed." + exit +fi + +if [ -s "$selection" ]; then + printf "rename selection? " + read -r resp +fi + +if [ "$resp" = "y" ]; then + # -o flag is necessary for interactive editors + xargs -o -0 $batchrenamesel < "$selection" +elif [ ! "$(LC_ALL=C ls -a)" = ". +.." ]; then + # On older systems that don't have ls -A + $batchrename +fi diff --git a/home/.config/zsh/.zshenv b/home/.config/zsh/.zshenv index 40db963..8a8e3af 100644 --- a/home/.config/zsh/.zshenv +++ b/home/.config/zsh/.zshenv @@ -85,7 +85,7 @@ export _ZO_RESOLVE_SYMLINKS=1 if command -v nnn >/dev/null then export TERMINAL=alacritty # for the preview script - export NNN_PLUG='t:preview-tui;m:nmount;f:fzcd;c:chksum;n:nuke;z:fzz;b:bulknew;d:dups:h:hexview;o:organize;p:pdfview;s:suedit' + export NNN_PLUG='t:preview-tui;m:nmount;f:fzcd;c:chksum;n:nuke;z:fzz;b:bulknew;d:dups:h:hexview;o:organize;p:pdfview;s:suedit;r:renamer' export NNN_FIFO="/tmp/nnn.fifo" export NNN_ARCHIVE='\\.(7z|a|ace|alz|arc|arj|bz|bz2|cab|cpio|deb|gz|jar|lha|lz|lzh|lzma|lzo|rar|rpm|rz|t7z|tar|tbz|tbz2|tgz|tlz|txz|tZ|tzo|war|xpi|xz|Z|zip)$' export NNN_OPENER="$XDG_CONFIG_HOME/nnn/plugins/nuke" diff --git a/home/.config/zsh/.zshrc b/home/.config/zsh/.zshrc index 52783a8..bdcc3a9 100644 --- a/home/.config/zsh/.zshrc +++ b/home/.config/zsh/.zshrc @@ -115,8 +115,8 @@ zinit ice blockf as"completion" for \ OMZ::plugins/fd/_fd # fzf key bindings and zsh completions for some commands -zinit snippet https://github.com/junegunn/fzf/blob/master/shell/key-bindings.zsh -zinit snippet https://github.com/junegunn/fzf/blob/master/shell/completion.zsh +# zinit snippet https://github.com/junegunn/fzf/blob/master/shell/key-bindings.zsh +# zinit snippet https://github.com/junegunn/fzf/blob/master/shell/completion.zsh export FZF_COMPLETION_OPTS='-x' # https://cht.sh (cheatsheet)