mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 03:41:27 +00:00
Fix #917: enhance plugin framework to clear sel on request
With this enhancement, plugins which operate on selection can explicitly request the program to clear the selection.
This commit is contained in:
parent
7c63dc8d73
commit
7f5dbd11e3
|
@ -14,64 +14,68 @@ Plugins extend the capabilities of `nnn`. They are _executable_ scripts (or bina
|
||||||
|
|
||||||
## List of plugins
|
## List of plugins
|
||||||
|
|
||||||
| Plugin (a-z) | Description | Lang | Dependencies |
|
| Plugin (a-z) | [Clears selection]<sup>1</sup> Description | Lang | Dependencies |
|
||||||
| --- | --- | --- | --- |
|
| --- | --- | --- | --- |
|
||||||
| [autojump](autojump) | Navigate to dir/path | sh | [jump](https://github.com/gsamokovarov/jump)/autojump/zoxide |
|
| [autojump](autojump) | [ ] Navigate to dir/path | sh | [jump](https://github.com/gsamokovarov/jump)/autojump/zoxide |
|
||||||
| [bookmarks](bookmarks) | Use named bookmarks managed with symlinks | sh | fzf |
|
| [bookmarks](bookmarks) | [ ] Use named bookmarks managed with symlinks | sh | fzf |
|
||||||
| [boom](boom) | Play random music from dir | sh | [moc](http://moc.daper.net/) |
|
| [boom](boom) | [ ] Play random music from dir | sh | [moc](http://moc.daper.net/) |
|
||||||
| [bulknew](bulknew) | Create multiple files/dirs at once | bash | sed, xargs, mktemp |
|
| [bulknew](bulknew) | [ ] Create multiple files/dirs at once | bash | sed, xargs, mktemp |
|
||||||
| [chksum](chksum) | Create and verify checksums | sh | md5sum,<br>sha256sum |
|
| [chksum](chksum) | [x] Create and verify checksums | sh | md5sum,<br>sha256sum |
|
||||||
| [cleanfilename](cleanfilename) | Clean filename to be more shell-friendly | sh | sed |
|
| [cleanfilename](cleanfilename) | [x] Clean filename to be more shell-friendly | sh | sed |
|
||||||
| [diffs](diffs) | Diff for selection (limited to 2 for directories) | sh | vimdiff, mktemp |
|
| [diffs](diffs) | [x] Diff for selection (limited to 2 for directories) | sh | vimdiff, mktemp |
|
||||||
| [dragdrop](dragdrop) | Drag/drop files from/into nnn | sh | [dragon](https://github.com/mwh/dragon) |
|
| [dragdrop](dragdrop) | [ ] Drag/drop files from/into nnn | sh | [dragon](https://github.com/mwh/dragon) |
|
||||||
| [dups](dups) | List non-empty duplicate files in current dir | bash | find, md5sum,<br>sort uniq xargs |
|
| [dups](dups) | [ ] List non-empty duplicate files in current dir | bash | find, md5sum,<br>sort uniq xargs |
|
||||||
| [finder](finder) | Run custom find command and list | sh | - |
|
| [finder](finder) | [ ] Run custom find command and list | sh | - |
|
||||||
| [fzcd](fzcd) | Change to the directory of a fuzzy-selected file/dir | sh | fzf |
|
| [fzcd](fzcd) | [ ] Change to the directory of a fuzzy-selected file/dir | sh | fzf |
|
||||||
| [fzhist](fzhist) | Fuzzy-select a cmd from history, edit in `$EDITOR` and run | sh | fzf, mktemp |
|
| [fzhist](fzhist) | [ ] Fuzzy-select a cmd from history, edit in `$EDITOR` and run | sh | fzf, mktemp |
|
||||||
| [fzopen](fzopen) | Fuzzy find a file in dir subtree and edit or open | sh | fzf, xdg-open |
|
| [fzopen](fzopen) | [ ] Fuzzy find a file in dir subtree and edit or open | sh | fzf, xdg-open |
|
||||||
| [fzz](fzz) | Change to any directory in the z database with fzf | sh | fzf, z |
|
| [fzz](fzz) | [ ] Change to any directory in the z database with fzf | sh | fzf, z |
|
||||||
| [getplugs](getplugs) | Update plugins to installed `nnn` version | sh | curl |
|
| [getplugs](getplugs) | [ ] Update plugins to installed `nnn` version | sh | curl |
|
||||||
| [gpg\*](gpg\*) | Encrypt/decrypt files using GPG | sh | gpg |
|
| [gpg\*](gpg\*) | [x] Encrypt/decrypt files using GPG | sh | gpg |
|
||||||
| [gutenread](gutenread) | Browse, download, read from Project Gutenberg | sh | curl, unzip, w3m<br>[epr](https://github.com/wustho/epr) (optional) |
|
| [gutenread](gutenread) | [ ] Browse, download, read from Project Gutenberg | sh | curl, unzip, w3m<br>[epr](https://github.com/wustho/epr) (optional) |
|
||||||
| [hexview](hexview) | View a file in hex in `$PAGER` | sh | [hx](https://github.com/krpors/hx)/xxd |
|
| [hexview](hexview) | [ ] View a file in hex in `$PAGER` | sh | [hx](https://github.com/krpors/hx)/xxd |
|
||||||
| [imgresize](imgresize) | Resize images in dir to screen resolution | sh | [imgp](https://github.com/jarun/imgp) |
|
| [imgresize](imgresize) | [ ] Resize images in dir to screen resolution | sh | [imgp](https://github.com/jarun/imgp) |
|
||||||
| [imgthumb](imgthumb) | View thumbnail of an image or dir of images | sh | [lsix](https://github.com/hackerb9/lsix) |
|
| [imgthumb](imgthumb) | [ ] View thumbnail of an image or dir of images | sh | [lsix](https://github.com/hackerb9/lsix) |
|
||||||
| [imgur](imgur) | Upload an image to imgur (from [imgur-screenshot](https://github.com/jomo/imgur-screenshot)) | bash | - |
|
| [imgur](imgur) | [ ] Upload an image to imgur (from [imgur-screenshot](https://github.com/jomo/imgur-screenshot)) | bash | - |
|
||||||
| [imgview](imgview) | Browse images, set wallpaper, copy path ([config](https://wiki.archlinux.org/index.php/Sxiv#Assigning_keyboard_shortcuts)), [rename](https://github.com/jarun/nnn/wiki/Basic-use-cases#browse-rename-images)| sh | [imv](https://github.com/eXeC64/imv)/[sxiv](https://github.com/muennich/sxiv)/[viu](https://github.com/atanunq/viu), less|
|
| [imgview](imgview) | [ ] Browse images, set wallpaper, copy path ([config](https://wiki.archlinux.org/index.php/Sxiv#Assigning_keyboard_shortcuts)), [rename](https://github.com/jarun/nnn/wiki/Basic-use-cases#browse-rename-images)| sh | [imv](https://github.com/eXeC64/imv)/[sxiv](https://github.com/muennich/sxiv)/[viu](https://github.com/atanunq/viu), less|
|
||||||
| [ipinfo](ipinfo) | Fetch external IP address and whois information | sh | curl, whois |
|
| [ipinfo](ipinfo) | [ ] Fetch external IP address and whois information | sh | curl, whois |
|
||||||
| [kdeconnect](kdeconnect) | Send selected files to an Android device | sh | kdeconnect-cli |
|
| [kdeconnect](kdeconnect) | [x] Send selected files to an Android device | sh | kdeconnect-cli |
|
||||||
| [launch](launch) | GUI application launcher | sh | fzf |
|
| [launch](launch) | [ ] GUI application launcher | sh | fzf |
|
||||||
| [mediainf](mediainf) | Show media information | sh | mediainfo |
|
| [mediainf](mediainf) | [ ] Show media information | sh | mediainfo |
|
||||||
| [mimelist](mimelist) | List files by mime in subtree | sh | - |
|
| [mimelist](mimelist) | [ ] List files by mime in subtree | sh | - |
|
||||||
| [moclyrics](moclyrics) | Show lyrics of the track playing in moc | sh | [ddgr](https://github.com/jarun/ddgr), [moc](http://moc.daper.net/) |
|
| [moclyrics](moclyrics) | [ ] Show lyrics of the track playing in moc | sh | [ddgr](https://github.com/jarun/ddgr), [moc](http://moc.daper.net/) |
|
||||||
| [mocplay](mocplay) | Append (and/or play) selection/dir/file in moc | sh | [moc](http://moc.daper.net/) |
|
| [mocplay](mocplay) | [x] Append (and/or play) selection/dir/file in moc | sh | [moc](http://moc.daper.net/) |
|
||||||
| [mp3conv](mp3conv) | Extract audio from multimedia as mp3 | sh | ffmpeg |
|
| [mp3conv](mp3conv) | [ ] Extract audio from multimedia as mp3 | sh | ffmpeg |
|
||||||
| [mtpmount](mtpmount) | Toggle mount of MTP device (eg. Android) | sh | gvfs-mtp |
|
| [mtpmount](mtpmount) | [ ] Toggle mount of MTP device (eg. Android) | sh | gvfs-mtp |
|
||||||
| [nbak](nbak) | Backs up `nnn` config | sh | tar, awk, mktemp |
|
| [nbak](nbak) | [ ] Backs up `nnn` config | sh | tar, awk, mktemp |
|
||||||
| [nmount](nmount) | Toggle mount status of a device as normal user | sh | pmount, udisks2 |
|
| [nmount](nmount) | [ ] Toggle mount status of a device as normal user | sh | pmount, udisks2 |
|
||||||
| [nuke](nuke) | Sample file opener (CLI-only by default) | sh | _see in-file docs_ |
|
| [nuke](nuke) | [ ] Sample file opener (CLI-only by default) | sh | _see in-file docs_ |
|
||||||
| [oldbigfile](oldbigfile) | List large files by access time | sh | find, sort |
|
| [oldbigfile](oldbigfile) | [ ] List large files by access time | sh | find, sort |
|
||||||
| [organize](organize) | Auto-organize files in directories by file type | sh | file |
|
| [organize](organize) | [x] Auto-organize files in directories by file type | sh | file |
|
||||||
| [pdfread](pdfread) | Read a PDF or text file aloud | sh | pdftotext, mpv,<br>pico2wave |
|
| [pdfread](pdfread) | [ ] Read a PDF or text file aloud | sh | pdftotext, mpv,<br>pico2wave |
|
||||||
| [pdfview](pdfview) | View PDF file in `$PAGER` | sh | pdftotext/<br>mupdf-tools |
|
| [pdfview](pdfview) | [ ] View PDF file in `$PAGER` | sh | pdftotext/<br>mupdf-tools |
|
||||||
| [picker](picker) | Pick files and list one per line (to pipe) | sh | nnn |
|
| [picker](picker) | [ ] Pick files and list one per line (to pipe) | sh | nnn |
|
||||||
| [preview-tabbed](preview-tabbed) | Tabbed/xembed based file previewer | bash | _see in-file docs_ |
|
| [preview-tabbed](preview-tabbed) | [ ] Tabbed/xembed based file previewer | bash | _see in-file docs_ |
|
||||||
| [preview-tui](preview-tui) | Tmux/kitty/xterm/`$TERMINAL` based file previewer | sh | _see in-file docs_ |
|
| [preview-tui](preview-tui) | [ ] Tmux/kitty/xterm/`$TERMINAL` based file previewer | sh | _see in-file docs_ |
|
||||||
| [preview-tui-ext](preview-tui-ext) | Meant to be an exhaustive version of [preview-tui](preview-tui) | sh | _see in-file docs_ |
|
| [preview-tui-ext](preview-tui-ext) | [ ] Meant to be an exhaustive version of [preview-tui](preview-tui) | sh | _see in-file docs_ |
|
||||||
| [pskill](pskill) | Fuzzy list by name and kill process or zombie | sh | fzf, ps, sudo/doas |
|
| [pskill](pskill) | [ ] Fuzzy list by name and kill process or zombie | sh | fzf, ps, sudo/doas |
|
||||||
| [renamer](renamer) | Batch rename selection or files in dir | sh | [qmv](https://www.nongnu.org/renameutils/)/[vidir](https://joeyh.name/code/moreutils/) |
|
| [renamer](renamer) | [x] 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 |
|
| [ringtone](ringtone) | [ ] Create a variable bitrate mp3 ringtone from file | sh | date, ffmpeg |
|
||||||
| [rsynccp](rsynccp) | Gives copy-paste verbose progress percentage | sh | rsync |
|
| [rsynccp](rsynccp) | [x] Gives copy-paste verbose progress percentage | sh | rsync |
|
||||||
| [splitjoin](splitjoin) | Split file or join selection | sh | split, cat |
|
| [splitjoin](splitjoin) | [x] Split file or join selection | sh | split, cat |
|
||||||
| [suedit](suedit) | Edit file using superuser permissions | sh | sudoedit/sudo/doas |
|
| [suedit](suedit) | [ ] Edit file using superuser permissions | sh | sudoedit/sudo/doas |
|
||||||
| [togglex](togglex) | Toggle executable mode for selection | sh | chmod |
|
| [togglex](togglex) | [x] Toggle executable mode for selection | sh | chmod |
|
||||||
| [treeview](treeview) | Informative tree output in `$EDITOR` | sh | tree |
|
| [treeview](treeview) | [ ] Informative tree output in `$EDITOR` | sh | tree |
|
||||||
| [uidgid](uidgid) | List user and group of all files in dir | sh | ls, less |
|
| [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 |
|
| [upgrade](upgrade) | [ ] Upgrade nnn manually on Debian 9 Stretch | sh | curl |
|
||||||
| [upload](upload) | Upload to Firefox Send or ix.io (text) or file.io (bin) | sh | [ffsend](https://github.com/timvisee/ffsend), curl, jq, tr |
|
| [upload](upload) | [ ] Upload to Firefox Send or ix.io (text) or file.io (bin) | sh | [ffsend](https://github.com/timvisee/ffsend), curl, jq, tr |
|
||||||
| [vidthumb](vidthumb) | Show video thumbnails in terminal | sh | [ffmpegthumbnailer](https://github.com/dirkvdb/ffmpegthumbnailer),<br>[lsix](https://github.com/hackerb9/lsix) |
|
| [vidthumb](vidthumb) | [ ] Show video thumbnails in terminal | sh | [ffmpegthumbnailer](https://github.com/dirkvdb/ffmpegthumbnailer),<br>[lsix](https://github.com/hackerb9/lsix) |
|
||||||
| [wall](wall) | Set wallpaper or change colorscheme | sh | nitrogen/pywal |
|
| [wall](wall) | [ ] Set wallpaper or change colorscheme | sh | nitrogen/pywal |
|
||||||
| [x2sel](x2sel) | Copy `\n`-separated file list from system clipboard to sel | sh | _see in-file docs_ |
|
| [x2sel](x2sel) | [ ] Copy `\n`-separated file list from system clipboard to sel | sh | _see in-file docs_ |
|
||||||
|
|
||||||
|
Note:
|
||||||
|
|
||||||
|
1. A plugin has to explicitly request `nnn` to clear the selection e.g. after operating on the selected files.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
|
@ -207,6 +211,7 @@ The `ctxcode` indicates the context to change the active directory of.
|
||||||
| `1`-`4` | context number |
|
| `1`-`4` | context number |
|
||||||
| `0` | current context |
|
| `0` | current context |
|
||||||
| `+` | smart context (next inactive else current) |
|
| `+` | smart context (next inactive else current) |
|
||||||
|
| `-` | clear the selection |
|
||||||
|
|
||||||
The `opcode` indicates the operation type.
|
The `opcode` indicates the operation type.
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,11 @@ fi
|
||||||
if [ "$resp" = "s" ]; then
|
if [ "$resp" = "s" ]; then
|
||||||
checksum_type
|
checksum_type
|
||||||
sed 's|'"$PWD/"'||g' < "$selection" | xargs -0 -I{} ${chsum}sum {} > "checksum_$(date '+%Y%m%d%H%M').$chsum"
|
sed 's|'"$PWD/"'||g' < "$selection" | xargs -0 -I{} ${chsum}sum {} > "checksum_$(date '+%Y%m%d%H%M').$chsum"
|
||||||
|
|
||||||
|
# Clear selection
|
||||||
|
if [ -p "$NNN_PIPE" ]; then
|
||||||
|
printf "-" > "$NNN_PIPE"
|
||||||
|
fi
|
||||||
elif [ -n "$1" ]; then
|
elif [ -n "$1" ]; then
|
||||||
if [ -f "$1" ]; then
|
if [ -f "$1" ]; then
|
||||||
for chks in md5 sha1 sha224 sha256 sha384 sha512
|
for chks in md5 sha1 sha224 sha256 sha384 sha512
|
||||||
|
|
|
@ -21,7 +21,7 @@ cleanup() {
|
||||||
printf "%s" "$1" | sed -e 's/[^A-Za-z0-9._-]/_/g'
|
printf "%s" "$1" | sed -e 's/[^A-Za-z0-9._-]/_/g'
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ -f "$sel" ]; then
|
if [ -s "$sel" ]; then
|
||||||
targets=$(sed -e "s/\\x0/\\n/g;\$a\\" "$sel" | \
|
targets=$(sed -e "s/\\x0/\\n/g;\$a\\" "$sel" | \
|
||||||
while read -r i; do
|
while read -r i; do
|
||||||
basename "$i";
|
basename "$i";
|
||||||
|
@ -57,3 +57,8 @@ for i in $targets; do
|
||||||
mv "$i" "$tmp$(cleanup "$i")";
|
mv "$i" "$tmp$(cleanup "$i")";
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# Clear selection
|
||||||
|
if [ -s "$sel" ] && [ -p "$NNN_PIPE" ]; then
|
||||||
|
printf "-" > "$NNN_PIPE"
|
||||||
|
fi
|
||||||
|
|
|
@ -54,3 +54,8 @@ if [ -s "$selection" ]; then
|
||||||
echo "needs at least 2 files or directories selected for comparison"
|
echo "needs at least 2 files or directories selected for comparison"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Clear selection
|
||||||
|
if [ -p "$NNN_PIPE" ]; then
|
||||||
|
printf "-" > "$NNN_PIPE"
|
||||||
|
fi
|
||||||
|
|
|
@ -19,3 +19,8 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf "%s" "$files" | xargs -n1 -I{} gpg --decrypt --output "{}.dec" {}
|
printf "%s" "$files" | xargs -n1 -I{} gpg --decrypt --output "{}.dec" {}
|
||||||
|
|
||||||
|
# Clear selection
|
||||||
|
if [ "$resp" = "s" ] && [ -p "$NNN_PIPE" ]; then
|
||||||
|
printf "-" > "$NNN_PIPE"
|
||||||
|
fi
|
||||||
|
|
|
@ -34,4 +34,9 @@ else
|
||||||
recipient=$(printf "%s" "$keyuids" | fzf | awk '{print $1}')
|
recipient=$(printf "%s" "$keyuids" | fzf | awk '{print $1}')
|
||||||
|
|
||||||
printf "%s" "$files" | xargs -n1 gpg --encrypt --recipient "$recipient"
|
printf "%s" "$files" | xargs -n1 gpg --encrypt --recipient "$recipient"
|
||||||
|
|
||||||
|
# Clear selection
|
||||||
|
if [ "$resp" = "s" ] && [ -p "$NNN_PIPE" ]; then
|
||||||
|
printf "-" > "$NNN_PIPE"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -8,11 +8,16 @@
|
||||||
selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection}
|
selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection}
|
||||||
|
|
||||||
id=$(kdeconnect-cli -a --id-only | awk '{print $1}')
|
id=$(kdeconnect-cli -a --id-only | awk '{print $1}')
|
||||||
if [ "$(find "$selection")" ]; then
|
if [ -s "$selection" ]; then
|
||||||
kdeconnect-cli -d "$id" --share "$(cat "$selection")"
|
kdeconnect-cli -d "$id" --share "$(cat "$selection")"
|
||||||
|
|
||||||
# If you want a system notification, uncomment the next 3 lines.
|
# If you want a system notification, uncomment the next 3 lines.
|
||||||
#notify-send -a "Kdeconnect" "Sending $(cat "$selection")"
|
#notify-send -a "Kdeconnect" "Sending $(cat "$selection")"
|
||||||
#else
|
#else
|
||||||
#notify-send -a "Kdeconnect" "No file selected"
|
#notify-send -a "Kdeconnect" "No file selected"
|
||||||
|
|
||||||
|
# Clear selection
|
||||||
|
if [ -p "$NNN_PIPE" ]; then
|
||||||
|
printf "-" > "$NNN_PIPE"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -82,3 +82,8 @@ mocp -p
|
||||||
|
|
||||||
# uncomment the line below to show mocp interface after appending
|
# uncomment the line below to show mocp interface after appending
|
||||||
# mocp
|
# mocp
|
||||||
|
|
||||||
|
# Clear selection
|
||||||
|
if [ "$resp" = "y" ] && [ -p "$NNN_PIPE" ]; then
|
||||||
|
printf "-" > "$NNN_PIPE"
|
||||||
|
fi
|
||||||
|
|
|
@ -2,9 +2,13 @@
|
||||||
|
|
||||||
# Description: Organize files in directories by category
|
# Description: Organize files in directories by category
|
||||||
#
|
#
|
||||||
|
# Note: This plugin clears the selection as it changes the contents of the current dir
|
||||||
|
#
|
||||||
# Shell: POSIX compliant
|
# Shell: POSIX compliant
|
||||||
# Author: th3lusive
|
# Author: th3lusive
|
||||||
|
|
||||||
|
sel=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection}
|
||||||
|
|
||||||
organize() {
|
organize() {
|
||||||
case "$(file -biL "$1")" in
|
case "$(file -biL "$1")" in
|
||||||
*video*)
|
*video*)
|
||||||
|
@ -48,6 +52,11 @@ main() {
|
||||||
do
|
do
|
||||||
[ -f "$file" ] && organize "$file"
|
[ -f "$file" ] && organize "$file"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# Clear selection
|
||||||
|
if [ -s "$sel" ] && [ -p "$NNN_PIPE" ]; then
|
||||||
|
printf "-" > "$NNN_PIPE"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
main "$@"
|
main "$@"
|
||||||
|
|
|
@ -33,6 +33,11 @@ fi
|
||||||
if [ "$resp" = "y" ]; then
|
if [ "$resp" = "y" ]; then
|
||||||
# -o flag is necessary for interactive editors
|
# -o flag is necessary for interactive editors
|
||||||
xargs -o -0 $batchrenamesel < "$selection"
|
xargs -o -0 $batchrenamesel < "$selection"
|
||||||
|
|
||||||
|
# Clear selection
|
||||||
|
if [ -p "$NNN_PIPE" ]; then
|
||||||
|
printf "-" > "$NNN_PIPE"
|
||||||
|
fi
|
||||||
elif [ ! "$(LC_ALL=C ls -a)" = ".
|
elif [ ! "$(LC_ALL=C ls -a)" = ".
|
||||||
.." ]; then
|
.." ]; then
|
||||||
# On older systems that don't have ls -A
|
# On older systems that don't have ls -A
|
||||||
|
|
|
@ -19,3 +19,8 @@ xargs -0 -a "$sel" -I % rsync -ah --progress % "$PWD"
|
||||||
|
|
||||||
# less verbose
|
# less verbose
|
||||||
# xargs -0 -a "$sel" -I % rsync -ah --info=progress2 % "$PWD"
|
# xargs -0 -a "$sel" -I % rsync -ah --info=progress2 % "$PWD"
|
||||||
|
|
||||||
|
# Clear selection
|
||||||
|
if [ -p "$NNN_PIPE" ]; then
|
||||||
|
printf "-" > "$NNN_PIPE"
|
||||||
|
fi
|
||||||
|
|
|
@ -33,6 +33,11 @@ if [ "$resp" = "j" ]; then
|
||||||
|
|
||||||
file="$(basename "$(echo "$arr" | sed -n '1p' | sed -e 's/[0-9][0-9]$//')")"
|
file="$(basename "$(echo "$arr" | sed -n '1p' | sed -e 's/[0-9][0-9]$//')")"
|
||||||
sort -z < "$selection" | xargs -0 -I{} cat {} > "${file}.out"
|
sort -z < "$selection" | xargs -0 -I{} cat {} > "${file}.out"
|
||||||
|
|
||||||
|
# Clear selection
|
||||||
|
if [ -p "$NNN_PIPE" ]; then
|
||||||
|
printf "-" > "$NNN_PIPE"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
elif [ "$resp" = "s" ]; then
|
elif [ "$resp" = "s" ]; then
|
||||||
if [ -n "$1" ] && [ -f "$1" ]; then
|
if [ -n "$1" ] && [ -f "$1" ]; then
|
||||||
|
|
|
@ -11,10 +11,11 @@
|
||||||
|
|
||||||
selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection}
|
selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection}
|
||||||
|
|
||||||
if [ ! -s "$selection" ]; then
|
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"
|
xargs -0 -I {} sh -c 'if [ -x "{}" ] ; then chmod -x "{}" ; else chmod +x "{}" ; fi' < "$selection"
|
||||||
|
|
||||||
|
# Clear selection
|
||||||
|
if [ -p "$NNN_PIPE" ]; then
|
||||||
|
printf "-" > "$NNN_PIPE"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
13
src/nnn.c
13
src/nnn.c
|
@ -4754,15 +4754,15 @@ static void readpipe(int fd, char **path, char **lastname, char **lastdir)
|
||||||
char ctx, *nextpath = NULL;
|
char ctx, *nextpath = NULL;
|
||||||
ssize_t len = read_nointr(fd, g_buf, 1);
|
ssize_t len = read_nointr(fd, g_buf, 1);
|
||||||
|
|
||||||
if (len != 1) {
|
if (len != 1)
|
||||||
if (selbufpos)
|
|
||||||
clearselection();
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if (g_buf[0] == '+')
|
if (g_buf[0] == '+')
|
||||||
ctx = (char)(get_free_ctx() + 1);
|
ctx = (char)(get_free_ctx() + 1);
|
||||||
else if (g_buf[0] < '0')
|
else if (g_buf[0] == '-') { /* Clear selection on '-' */
|
||||||
|
clearselection();
|
||||||
|
return;
|
||||||
|
} else if (g_buf[0] < '0')
|
||||||
return;
|
return;
|
||||||
else {
|
else {
|
||||||
ctx = g_buf[0] - '0';
|
ctx = g_buf[0] - '0';
|
||||||
|
@ -4789,8 +4789,7 @@ static void readpipe(int fd, char **path, char **lastname, char **lastdir)
|
||||||
rmlistpath();
|
rmlistpath();
|
||||||
|
|
||||||
nextpath = load_input(fd, *path);
|
nextpath = load_input(fd, *path);
|
||||||
} else if (selbufpos)
|
}
|
||||||
clearselection();
|
|
||||||
|
|
||||||
if (nextpath) {
|
if (nextpath) {
|
||||||
if (ctx == 0 || ctx == cfg.curctx + 1) { /* Same context */
|
if (ctx == 0 || ctx == cfg.curctx + 1) { /* Same context */
|
||||||
|
|
Loading…
Reference in a new issue