Skip to content

Commit 0bf9fe9

Browse files
authored
Merge pull request #1816 from mdhooge/master
fix: use a more generic way to print NUL with awk
2 parents ea2427f + 08122d5 commit 0bf9fe9

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

nnn.1

+1-1
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ Handy bash/zsh shell function to list files by mime-type in current directory:
353353

354354
list ()
355355
{
356-
find . -maxdepth 1 | file -if- | grep "$1" | awk -F: '{printf "%s\0", $1}' | nnn
356+
find . -maxdepth 1 | file -if- | grep "$1" | awk -F: '{printf "%s%c", $1, 0}' | nnn
357357
}
358358
.Ed
359359
.Pp

plugins/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Plugins extend the capabilities of `nnn`. They are _executable_ scripts (or bina
4141
| [ipinfo](ipinfo) | Fetch external IP address and whois information | sh | curl, whois |
4242
| [kdeconnect](kdeconnect) | Send selected files to an Android device [] | sh | kdeconnect-cli |
4343
| [launch](launch) | GUI application launcher | sh | fzf |
44-
| [mimelist](mimelist) | List files by mime in subtree | sh | - |
44+
| [mimelist](mimelist) | List files by mime in subtree | sh | file/mimetype |
4545
| [moclyrics](moclyrics) | Show lyrics of the track playing in moc | sh | [ddgr](https://github.com/jarun/ddgr), [moc](http://moc.daper.net/) |
4646
| [mocq](mocq) | Queue/play selection/dir/file in moc [] | sh | [moc](http://moc.daper.net/) |
4747
| [mp3conv](mp3conv) | Extract audio from multimedia as mp3 | sh | ffmpeg |

plugins/mimelist

+10-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22

33
# Description: Find and list files by mime type in smart context
44
#
5+
# Dependencies:
6+
# - file
7+
# - mimetype (optional, PERL File MimeInfo)
8+
#
59
# Shell: POSIX compliant
6-
# Author: Arun Prakash Jana
10+
# Author: Arun Prakash Jana, Michel DHOOGE
711

812
# shellcheck disable=SC1090,SC1091
913
. "$(dirname "$0")"/.nnn-plugin-helper
@@ -12,4 +16,8 @@ printf "mime (e.g., video/audio/image): "
1216
read -r mime
1317

1418
printf "%s" "+l" > "$NNN_PIPE"
15-
find . | file -if- | grep "$mime" | awk -F: '{printf "%s\0", $1}' > "$NNN_PIPE"
19+
if type mimetype >/dev/null 2>&1; then
20+
find . | mimetype -f - | grep "$mime" | awk -F: '{printf "%s%c", $1, 0}' > "$NNN_PIPE"
21+
else
22+
find . | file -if- | grep "$mime" | awk -F: '{printf "%s%c", $1, 0}' > "$NNN_PIPE"
23+
fi

0 commit comments

Comments
 (0)