echo "########## clang-tidy-10 ##########"
clang-tidy-10 src/* -- -I/usr/include -I/usr/include/ncursesw
echo "########## shellcheck ##########"
- find plugins/ -type f -not -name "*.md" -exec shellcheck -e SC1090 {} +
+ find plugins/ -type f -not -name "*.md" -exec shellcheck -e SC1090,SC2230 {} +
package-and-publish:
machine: true
| [kdeconnect](kdeconnect) | Send selected files to an Android device | sh | kdeconnect-cli |
| [launch](launch) | GUI application launcher | sh | fzf |
| [mediainf](mediainf) | Show media information | sh | mediainfo |
-| [mimelist](mimelist) | List files by mime in subtree | sh | fd/find |
+| [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/) |
| [mocplay](mocplay) | 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 |
GUIPLAYER="${GUIPLAYER}"
NUMTRACKS="${NUMTRACKS:-100}"
-if [ ! -z "$GUIPLAYER" ]; then
+if [ -n "$GUIPLAYER" ]; then
find . -type f \( -iname "*.mp3" -o -iname "*.flac" -o -iname "*.m4a" -o -iname "*.webm" -o -iname "*.wma" \) | shuf -n "$NUMTRACKS" | xargs -d "\n" "$GUIPLAYER" > /dev/null 2>&1 &
# detach the player
eval xargs -0 "$diffcmd" < "$selection"
fi
- elif ! [ -z "$1" ]; then
+ elif [ -n "$1" ]; then
f1="$(echo "$arr" | sed -n '1p')"
if [ -d "$f1" ] && [ -d "$1" ]; then
dirdiff "$f1" "$1"
printf "cmd: "
read -r cmd
-if ! [ -z "$cmd" ]; then
+if [ -n "$cmd" ]; then
printf "%s" "+l" > "$NNN_PIPE"
eval "$cmd" > "$NNN_PIPE"
fi
entry="$(grep "\- cmd: " "$hist_file" | cut -c 8- | "$fuzzy")"
fi
-if ! [ -z "$entry" ]; then
+if [ -n "$entry" ]; then
tmpfile=$(mktemp)
echo "$entry" >> "$tmpfile"
$EDITOR "$tmpfile"
# Shell: POSIX compliant
# Author: Arun Prakash Jana
-if ! [ -z "$1" ]; then
+if [ -n "$1" ]; then
if which hx >/dev/null 2>&1; then
hx "$1"
else
read -r res
fi
-if ! [ -z "$res" ] && ! [ -z "$MINSIZE" ]; then
+if [ -n "$res" ] && [ -n "$MINSIZE" ]; then
imgp -ackx "$res" -s "$MINSIZE"
fi
# Shell: POSIX compliant
# Author: Arun Prakash Jana
-if ! [ -z "$1" ]; then
+if [ -n "$1" ]; then
if [ -d "$1" ]; then
lsix "$1"/*
else
function check_for_update() {
# exit non-zero on HTTP error, output only the body (no stats) but output errors, follow redirects, output everything to stdout
remote_version="$(curl --compressed -fsSL --stderr - "https://api.github.com/repos/jomo/imgur-screenshot/releases" | grep -Em 1 --color 'tag_name":\s*".*"' | cut -d '"' -f 4)"
- if ! [ -z "$remote_version" ]; then
- if [ ! "${current_version}" = "${remote_version}" ] && [ ! -z "${current_version}" ] && [ ! -z "${remote_version}" ]; then
+ if [ -n "$remote_version" ]; then
+ if [ ! "${current_version}" = "${remote_version}" ] && [ -n "${current_version}" ] && [ -n "${remote_version}" ]; then
echo "Update found!"
echo "Version ${remote_version} is available (You have ${current_version})"
notify ok "Update found" "Version ${remote_version} is available (You have ${current_version}). https://github.com/jomo/imgur-screenshot"
current_time="$(date +%s)"
preemptive_refresh_time="$((10*60))"
expired="$((current_time > (token_expire_time - preemptive_refresh_time)))"
- if [ ! -z "${refresh_token}" ]; then
+ if [ -n "${refresh_token}" ]; then
# token already set
if [ "${expired}" -eq "0" ]; then
# token expired
img_ext="$(grep -Eo '"link":\s*"[^"]+"' <<<"${response}" | cut -d "\"" -f 4 | rev | cut -d "." -f 1 | rev)" # "link" itself has ugly '\/' escaping and no https!
del_id="$(grep -Eo '"deletehash":\s*"[^"]+"' <<<"${response}" | cut -d "\"" -f 4)"
- if [ ! -z "${auto_delete}" ]; then
+ if [ -n "${auto_delete}" ]; then
export -f delete_image
echo "Deleting image in ${auto_delete} seconds."
nohup /bin/bash -c "sleep ${auto_delete} && delete_image ${imgur_anon_id} ${del_id} ${log_file}" &
img_ext="$(grep -Eo '"link":\s*"[^"]+"' <<<"${response}" | cut -d "\"" -f 4 | rev | cut -d "." -f 1 | rev)" # "link" itself has ugly '\/' escaping and no https!
del_id="$(grep -Eo '"deletehash":\s*"[^"]+"' <<<"${response}" | cut -d "\"" -f 4)"
- if [ ! -z "${auto_delete}" ]; then
+ if [ -n "${auto_delete}" ]; then
export -f delete_image
echo "Deleting image in ${auto_delete} seconds."
nohup /bin/bash -c "sleep ${auto_delete} && delete_image ${imgur_anon_id} ${del_id} ${log_file}" &
if selection=$( get_selection ); then
setsid "$selection" 2>/dev/null 1>/dev/null &
- if ! [ -z "$1" ]; then
+ if [ -n "$1" ]; then
sleep "$1"
else
sleep 1
# Shell: POSIX compliant
# Author: Arun Prakash Jana
-if ! [ -z "$1" ] && [ -f "$1" ]; then
+if [ -n "$1" ] && [ -f "$1" ]; then
mediainfo "$1" | $PAGER
# exiftool "$1" | $PAGER
fi
#!/usr/bin/env sh
-# Description: Run fd/find in subtree and list files by mime type in smart context
-# Dependencies: fd/find
+# Description: Find and list files by mime type in smart context
#
# Shell: POSIX compliant
# Author: Arun Prakash Jana
. "$(dirname "$0")"/.nnn-plugin-helper
-if [ "$(cmd_exists fd)" -eq "0" ]; then
- fd=fd
-else
- fd=find
-fi
-
printf "mime (e.g., video/audio/image): "
read -r mime
printf "%s" "+l" > "$NNN_PIPE"
-$fd | file -if- | grep "$mime" | awk -F: '{printf "%s\0", $1}' > "$NNN_PIPE"
+find . | file -if- | grep "$mime" | awk -F: '{printf "%s\0", $1}' > "$NNN_PIPE"
ARTIST="$(echo "$out" | grep 'Artist:' | cut -d':' -f2 | sed 's/^[[:blank:]]*//;s/[[:blank:]]*$//')"
TITLE="$(echo "$out" | grep 'SongTitle:' | cut -d':' -f2 | sed 's/^[[:blank:]]*//;s/[[:blank:]]*$//')"
-if ! [ -z "$ARTIST" ] && ! [ -z "$TITLE" ]; then
+if [ -n "$ARTIST" ] && [ -n "$TITLE" ]; then
ddgr -w azlyrics.com --ducky "$ARTIST" "$TITLE"
else
# Try by file name
FILENAME="$(basename "$(echo "$out" | grep 'File:' | cut -d':' -f2)")"
FILENAME="$(echo "${FILENAME%%.*}" | tr -d -)"
- if ! [ -z "$FILENAME" ]; then
+ if [ -n "$FILENAME" ]; then
ddgr -w azlyrics.com --ducky "$FILENAME"
fi
fi
printf "%s" "$prompt"
read -r dev
-while ! [ -z "$dev" ]
+while [ -n "$dev" ]
do
if [ "$dev" = "l" ]; then
lsblk
# Shell: POSIX compliant
# Author: Arun Prakash Jana
-if ! [ -z "$1" ]; then
+if [ -n "$1" ]; then
tmpf="$(basename "$1")"
tmpf="${TMPDIR:-/tmp}"/"${tmpf%.*}"
# Shell: POSIX compliant
# Author: Arun Prakash Jana
-if ! [ -z "$1" ]; then
+if [ -n "$1" ]; then
if [ "$(head -c 4 "$1")" = "%PDF" ]; then
# Convert using pdftotext
pdftotext -nopgbrk -layout "$1" - | sed 's/\xe2\x80\x8b//g' | $PAGER
read -r psname
# shellcheck disable=SC2009
-if ! [ -z "$psname" ]; then
+if [ -n "$psname" ]; then
if which sudo >/dev/null 2>&1; then
sucmd=sudo
elif which doas >/dev/null 2>&1; then
# Shell: POSIX compliant
# Author: Arun Prakash Jana
-if ! [ -z "$1" ] && [ -s "$1" ]; then
+if [ -n "$1" ] && [ -s "$1" ]; then
if which ffsend >/dev/null 2>&1; then
ffsend -iq u "$1"
elif [ "$(mimetype --output-format %m "$1" | awk -F '/' '{print $1}')" = "text" ]; then
echo $?
}
-if ! [ -z "$1" ]; then
+if [ -n "$1" ]; then
if [ "$(mimetype --output-format %m "$1" | awk -F '/' '{print $1}')" = "image" ]; then
if [ "$(cmd_exists nitrogen)" -eq "0" ]; then
nitrogen --set-zoom-fill --save "$1"