mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 03:41:27 +00:00
shellcheck fixes
This commit is contained in:
parent
63315c88d2
commit
a7fd4957dd
|
@ -70,7 +70,7 @@ jobs:
|
||||||
echo "########## clang-tidy-10 ##########"
|
echo "########## clang-tidy-10 ##########"
|
||||||
clang-tidy-10 src/* -- -I/usr/include -I/usr/include/ncursesw
|
clang-tidy-10 src/* -- -I/usr/include -I/usr/include/ncursesw
|
||||||
echo "########## shellcheck ##########"
|
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:
|
package-and-publish:
|
||||||
machine: true
|
machine: true
|
||||||
|
|
|
@ -41,7 +41,7 @@ Plugins extend the capabilities of `nnn`. They are _executable_ scripts (or bina
|
||||||
| [kdeconnect](kdeconnect) | Send selected files to an Android device | sh | kdeconnect-cli |
|
| [kdeconnect](kdeconnect) | 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 | 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/) |
|
| [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) | 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 |
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
GUIPLAYER="${GUIPLAYER}"
|
GUIPLAYER="${GUIPLAYER}"
|
||||||
NUMTRACKS="${NUMTRACKS:-100}"
|
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 &
|
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
|
# detach the player
|
||||||
|
|
|
@ -41,7 +41,7 @@ if [ -s "$selection" ]; then
|
||||||
|
|
||||||
eval xargs -0 "$diffcmd" < "$selection"
|
eval xargs -0 "$diffcmd" < "$selection"
|
||||||
fi
|
fi
|
||||||
elif ! [ -z "$1" ]; then
|
elif [ -n "$1" ]; then
|
||||||
f1="$(echo "$arr" | sed -n '1p')"
|
f1="$(echo "$arr" | sed -n '1p')"
|
||||||
if [ -d "$f1" ] && [ -d "$1" ]; then
|
if [ -d "$f1" ] && [ -d "$1" ]; then
|
||||||
dirdiff "$f1" "$1"
|
dirdiff "$f1" "$1"
|
||||||
|
|
|
@ -22,7 +22,7 @@ printf " fzf -m | tr %s %s\n\n" "'\n'" "'\0'"
|
||||||
printf "cmd: "
|
printf "cmd: "
|
||||||
read -r cmd
|
read -r cmd
|
||||||
|
|
||||||
if ! [ -z "$cmd" ]; then
|
if [ -n "$cmd" ]; then
|
||||||
printf "%s" "+l" > "$NNN_PIPE"
|
printf "%s" "+l" > "$NNN_PIPE"
|
||||||
eval "$cmd" > "$NNN_PIPE"
|
eval "$cmd" > "$NNN_PIPE"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -22,7 +22,7 @@ elif [ "$shellname" = "fish" ]; then
|
||||||
entry="$(grep "\- cmd: " "$hist_file" | cut -c 8- | "$fuzzy")"
|
entry="$(grep "\- cmd: " "$hist_file" | cut -c 8- | "$fuzzy")"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! [ -z "$entry" ]; then
|
if [ -n "$entry" ]; then
|
||||||
tmpfile=$(mktemp)
|
tmpfile=$(mktemp)
|
||||||
echo "$entry" >> "$tmpfile"
|
echo "$entry" >> "$tmpfile"
|
||||||
$EDITOR "$tmpfile"
|
$EDITOR "$tmpfile"
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
# Shell: POSIX compliant
|
# Shell: POSIX compliant
|
||||||
# Author: Arun Prakash Jana
|
# Author: Arun Prakash Jana
|
||||||
|
|
||||||
if ! [ -z "$1" ]; then
|
if [ -n "$1" ]; then
|
||||||
if which hx >/dev/null 2>&1; then
|
if which hx >/dev/null 2>&1; then
|
||||||
hx "$1"
|
hx "$1"
|
||||||
else
|
else
|
||||||
|
|
|
@ -25,6 +25,6 @@ if [ -z "$res" ]; then
|
||||||
read -r res
|
read -r res
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! [ -z "$res" ] && ! [ -z "$MINSIZE" ]; then
|
if [ -n "$res" ] && [ -n "$MINSIZE" ]; then
|
||||||
imgp -ackx "$res" -s "$MINSIZE"
|
imgp -ackx "$res" -s "$MINSIZE"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
# Shell: POSIX compliant
|
# Shell: POSIX compliant
|
||||||
# Author: Arun Prakash Jana
|
# Author: Arun Prakash Jana
|
||||||
|
|
||||||
if ! [ -z "$1" ]; then
|
if [ -n "$1" ]; then
|
||||||
if [ -d "$1" ]; then
|
if [ -d "$1" ]; then
|
||||||
lsix "$1"/*
|
lsix "$1"/*
|
||||||
else
|
else
|
||||||
|
|
|
@ -172,8 +172,8 @@ function take_screenshot() {
|
||||||
function check_for_update() {
|
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
|
# 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)"
|
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 [ -n "$remote_version" ]; then
|
||||||
if [ ! "${current_version}" = "${remote_version}" ] && [ ! -z "${current_version}" ] && [ ! -z "${remote_version}" ]; then
|
if [ ! "${current_version}" = "${remote_version}" ] && [ -n "${current_version}" ] && [ -n "${remote_version}" ]; then
|
||||||
echo "Update found!"
|
echo "Update found!"
|
||||||
echo "Version ${remote_version} is available (You have ${current_version})"
|
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"
|
notify ok "Update found" "Version ${remote_version} is available (You have ${current_version}). https://github.com/jomo/imgur-screenshot"
|
||||||
|
@ -209,7 +209,7 @@ function load_access_token() {
|
||||||
current_time="$(date +%s)"
|
current_time="$(date +%s)"
|
||||||
preemptive_refresh_time="$((10*60))"
|
preemptive_refresh_time="$((10*60))"
|
||||||
expired="$((current_time > (token_expire_time - preemptive_refresh_time)))"
|
expired="$((current_time > (token_expire_time - preemptive_refresh_time)))"
|
||||||
if [ ! -z "${refresh_token}" ]; then
|
if [ -n "${refresh_token}" ]; then
|
||||||
# token already set
|
# token already set
|
||||||
if [ "${expired}" -eq "0" ]; then
|
if [ "${expired}" -eq "0" ]; then
|
||||||
# token expired
|
# token expired
|
||||||
|
@ -320,7 +320,7 @@ function upload_authenticated_image() {
|
||||||
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!
|
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)"
|
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
|
export -f delete_image
|
||||||
echo "Deleting image in ${auto_delete} seconds."
|
echo "Deleting image in ${auto_delete} seconds."
|
||||||
nohup /bin/bash -c "sleep ${auto_delete} && delete_image ${imgur_anon_id} ${del_id} ${log_file}" &
|
nohup /bin/bash -c "sleep ${auto_delete} && delete_image ${imgur_anon_id} ${del_id} ${log_file}" &
|
||||||
|
@ -348,7 +348,7 @@ function upload_anonymous_image() {
|
||||||
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!
|
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)"
|
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
|
export -f delete_image
|
||||||
echo "Deleting image in ${auto_delete} seconds."
|
echo "Deleting image in ${auto_delete} seconds."
|
||||||
nohup /bin/bash -c "sleep ${auto_delete} && delete_image ${imgur_anon_id} ${del_id} ${log_file}" &
|
nohup /bin/bash -c "sleep ${auto_delete} && delete_image ${imgur_anon_id} ${del_id} ${log_file}" &
|
||||||
|
|
|
@ -34,7 +34,7 @@ get_selection() {
|
||||||
if selection=$( get_selection ); then
|
if selection=$( get_selection ); then
|
||||||
setsid "$selection" 2>/dev/null 1>/dev/null &
|
setsid "$selection" 2>/dev/null 1>/dev/null &
|
||||||
|
|
||||||
if ! [ -z "$1" ]; then
|
if [ -n "$1" ]; then
|
||||||
sleep "$1"
|
sleep "$1"
|
||||||
else
|
else
|
||||||
sleep 1
|
sleep 1
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
# Shell: POSIX compliant
|
# Shell: POSIX compliant
|
||||||
# Author: Arun Prakash Jana
|
# Author: Arun Prakash Jana
|
||||||
|
|
||||||
if ! [ -z "$1" ] && [ -f "$1" ]; then
|
if [ -n "$1" ] && [ -f "$1" ]; then
|
||||||
mediainfo "$1" | $PAGER
|
mediainfo "$1" | $PAGER
|
||||||
# exiftool "$1" | $PAGER
|
# exiftool "$1" | $PAGER
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -1,21 +1,14 @@
|
||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
# Description: Run fd/find in subtree and list files by mime type in smart context
|
# Description: Find and list files by mime type in smart context
|
||||||
# Dependencies: fd/find
|
|
||||||
#
|
#
|
||||||
# Shell: POSIX compliant
|
# Shell: POSIX compliant
|
||||||
# Author: Arun Prakash Jana
|
# Author: Arun Prakash Jana
|
||||||
|
|
||||||
. "$(dirname "$0")"/.nnn-plugin-helper
|
. "$(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): "
|
printf "mime (e.g., video/audio/image): "
|
||||||
read -r mime
|
read -r mime
|
||||||
|
|
||||||
printf "%s" "+l" > "$NNN_PIPE"
|
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"
|
||||||
|
|
|
@ -26,14 +26,14 @@ fi
|
||||||
ARTIST="$(echo "$out" | grep 'Artist:' | cut -d':' -f2 | sed 's/^[[:blank:]]*//;s/[[:blank:]]*$//')"
|
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:]]*$//')"
|
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"
|
ddgr -w azlyrics.com --ducky "$ARTIST" "$TITLE"
|
||||||
else
|
else
|
||||||
# Try by file name
|
# Try by file name
|
||||||
FILENAME="$(basename "$(echo "$out" | grep 'File:' | cut -d':' -f2)")"
|
FILENAME="$(basename "$(echo "$out" | grep 'File:' | cut -d':' -f2)")"
|
||||||
FILENAME="$(echo "${FILENAME%%.*}" | tr -d -)"
|
FILENAME="$(echo "${FILENAME%%.*}" | tr -d -)"
|
||||||
|
|
||||||
if ! [ -z "$FILENAME" ]; then
|
if [ -n "$FILENAME" ]; then
|
||||||
ddgr -w azlyrics.com --ducky "$FILENAME"
|
ddgr -w azlyrics.com --ducky "$FILENAME"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -24,7 +24,7 @@ printf "\nEnsure you aren't still in the mounted device.\n"
|
||||||
printf "%s" "$prompt"
|
printf "%s" "$prompt"
|
||||||
read -r dev
|
read -r dev
|
||||||
|
|
||||||
while ! [ -z "$dev" ]
|
while [ -n "$dev" ]
|
||||||
do
|
do
|
||||||
if [ "$dev" = "l" ]; then
|
if [ "$dev" = "l" ]; then
|
||||||
lsblk
|
lsblk
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
# Shell: POSIX compliant
|
# Shell: POSIX compliant
|
||||||
# Author: Arun Prakash Jana
|
# Author: Arun Prakash Jana
|
||||||
|
|
||||||
if ! [ -z "$1" ]; then
|
if [ -n "$1" ]; then
|
||||||
tmpf="$(basename "$1")"
|
tmpf="$(basename "$1")"
|
||||||
tmpf="${TMPDIR:-/tmp}"/"${tmpf%.*}"
|
tmpf="${TMPDIR:-/tmp}"/"${tmpf%.*}"
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
# Shell: POSIX compliant
|
# Shell: POSIX compliant
|
||||||
# Author: Arun Prakash Jana
|
# Author: Arun Prakash Jana
|
||||||
|
|
||||||
if ! [ -z "$1" ]; then
|
if [ -n "$1" ]; then
|
||||||
if [ "$(head -c 4 "$1")" = "%PDF" ]; then
|
if [ "$(head -c 4 "$1")" = "%PDF" ]; then
|
||||||
# Convert using pdftotext
|
# Convert using pdftotext
|
||||||
pdftotext -nopgbrk -layout "$1" - | sed 's/\xe2\x80\x8b//g' | $PAGER
|
pdftotext -nopgbrk -layout "$1" - | sed 's/\xe2\x80\x8b//g' | $PAGER
|
||||||
|
|
|
@ -13,7 +13,7 @@ printf "Enter process name ['defunct' for zombies]: "
|
||||||
read -r psname
|
read -r psname
|
||||||
|
|
||||||
# shellcheck disable=SC2009
|
# shellcheck disable=SC2009
|
||||||
if ! [ -z "$psname" ]; then
|
if [ -n "$psname" ]; then
|
||||||
if which sudo >/dev/null 2>&1; then
|
if which sudo >/dev/null 2>&1; then
|
||||||
sucmd=sudo
|
sucmd=sudo
|
||||||
elif which doas >/dev/null 2>&1; then
|
elif which doas >/dev/null 2>&1; then
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
# Shell: POSIX compliant
|
# Shell: POSIX compliant
|
||||||
# Author: Arun Prakash Jana
|
# Author: Arun Prakash Jana
|
||||||
|
|
||||||
if ! [ -z "$1" ] && [ -s "$1" ]; then
|
if [ -n "$1" ] && [ -s "$1" ]; then
|
||||||
if which ffsend >/dev/null 2>&1; then
|
if which ffsend >/dev/null 2>&1; then
|
||||||
ffsend -iq u "$1"
|
ffsend -iq u "$1"
|
||||||
elif [ "$(mimetype --output-format %m "$1" | awk -F '/' '{print $1}')" = "text" ]; then
|
elif [ "$(mimetype --output-format %m "$1" | awk -F '/' '{print $1}')" = "text" ]; then
|
||||||
|
|
|
@ -11,7 +11,7 @@ cmd_exists () {
|
||||||
echo $?
|
echo $?
|
||||||
}
|
}
|
||||||
|
|
||||||
if ! [ -z "$1" ]; then
|
if [ -n "$1" ]; then
|
||||||
if [ "$(mimetype --output-format %m "$1" | awk -F '/' '{print $1}')" = "image" ]; then
|
if [ "$(mimetype --output-format %m "$1" | awk -F '/' '{print $1}')" = "image" ]; then
|
||||||
if [ "$(cmd_exists nitrogen)" -eq "0" ]; then
|
if [ "$(cmd_exists nitrogen)" -eq "0" ]; then
|
||||||
nitrogen --set-zoom-fill --save "$1"
|
nitrogen --set-zoom-fill --save "$1"
|
||||||
|
|
Loading…
Reference in a new issue