README.md | 2 +- plugins/README.md | 1 + plugins/togglex | 20 ++++++++++++++++++++ diff --git a/README.md b/README.md index 24ce050805362437b49e461fd6906825168f49a0..ce56877bc88b315373c13edd2622e0840a1788d5 100644 --- a/README.md +++ b/README.md @@ -130,7 +130,7 @@ - FreeDesktop compliant trash (needs trash-cli) - Cross-dir file/all/range selection - Create (with parents), rename, duplicate files and dirs - Batch renamer for selection or dir - - List input file stream from stdin or plugin + - List input stream of file paths from stdin or plugin - Copy (as), move (as), delete, archive, link selection - Dir updates, notification on cp, mv, rm completion - Copy file paths to system clipboard on select diff --git a/plugins/README.md b/plugins/README.md index d802cffd52c8c4a5babe1a34b4b073d1afbd09bd..eba14f83b30b666e493870a4177fc39c7d595853 100644 --- a/plugins/README.md +++ b/plugins/README.md @@ -60,6 +60,7 @@ | [renamer](renamer) | Batch rename selection or files in dir | sh | [qmv](https://www.nongnu.org/renameutils/)/[vidir](https://joeyh.name/code/moreutils/) | | [ringtone](ringtone) | Create a variable bitrate mp3 ringtone from file | sh | date, ffmpeg | | [splitjoin](splitjoin) | Split file or join selection | sh | split, cat | | [suedit](suedit) | Edit file using superuser permissions | sh | sudoedit/sudo/doas | +| [togglex](togglex) | Toggle executable mode for selection | sh | chmod | | [treeview](treeview) | Informative tree output in `$EDITOR` | sh | tree | | [uidgid](uidgid) | List user and group of all files in dir | sh | ls, less | | [upgrade](upgrade) | Upgrade nnn manually on Debian 9 Stretch | sh | curl | diff --git a/plugins/togglex b/plugins/togglex new file mode 100755 index 0000000000000000000000000000000000000000..e2a23f4123de298fc7e5365dd89f43cdde96c119 --- /dev/null +++ b/plugins/togglex @@ -0,0 +1,20 @@ +#!/usr/bin/env sh + +# Description: Toggles executable mode for selection +# +# Dependencies: chmod +# +# Note: Works _only_ with selection (nnn can toggle the mode for the hovered file) +# +# Shell: POSIX compliant +# Author: Arun Prakash Jana + +selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection} + +if [ ! -s "$selection" ]; then + printf "0 selected " + read -r _ + exit +fi + +xargs -0 -I {} sh -c 'if [ -x {} ] ; then chmod -x {} ; else chmod +x {} ; fi' < "$selection"