File tree 3 files changed +12
-4
lines changed
3 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -353,7 +353,7 @@ Handy bash/zsh shell function to list files by mime-type in current directory:
353
353
354
354
list ()
355
355
{
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
357
357
}
358
358
.Ed
359
359
.Pp
Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ Plugins extend the capabilities of `nnn`. They are _executable_ scripts (or bina
41
41
| [ ipinfo] ( ipinfo ) | Fetch external IP address and whois information | sh | curl, whois |
42
42
| [ kdeconnect] ( kdeconnect ) | Send selected files to an Android device [ ✓] | sh | kdeconnect-cli |
43
43
| [ 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 |
45
45
| [ moclyrics] ( moclyrics ) | Show lyrics of the track playing in moc | sh | [ ddgr] ( https://github.com/jarun/ddgr ) , [ moc] ( http://moc.daper.net/ ) |
46
46
| [ mocq] ( mocq ) | Queue/play selection/dir/file in moc [ ✓] | sh | [ moc] ( http://moc.daper.net/ ) |
47
47
| [ mp3conv] ( mp3conv ) | Extract audio from multimedia as mp3 | sh | ffmpeg |
Original file line number Diff line number Diff line change 2
2
3
3
# Description: Find and list files by mime type in smart context
4
4
#
5
+ # Dependencies:
6
+ # - file
7
+ # - mimetype (optional, PERL File MimeInfo)
8
+ #
5
9
# Shell: POSIX compliant
6
- # Author: Arun Prakash Jana
10
+ # Author: Arun Prakash Jana, Michel DHOOGE
7
11
8
12
# shellcheck disable=SC1090,SC1091
9
13
. " $( dirname " $0 " ) " /.nnn-plugin-helper
@@ -12,4 +16,8 @@ printf "mime (e.g., video/audio/image): "
12
16
read -r mime
13
17
14
18
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
You can’t perform that action at this time.
0 commit comments