@@ -5,7 +5,8 @@ | |||||
# Arun Prakash Jana <engineerarun@gmail.com> | # Arun Prakash Jana <engineerarun@gmail.com> | ||||
# | # | ||||
_nnn () { | |||||
_nnn () | |||||
{ | |||||
COMPREPLY=() | COMPREPLY=() | ||||
local IFS=$' \n' | local IFS=$' \n' | ||||
local cur=$2 prev=$3 | local cur=$2 prev=$3 | ||||
@@ -36,7 +37,7 @@ _nnn () { | |||||
COMPREPLY=( $(compgen -f -d -- "$cur") ) | COMPREPLY=( $(compgen -f -d -- "$cur") ) | ||||
elif [[ $prev == -e ]]; then | elif [[ $prev == -e ]]; then | ||||
local sessions_dir=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/sessions | local sessions_dir=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/sessions | ||||
COMPREPLY=( $(compgen -W "$(ls $sessions_dir)" -- "$cur") ) | |||||
COMPREPLY=( $(compgen -W "$(ls "$sessions_dir")" -- "$cur") ) | |||||
elif [[ $cur == -* ]]; then | elif [[ $cur == -* ]]; then | ||||
COMPREPLY=( $(compgen -W "${opts[*]}" -- "$cur") ) | COMPREPLY=( $(compgen -W "${opts[*]}" -- "$cur") ) | ||||
else | else | ||||
@@ -1,24 +1,24 @@ | |||||
n() | |||||
n () | |||||
{ | { | ||||
# Block nesting of nnn in subshells | # Block nesting of nnn in subshells | ||||
if [ $(expr $NNNLVL + 0) -ge 1 ]; then | |||||
if [ "$((NNNLVL + 0))" -ge 1 ]; then | |||||
echo "nnn is already running" | echo "nnn is already running" | ||||
return | return | ||||
fi | fi | ||||
# The default behaviour is to cd on quit (nnn checks if NNN_TMPFILE is set) | |||||
# To cd on quit only on ^G, export NNN_TMPFILE after the call to nnn | |||||
export NNN_TMPFILE=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.lastd | |||||
# Unmask ^Q (, ^V etc.) (if required, see `stty -a`) to Quit nnn | # Unmask ^Q (, ^V etc.) (if required, see `stty -a`) to Quit nnn | ||||
# stty start undef | # stty start undef | ||||
# stty stop undef | # stty stop undef | ||||
# stty lwrap undef | # stty lwrap undef | ||||
# The default behaviour is to cd on quit (nnn checks if NNN_TMPFILE is set) | |||||
# To cd on quit only on ^G, export NNN_TMPFILE after the call to nnn | |||||
export NNN_TMPFILE=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.lastd | |||||
nnn "$@" | nnn "$@" | ||||
if [ -f $NNN_TMPFILE ]; then | |||||
. $NNN_TMPFILE | |||||
rm -f $NNN_TMPFILE > /dev/null | |||||
if [ -f "$NNN_TMPFILE" ]; then | |||||
. "$NNN_TMPFILE" | |||||
rm -f "$NNN_TMPFILE" > /dev/null | |||||
fi | fi | ||||
} | } |
@@ -1,7 +1,7 @@ | |||||
n() | |||||
n () | |||||
{ | { | ||||
# Block nesting of nnn in subshells | # Block nesting of nnn in subshells | ||||
if [ $(expr $NNNLVL + 0) -ge 1 ]; then | |||||
if [ "$((NNNLVL + 0))" -ge 1 ]; then | |||||
echo "nnn is already running" | echo "nnn is already running" | ||||
return | return | ||||
fi | fi | ||||
@@ -17,8 +17,8 @@ n() | |||||
nnn "$@" | nnn "$@" | ||||
if [ -f $NNN_TMPFILE ]; then | |||||
. $NNN_TMPFILE | |||||
rm $NNN_TMPFILE | |||||
if [ -f "$NNN_TMPFILE" ]; then | |||||
. "$NNN_TMPFILE" | |||||
rm -f "$NNN_TMPFILE" > /dev/null | |||||
fi | fi | ||||
} | } |
@@ -7,7 +7,7 @@ test -e outdir && { | |||||
exit 1 | exit 1 | ||||
} | } | ||||
mkdir -p outdir && cd outdir | |||||
mkdir -p outdir && cd outdir || exit 1 | |||||
echo 'It works!' > normal.txt | echo 'It works!' > normal.txt | ||||
echo 'Με δουλέβει;' > 'κοινό.txt' | echo 'Με δουλέβει;' > 'κοινό.txt' | ||||
@@ -6,6 +6,7 @@ | |||||
# Author: Anna Arad | # Author: Anna Arad | ||||
selection=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection | selection=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection | ||||
export selection | |||||
## Ask nnn to switch to directory $1 in context $2. | ## Ask nnn to switch to directory $1 in context $2. | ||||
## If $2 is not provided, the function asks explicitly. | ## If $2 is not provided, the function asks explicitly. | ||||
@@ -20,11 +21,11 @@ nnn_cd () { | |||||
if [ -n "$2" ]; then | if [ -n "$2" ]; then | ||||
context=$2 | context=$2 | ||||
else | else | ||||
echo -n "Choose context 1-4 (blank for current): " | |||||
read context | |||||
printf "Choose context 1-4 (blank for current): " | |||||
read -r context | |||||
fi | fi | ||||
echo -n ${context:-0}$dir > $NNN_PIPE | |||||
printf "%s" "${context:-0}$dir" > "$NNN_PIPE" | |||||
} | } | ||||
cmd_exists () { | cmd_exists () { | ||||
@@ -15,7 +15,7 @@ if [ ! -z "$GUIPLAYER" ]; then | |||||
find . -type f \( -iname "*.mp3" -o -iname "*.flac" -o -iname "*.webm" -o -iname "*.wma" \) | sort -R | head -n $NUMTRACKS | xargs -d "\n" "$PLAYER" > /dev/null 2>&1 & | find . -type f \( -iname "*.mp3" -o -iname "*.flac" -o -iname "*.webm" -o -iname "*.wma" \) | sort -R | head -n $NUMTRACKS | xargs -d "\n" "$PLAYER" > /dev/null 2>&1 & | ||||
# detach the player | # detach the player | ||||
disown | |||||
sleep 1 | |||||
else | else | ||||
# start MOC server | # start MOC server | ||||
mocp -S | mocp -S | ||||
@@ -21,8 +21,8 @@ chsum=md5 | |||||
checksum_type() | checksum_type() | ||||
{ | { | ||||
echo "possible checksums: md5, sha1, sha224, sha256, sha384, sha512" | echo "possible checksums: md5, sha1, sha224, sha256, sha384, sha512" | ||||
echo -n "create md5 (m), sha256 (s), sha512 (S) (or type one of the above checksums) [default=m]: " | |||||
read chsum_resp | |||||
printf "create md5 (m), sha256 (s), sha512 (S) (or type one of the above checksums) [default=m]: " | |||||
read -r chsum_resp | |||||
for chks in md5 sha1 sha224 sha256 sha384 sha512 | for chks in md5 sha1 sha224 sha256 sha384 sha512 | ||||
do | do | ||||
if [ "$chsum_resp" = "$chks" ]; then | if [ "$chsum_resp" = "$chks" ]; then | ||||
@@ -38,8 +38,8 @@ checksum_type() | |||||
} | } | ||||
if [ -s "$selection" ]; then | if [ -s "$selection" ]; then | ||||
echo -n "work with selection (s) or current file (f) [default=f]: " | |||||
read resp | |||||
printf "work with selection (s) or current file (f) [default=f]: " | |||||
read -r resp | |||||
fi | fi | ||||
if [ "$resp" = "s" ]; then | if [ "$resp" = "s" ]; then | ||||
@@ -49,10 +49,10 @@ 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 | ||||
do | do | ||||
if [ "$(echo "$1" | grep \.${chks}$)" ]; then | |||||
if echo "$1" | grep -q \.${chks}$; then | |||||
${chks}sum -c < "$1" | ${chks}sum -c < "$1" | ||||
read dummy | |||||
exit | |||||
read -r _ | |||||
return | |||||
fi | fi | ||||
done | done | ||||
checksum_type | checksum_type | ||||
@@ -16,21 +16,22 @@ | |||||
selection=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection | selection=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection | ||||
resp=f | resp=f | ||||
all= | all= | ||||
if which dragon-drag-and-drop 2>&1 >/dev/null; then | |||||
if which dragon-drag-and-drop >/dev/null 2>&1; then | |||||
dnd="dragon-drag-and-drop" | dnd="dragon-drag-and-drop" | ||||
else | else | ||||
dnd="dragon" | dnd="dragon" | ||||
fi | fi | ||||
function add_file() { | |||||
echo -n "$@" >> "$selection" | |||||
echo -ne "\0" >> "$selection" | |||||
add_file () | |||||
{ | |||||
printf "%s" "$@" >> "$selection" | |||||
printf "\0" >> "$selection" | |||||
} | } | ||||
function use_all() | |||||
use_all () | |||||
{ | { | ||||
echo -n "mark --all (a) [default=none]: " | |||||
read resp | |||||
printf "mark --all (a) [default=none]: " | |||||
read -r resp | |||||
if [ "$resp" = "a" ]; then | if [ "$resp" = "a" ]; then | ||||
all="--all" | all="--all" | ||||
else | else | ||||
@@ -39,11 +40,11 @@ function use_all() | |||||
} | } | ||||
if [ -s "$selection" ]; then | if [ -s "$selection" ]; then | ||||
echo -n "Drop file (r). Drag selection (s), Drag current directory (d) or drag current file (f) [default=f]: " | |||||
read resp | |||||
printf "Drop file (r). Drag selection (s), Drag current directory (d) or drag current file (f) [default=f]: " | |||||
read -r resp | |||||
else | else | ||||
echo -n "Drop file (r). Drag current directory (d) or drag current file (f) [default=f]: " | |||||
read resp | |||||
printf "Drop file (r). Drag current directory (d) or drag current file (f) [default=f]: " | |||||
read -r resp | |||||
if [ "$resp" = "s" ]; then | if [ "$resp" = "s" ]; then | ||||
resp=f | resp=f | ||||
fi | fi | ||||
@@ -56,10 +57,10 @@ elif [ "$resp" = "d" ]; then | |||||
use_all | use_all | ||||
"$dnd" "$all" "$PWD/"* & | "$dnd" "$all" "$PWD/"* & | ||||
elif [ "$resp" = "r" ]; then | elif [ "$resp" = "r" ]; then | ||||
echo -n > "$selection" | |||||
"$dnd" --print-path --target | while read f | |||||
printf > "$selection" | |||||
"$dnd" --print-path --target | while read -r f | |||||
do | do | ||||
if echo -n "$f" | grep '^\(https\?\|ftps\?\|s\?ftp\):\/\/' ; then | |||||
if printf "%s" "$f" | grep '^\(https\?\|ftps\?\|s\?ftp\):\/\/' ; then | |||||
curl -LJO "$f" | curl -LJO "$f" | ||||
add_file "$PWD/$(basename "$f")" | add_file "$PWD/$(basename "$f")" | ||||
elif [ -e "$f" ]; then | elif [ -e "$f" ]; then | ||||
@@ -9,7 +9,7 @@ | |||||
# Shell: POSIX compliant | # Shell: POSIX compliant | ||||
# Author: syssyphus | # Author: syssyphus | ||||
find -size +0 -type f -printf "%s\n" | sort -rn | uniq -d | xargs -I{} -n1 find -type f -size {}c -print0 | xargs -0 md5sum | sort | uniq -w32 --all-repeated=separate | |||||
find . -size +0 -type f -printf "%s\n" | sort -rn | uniq -d | xargs -I{} -n1 find -type f -size {}c -print0 | xargs -0 md5sum | sort | uniq -w32 --all-repeated=separate | |||||
echo "Press any key to exit" | |||||
read dummy | |||||
printf "Press any key to exit" | |||||
read -r _ |
@@ -5,7 +5,7 @@ | |||||
# Shell: POSIX compliant | # Shell: POSIX compliant | ||||
# Author: Anna Arad | # Author: Anna Arad | ||||
. $(dirname $0)/.nnn-plugin-helper | |||||
. "$(dirname "$0")"/.nnn-plugin-helper | |||||
if [ "$(cmd_exists fzy)" -eq "0" ]; then | if [ "$(cmd_exists fzy)" -eq "0" ]; then | ||||
if [ "$(cmd_exists fd)" -eq "0" ]; then | if [ "$(cmd_exists fd)" -eq "0" ]; then | ||||
@@ -23,7 +23,7 @@ else | |||||
exit 1 | exit 1 | ||||
fi | fi | ||||
if [ "$?" -eq "0" ]; then | |||||
if ! [ -z "$sel" ]; then | |||||
case "$(file -bi "$sel")" in | case "$(file -bi "$sel")" in | ||||
*directory*) ;; | *directory*) ;; | ||||
*) sel=$(dirname "$sel") ;; | *) sel=$(dirname "$sel") ;; | ||||
@@ -18,15 +18,15 @@ fi | |||||
if ! [ -z "$entry" ]; then | if ! [ -z "$entry" ]; then | ||||
tmpfile=$(mktemp) | tmpfile=$(mktemp) | ||||
echo "$entry" >> $tmpfile | |||||
$EDITOR $tmpfile | |||||
echo "$entry" >> "$tmpfile" | |||||
$EDITOR "$tmpfile" | |||||
if [ -s $tmpfile ]; then | |||||
$SHELL -c "$(cat $tmpfile)" | |||||
if [ -s "$tmpfile" ]; then | |||||
$SHELL -c "$(cat "$tmpfile")" | |||||
fi | fi | ||||
rm $tmpfile | |||||
rm "$tmpfile" | |||||
echo -n "Press any key to exit" | |||||
read input | |||||
printf "Press any key to exit" | |||||
read -r _ | |||||
fi | fi |
@@ -7,7 +7,7 @@ | |||||
# Shell: POSIX compliant | # Shell: POSIX compliant | ||||
# Author: Arun Prakash Jana | # Author: Arun Prakash Jana | ||||
entry="$(find -type f 2>/dev/null | fzy)" | |||||
entry="$(find . -type f 2>/dev/null | fzy)" | |||||
case "$(file -biL "$entry")" in | case "$(file -biL "$entry")" in | ||||
*text*) | *text*) | ||||
@@ -14,13 +14,13 @@ is_cmd_exists () { | |||||
} | } | ||||
merge () { | merge () { | ||||
vimdiff $1 $2 | |||||
vimdiff "$1" "$2" | |||||
} | } | ||||
prompt () { | prompt () { | ||||
echo "Plugin $1 already exists and is different." | |||||
echo -n "Keep (k), merge (m), overwrite (o) [default: k]? " | |||||
read operation | |||||
printf "%s" "Plugin $1 already exists and is different.\n" | |||||
printf "Keep (k), merge (m), overwrite (o) [default: k]? " | |||||
read -r operation | |||||
if [ "$operation" = "m" ]; then | if [ "$operation" = "m" ]; then | ||||
op="merge" | op="merge" | ||||
@@ -40,27 +40,27 @@ else | |||||
fi | fi | ||||
# backup any earlier plugins | # backup any earlier plugins | ||||
if [ -d $PLUGIN_DIR ]; then | |||||
tar -C $CONFIG_DIR -czf $CONFIG_DIR"plugins-$(date '+%Y%m%d%H%M').tar.gz" plugins/ | |||||
if [ -d "$PLUGIN_DIR" ]; then | |||||
tar -C "$CONFIG_DIR" -czf "$CONFIG_DIR""plugins-$(date '+%Y%m%d%H%M').tar.gz" plugins/ | |||||
fi | fi | ||||
mkdir -p $PLUGIN_DIR | |||||
cd $CONFIG_DIR | |||||
mkdir -p "$PLUGIN_DIR" | |||||
cd "$CONFIG_DIR" || exit 1 | |||||
curl -Ls -O https://github.com/jarun/nnn/archive/master.tar.gz | curl -Ls -O https://github.com/jarun/nnn/archive/master.tar.gz | ||||
tar -zxf master.tar.gz | tar -zxf master.tar.gz | ||||
cd nnn-master/plugins | |||||
cd nnn-master/plugins || exit 1 | |||||
for f in *; do | for f in *; do | ||||
if [ -f ../../plugins/$f ]; then | |||||
if [ "$(diff --brief $f ../../plugins/$f)" ]; then | |||||
prompt $f | |||||
$op $f ../../plugins/ | |||||
if [ -f ../../plugins/"$f" ]; then | |||||
if [ "$(diff --brief "$f" ../../plugins/"$f")" ]; then | |||||
prompt "$f" | |||||
$op "$f" ../../plugins/ | |||||
fi | fi | ||||
else | else | ||||
cp -vRf $f ../../plugins/ | |||||
cp -vRf "$f" ../../plugins/ | |||||
fi | fi | ||||
done | done | ||||
cd ../.. | |||||
cd ../.. || exit 1 | |||||
$sucmd mv -vf nnn-master/misc/nlaunch/nlaunch /usr/local/bin/ | $sucmd mv -vf nnn-master/misc/nlaunch/nlaunch /usr/local/bin/ | ||||
rm -rf nnn-master/ master.tar.gz $PLUGIN_DIR/README.md | |||||
rm -rf nnn-master/ master.tar.gz "$PLUGIN_DIR"/README.md |
@@ -25,25 +25,25 @@ BROWSER=w3m | |||||
READER= | READER= | ||||
if [ ! -z "$EBOOK_ID" ]; then | if [ ! -z "$EBOOK_ID" ]; then | ||||
if [ ! -e $DIR ]; then | |||||
mkdir -p $DIR | |||||
cd $DIR | |||||
if [ ! -e "$DIR" ]; then | |||||
mkdir -p "$DIR" | |||||
cd "$DIR" || exit 1 | |||||
if [ -z "$READER" ]; then | if [ -z "$READER" ]; then | ||||
curl -L -O "https://www.gutenberg.org/files/"$EBOOK_ID"/"$EBOOK_ID"-h.zip" | |||||
curl -L -O https://www.gutenberg.org/files/"$EBOOK_ID"/"$EBOOK_ID"-h.zip | |||||
unzip "$EBOOK_ID"-h.zip | unzip "$EBOOK_ID"-h.zip | ||||
else | else | ||||
curl -L -o "$EBOOK_ID".epub "http://www.gutenberg.org/ebooks/"$EBOOK_ID".epub.noimages" | |||||
curl -L -o "$EBOOK_ID".epub http://www.gutenberg.org/ebooks/"$EBOOK_ID".epub.noimages | |||||
fi | fi | ||||
fi | fi | ||||
if [ -d $DIR ]; then | |||||
if [ -d "$DIR" ]; then | |||||
if [ -z "$READER" ]; then | if [ -z "$READER" ]; then | ||||
"$BROWSER" $DIR/"$EBOOK_ID"-h/"$EBOOK_ID"-h.htm | |||||
"$BROWSER" "$DIR"/"$EBOOK_ID"-h/"$EBOOK_ID"-h.htm | |||||
else | else | ||||
"$READER" $DIR/"$EBOOK_ID".epub | |||||
"$READER" "$DIR"/"$EBOOK_ID".epub | |||||
fi | fi | ||||
fi | fi | ||||
else | else | ||||
"$BROWSER" $BROWSE_LINK | |||||
"$BROWSER" "$BROWSE_LINK" | |||||
fi | fi |
@@ -21,8 +21,8 @@ res= | |||||
minsize=1048576 | minsize=1048576 | ||||
if [ -z "$res" ]; then | if [ -z "$res" ]; then | ||||
echo -n "desktop resolution (hxv): " | |||||
read res | |||||
printf "desktop resolution (hxv): " | |||||
read -r res | |||||
fi | fi | ||||
if ! [ -z "$res" ] && ! [ -z "$minsize" ]; then | if ! [ -z "$res" ] && ! [ -z "$minsize" ]; then | ||||
@@ -78,14 +78,22 @@ upload_timeout="120" | |||||
upload_retries="1" | upload_retries="1" | ||||
if is_mac; then | if is_mac; then | ||||
# shellcheck disable=SC2034 | |||||
screenshot_select_command="screencapture -i %img" | screenshot_select_command="screencapture -i %img" | ||||
# shellcheck disable=SC2034 | |||||
screenshot_window_command="screencapture -iWa %img" | screenshot_window_command="screencapture -iWa %img" | ||||
# shellcheck disable=SC2034 | |||||
screenshot_full_command="screencapture %img" | screenshot_full_command="screencapture %img" | ||||
# shellcheck disable=SC2034 | |||||
open_command="open %url" | open_command="open %url" | ||||
else | else | ||||
# shellcheck disable=SC2034 | |||||
screenshot_select_command="scrot -s %img" | screenshot_select_command="scrot -s %img" | ||||
# shellcheck disable=SC2034 | |||||
screenshot_window_command="scrot %img" | screenshot_window_command="scrot %img" | ||||
# shellcheck disable=SC2034 | |||||
screenshot_full_command="scrot %img" | screenshot_full_command="scrot %img" | ||||
# shellcheck disable=SC2034 | |||||
open_command="xdg-open %url" | open_command="xdg-open %url" | ||||
fi | fi | ||||
open="true" | open="true" | ||||
@@ -162,7 +170,7 @@ function take_screenshot() { | |||||
cmd=${!cmd//\%img/${1}} | cmd=${!cmd//\%img/${1}} | ||||
shot_err="$(${cmd} &>/dev/null)" #takes a screenshot with selection | shot_err="$(${cmd} &>/dev/null)" #takes a screenshot with selection | ||||
if [ "${?}" != "0" ]; then | |||||
if ! [ -z "$shot_err" ]; then | |||||
echo "Failed to take screenshot '${1}': '${shot_err}'. For more information visit https://github.com/jomo/imgur-screenshot/wiki/Troubleshooting" | tee -a "${log_file}" | echo "Failed to take screenshot '${1}': '${shot_err}'. For more information visit https://github.com/jomo/imgur-screenshot/wiki/Troubleshooting" | tee -a "${log_file}" | ||||
notify error "Something went wrong :(" "Information has been logged" | notify error "Something went wrong :(" "Information has been logged" | ||||
exit 1 | exit 1 | ||||
@@ -171,8 +179,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" | egrep -m 1 --color 'tag_name":\s*".*"' | cut -d '"' -f 4)" | |||||
if [ "${?}" -eq "0" ]; then | |||||
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 [ ! "${current_version}" = "${remote_version}" ] && [ ! -z "${current_version}" ] && [ ! -z "${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})" | ||||
@@ -249,7 +257,7 @@ function refresh_access_token() { | |||||
token_url="https://api.imgur.com/oauth2/token" | token_url="https://api.imgur.com/oauth2/token" | ||||
# exchange the refresh token for access_token and refresh_token | # exchange the refresh token for access_token and refresh_token | ||||
response="$(curl --compressed -fsSL --stderr - -F "client_id=${imgur_acct_key}" -F "client_secret=${imgur_secret}" -F "grant_type=refresh_token" -F "refresh_token=${refresh_token}" "${token_url}")" | response="$(curl --compressed -fsSL --stderr - -F "client_id=${imgur_acct_key}" -F "client_secret=${imgur_secret}" -F "grant_type=refresh_token" -F "refresh_token=${refresh_token}" "${token_url}")" | ||||
if [ ! "${?}" -eq "0" ]; then | |||||
if ! [ -z "$response" ]; then | |||||
# curl failed | # curl failed | ||||
handle_upload_error "${response}" "${token_url}" | handle_upload_error "${response}" "${token_url}" | ||||
exit 1 | exit 1 | ||||
@@ -265,9 +273,9 @@ function save_access_token() { | |||||
exit 1 | exit 1 | ||||
fi | fi | ||||
access_token="$(egrep -o 'access_token":".*"' <<<"${1}" | cut -d '"' -f 3)" | |||||
refresh_token="$(egrep -o 'refresh_token":".*"' <<<"${1}" | cut -d '"' -f 3)" | |||||
expires_in="$(egrep -o 'expires_in":[0-9]*' <<<"${1}" | cut -d ':' -f 2)" | |||||
access_token="$(grep -Eo 'access_token":".*"' <<<"${1}" | cut -d '"' -f 3)" | |||||
refresh_token="$(grep -Eo 'refresh_token":".*"' <<<"${1}" | cut -d '"' -f 3)" | |||||
expires_in="$(grep -Eo 'expires_in":[0-9]*' <<<"${1}" | cut -d ':' -f 2)" | |||||
token_expire_time="$(( $(date +%s) + expires_in ))" | token_expire_time="$(( $(date +%s) + expires_in ))" | ||||
# create dir if not exist | # create dir if not exist | ||||
@@ -282,8 +290,8 @@ EOF | |||||
function fetch_account_info() { | function fetch_account_info() { | ||||
response="$(curl --compressed --connect-timeout "${upload_connect_timeout}" -m "${upload_timeout}" --retry "${upload_retries}" -fsSL --stderr - -H "Authorization: Bearer ${access_token}" https://api.imgur.com/3/account/me)" | response="$(curl --compressed --connect-timeout "${upload_connect_timeout}" -m "${upload_timeout}" --retry "${upload_retries}" -fsSL --stderr - -H "Authorization: Bearer ${access_token}" https://api.imgur.com/3/account/me)" | ||||
if egrep -q '"success":\s*true' <<<"${response}"; then | |||||
username="$(egrep -o '"url":\s*"[^"]+"' <<<"${response}" | cut -d "\"" -f 4)" | |||||
if grep -Eq '"success":\s*true' <<<"${response}"; then | |||||
username="$(grep -Eo '"url":\s*"[^"]+"' <<<"${response}" | cut -d "\"" -f 4)" | |||||
echo "Logged in as ${username}." | echo "Logged in as ${username}." | ||||
echo "https://${username}.imgur.com" | echo "https://${username}.imgur.com" | ||||
else | else | ||||
@@ -293,7 +301,7 @@ function fetch_account_info() { | |||||
function delete_image() { | function delete_image() { | ||||
response="$(curl --compressed -X DELETE -fsSL --stderr - -H "Authorization: Client-ID ${1}" "https://api.imgur.com/3/image/${2}")" | response="$(curl --compressed -X DELETE -fsSL --stderr - -H "Authorization: Client-ID ${1}" "https://api.imgur.com/3/image/${2}")" | ||||
if egrep -q '"success":\s*true' <<<"${response}"; then | |||||
if grep -Eq '"success":\s*true' <<<"${response}"; then | |||||
echo "Image successfully deleted (delete hash: ${2})." >> "${3}" | echo "Image successfully deleted (delete hash: ${2})." >> "${3}" | ||||
else | else | ||||
echo "The Image could not be deleted: ${response}." >> "${3}" | echo "The Image could not be deleted: ${response}." >> "${3}" | ||||
@@ -310,10 +318,10 @@ function upload_authenticated_image() { | |||||
fi | fi | ||||
# JSON parser premium edition (not really) | # JSON parser premium edition (not really) | ||||
if egrep -q '"success":\s*true' <<<"${response}"; then | |||||
img_id="$(egrep -o '"id":\s*"[^"]+"' <<<"${response}" | cut -d "\"" -f 4)" | |||||
img_ext="$(egrep -o '"link":\s*"[^"]+"' <<<"${response}" | cut -d "\"" -f 4 | rev | cut -d "." -f 1 | rev)" # "link" itself has ugly '\/' escaping and no https! | |||||
del_id="$(egrep -o '"deletehash":\s*"[^"]+"' <<<"${response}" | cut -d "\"" -f 4)" | |||||
if grep -Eq '"success":\s*true' <<<"${response}"; then | |||||
img_id="$(grep -Eo '"id":\s*"[^"]+"' <<<"${response}" | cut -d "\"" -f 4)" | |||||
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 [ ! -z "${auto_delete}" ]; then | ||||
export -f delete_image | export -f delete_image | ||||
@@ -323,7 +331,7 @@ function upload_authenticated_image() { | |||||
handle_upload_success "https://i.imgur.com/${img_id}.${img_ext}" "https://imgur.com/delete/${del_id}" "${1}" | handle_upload_success "https://i.imgur.com/${img_id}.${img_ext}" "https://imgur.com/delete/${del_id}" "${1}" | ||||
else # upload failed | else # upload failed | ||||
err_msg="$(egrep -o '"error":\s*"[^"]+"' <<<"${response}" | cut -d "\"" -f 4)" | |||||
err_msg="$(grep -Eo '"error":\s*"[^"]+"' <<<"${response}" | cut -d "\"" -f 4)" | |||||
test -z "${err_msg}" && err_msg="${response}" | test -z "${err_msg}" && err_msg="${response}" | ||||
handle_upload_error "${err_msg}" "${1}" | handle_upload_error "${err_msg}" "${1}" | ||||
fi | fi | ||||
@@ -338,10 +346,10 @@ function upload_anonymous_image() { | |||||
response="$(curl --compressed --connect-timeout "${upload_connect_timeout}" -m "${upload_timeout}" --retry "${upload_retries}" -fsSL --stderr - -H "Authorization: Client-ID ${imgur_anon_id}" -F "title=${title}" -F "image=@\"${1}\"" https://api.imgur.com/3/image)" | response="$(curl --compressed --connect-timeout "${upload_connect_timeout}" -m "${upload_timeout}" --retry "${upload_retries}" -fsSL --stderr - -H "Authorization: Client-ID ${imgur_anon_id}" -F "title=${title}" -F "image=@\"${1}\"" https://api.imgur.com/3/image)" | ||||
fi | fi | ||||
# JSON parser premium edition (not really) | # JSON parser premium edition (not really) | ||||
if egrep -q '"success":\s*true' <<<"${response}"; then | |||||
img_id="$(egrep -o '"id":\s*"[^"]+"' <<<"${response}" | cut -d "\"" -f 4)" | |||||
img_ext="$(egrep -o '"link":\s*"[^"]+"' <<<"${response}" | cut -d "\"" -f 4 | rev | cut -d "." -f 1 | rev)" # "link" itself has ugly '\/' escaping and no https! | |||||
del_id="$(egrep -o '"deletehash":\s*"[^"]+"' <<<"${response}" | cut -d "\"" -f 4)" | |||||
if grep -Eq '"success":\s*true' <<<"${response}"; then | |||||
img_id="$(grep -Eo '"id":\s*"[^"]+"' <<<"${response}" | cut -d "\"" -f 4)" | |||||
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 [ ! -z "${auto_delete}" ]; then | ||||
export -f delete_image | export -f delete_image | ||||
@@ -351,7 +359,7 @@ function upload_anonymous_image() { | |||||
handle_upload_success "https://i.imgur.com/${img_id}.${img_ext}" "https://imgur.com/delete/${del_id}" "${1}" | handle_upload_success "https://i.imgur.com/${img_id}.${img_ext}" "https://imgur.com/delete/${del_id}" "${1}" | ||||
else # upload failed | else # upload failed | ||||
err_msg="$(egrep -o '"error":\s*"[^"]+"' <<<"${response}" | cut -d "\"" -f 4)" | |||||
err_msg="$(grep -Eo '"error":\s*"[^"]+"' <<<"${response}" | cut -d "\"" -f 4)" | |||||
test -z "${err_msg}" && err_msg="${response}" | test -z "${err_msg}" && err_msg="${response}" | ||||
handle_upload_error "${err_msg}" "${1}" | handle_upload_error "${err_msg}" "${1}" | ||||
fi | fi | ||||
@@ -456,6 +464,7 @@ while [ ${#} != 0 ]; do | |||||
mode="full" | mode="full" | ||||
shift;; | shift;; | ||||
-o | --open) | -o | --open) | ||||
# shellcheck disable=SC2034 | |||||
open="${2}" | open="${2}" | ||||
shift 2;; | shift 2;; | ||||
-e | --edit) | -e | --edit) | ||||
@@ -511,23 +520,23 @@ if [ -n "${album_title}" ]; then | |||||
-H "Authorization: Client-ID ${imgur_anon_id}" \ | -H "Authorization: Client-ID ${imgur_anon_id}" \ | ||||
https://api.imgur.com/3/album)" | https://api.imgur.com/3/album)" | ||||
fi | fi | ||||
if egrep -q '"success":\s*true' <<<"${response}"; then # Album creation successful | |||||
if grep -Eq '"success":\s*true' <<<"${response}"; then # Album creation successful | |||||
echo "Album '${album_title}' successfully created" | echo "Album '${album_title}' successfully created" | ||||
album_id="$(egrep -o '"id":\s*"[^"]+"' <<<"${response}" | cut -d "\"" -f 4)" | |||||
del_id="$(egrep -o '"deletehash":\s*"[^"]+"' <<<"${response}" | cut -d "\"" -f 4)" | |||||
album_id="$(grep -Eo '"id":\s*"[^"]+"' <<<"${response}" | cut -d "\"" -f 4)" | |||||
del_id="$(grep -Eo '"deletehash":\s*"[^"]+"' <<<"${response}" | cut -d "\"" -f 4)" | |||||
handle_album_creation_success "http://imgur.com/a/${album_id}" "${del_id}" "${album_title}" | handle_album_creation_success "http://imgur.com/a/${album_id}" "${del_id}" "${album_title}" | ||||
if [ "${login}" = "false" ]; then | if [ "${login}" = "false" ]; then | ||||
album_id="${del_id}" | album_id="${del_id}" | ||||
fi | fi | ||||
else # Album creation failed | else # Album creation failed | ||||
err_msg="$(egrep -o '"error":\s*"[^"]+"' <<<"${response}" | cut -d "\"" -f 4)" | |||||
err_msg="$(grep -Eo '"error":\s*"[^"]+"' <<<"${response}" | cut -d "\"" -f 4)" | |||||
test -z "${err_msg}" && err_msg="${response}" | test -z "${err_msg}" && err_msg="${response}" | ||||
handle_album_creation_error "${err_msg}" "${album_title}" | handle_album_creation_error "${err_msg}" "${album_title}" | ||||
fi | fi | ||||
fi | fi | ||||
if [ -z "${upload_files}" ]; then | |||||
if [ -z "${upload_files[*]}" ]; then | |||||
upload_files[0]="" | upload_files[0]="" | ||||
fi | fi | ||||
@@ -545,11 +554,13 @@ for upload_file in "${upload_files[@]}"; do | |||||
fi | fi | ||||
# get full path | # get full path | ||||
img_file="$(cd "$( dirname "${img_file}")" && echo "$(pwd)/$(basename "${img_file}")")" | |||||
#cd "$(dirname "$(realpath "${img_file}")")" | |||||
#img_file="$(realpath "${img_file}")" | |||||
# check if file exists | # check if file exists | ||||
if [ ! -f "${img_file}" ]; then | |||||
if ! [ -f "${img_file}" ]; then | |||||
echo "file '${img_file}' doesn't exist !" | echo "file '${img_file}' doesn't exist !" | ||||
read -r _ | |||||
exit 1 | exit 1 | ||||
fi | fi | ||||
@@ -584,4 +595,4 @@ if [ "${check_update}" = "true" ]; then | |||||
check_for_update | check_for_update | ||||
fi | fi | ||||
read dummy | |||||
read -r _ |
@@ -5,9 +5,9 @@ | |||||
# Shell: POSIX compliant | # Shell: POSIX compliant | ||||
# Author: Arun Prakash Jana | # Author: Arun Prakash Jana | ||||
IP=`curl -s ifconfig.me` | |||||
IP=$(curl -s ifconfig.me) | |||||
whois "$IP" | whois "$IP" | ||||
echo your external IP address is "$IP" | echo your external IP address is "$IP" | ||||
read dummy | |||||
read -r _ |
@@ -18,7 +18,7 @@ out="$(mocp -i)" | |||||
# Check if anything is playing | # Check if anything is playing | ||||
state=$(echo "$out" | grep "State:" | cut -d' ' -f2) | state=$(echo "$out" | grep "State:" | cut -d' ' -f2) | ||||
if ! [ $state = 'PLAY' ]; then | |||||
if ! [ "$state" = 'PLAY' ]; then | |||||
exit | exit | ||||
fi | fi | ||||
@@ -18,7 +18,8 @@ ret=$cmd | |||||
SHUFFLE=0 | SHUFFLE=0 | ||||
mocp_add() { | |||||
mocp_add () | |||||
{ | |||||
if [ $SHUFFLE = 1 ]; then | if [ $SHUFFLE = 1 ]; then | ||||
if [ "$resp" = "y" ]; then | if [ "$resp" = "y" ]; then | ||||
arr=$(tr '\0' '\n' < "$selection") | arr=$(tr '\0' '\n' < "$selection") | ||||
@@ -38,7 +39,7 @@ mocp_add() { | |||||
arr2=$(echo "$arr2" | awk 'BEGIN{srand();}{print rand()"\t"$0}' | sort -k1 -n | cut -f2-) | arr2=$(echo "$arr2" | awk 'BEGIN{srand();}{print rand()"\t"$0}' | sort -k1 -n | cut -f2-) | ||||
for entry in $arr2 | for entry in $arr2 | ||||
do | do | ||||
if [ -f "$entry" ] && [ "$(echo "$entry" | grep -v '\.m3u$\|\.pls$')" ]; then | |||||
if [ -f "$entry" ] && echo "$entry" | grep -qv '\.m3u$\|\.pls$' ; then | |||||
mocp -a "$entry" | mocp -a "$entry" | ||||
fi | fi | ||||
done | done | ||||
@@ -57,8 +58,8 @@ if [ ! -s "$selection" ] && [ -z "$1" ]; then | |||||
fi | fi | ||||
if [ -s "$selection" ]; then | if [ -s "$selection" ]; then | ||||
echo -n "Work with selection? Enter 'y' to confirm: " | |||||
read resp | |||||
printf "Work with selection? Enter 'y' to confirm: " | |||||
read -r resp | |||||
fi | fi | ||||
if [ -z "$ret" ]; then | if [ -z "$ret" ]; then | ||||
@@ -68,7 +69,7 @@ else | |||||
# mocp running, check if it's playing | # mocp running, check if it's playing | ||||
state=$(mocp -i | grep "State:" | cut -d' ' -f2) | state=$(mocp -i | grep "State:" | cut -d' ' -f2) | ||||
if [ $state = 'PLAY' ]; then | |||||
if [ "$state" = 'PLAY' ]; then | |||||
# add to playlist and exit | # add to playlist and exit | ||||
mocp_add "$1" | mocp_add "$1" | ||||
@@ -10,14 +10,14 @@ | |||||
selection=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection | selection=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection | ||||
if [ -s $selection ]; then | |||||
if [ -s "$selection" ]; then | |||||
arr=$(tr '\0' '\n' < "$selection") | arr=$(tr '\0' '\n' < "$selection") | ||||
if [ "$(echo "$arr" | wc -l)" -gt 1 ]; then | if [ "$(echo "$arr" | wc -l)" -gt 1 ]; then | ||||
f1="$(echo "$arr" | sed -n '1p')" | f1="$(echo "$arr" | sed -n '1p')" | ||||
f2="$(echo "$arr" | sed -n '2p')" | f2="$(echo "$arr" | sed -n '2p')" | ||||
if [ -d "$f1" ] && [ -d "$f2" ]; then | if [ -d "$f1" ] && [ -d "$f2" ]; then | ||||
dir1=$(mktemp "${TMPDIR:-/tmp}"/nnn-$(basename "$f1").XXXXXXXX) | |||||
dir2=$(mktemp "${TMPDIR:-/tmp}"/nnn-$(basename "$f2").XXXXXXXX) | |||||
dir1=$(mktemp "${TMPDIR:-/tmp}"/nnn-"$(basename "$f1")".XXXXXXXX) | |||||
dir2=$(mktemp "${TMPDIR:-/tmp}"/nnn-"$(basename "$f2")".XXXXXXXX) | |||||
ls -A1 "$f1" > "$dir1" | ls -A1 "$f1" > "$dir1" | ||||
ls -A1 "$f2" > "$dir2" | ls -A1 "$f2" > "$dir2" | ||||
vimdiff "$dir1" "$dir2" | vimdiff "$dir1" "$dir2" | ||||
@@ -27,7 +27,7 @@ if [ -s $selection ]; then | |||||
# Vim: Warning: Input is not from a terminal | # Vim: Warning: Input is not from a terminal | ||||
# xargs -0 -o vimdiff < $selection | # xargs -0 -o vimdiff < $selection | ||||
xargs -0 vimdiff +0 < $selection | |||||
xargs -0 vimdiff +0 < "$selection" | |||||
fi | fi | ||||
else | else | ||||
echo "needs at least 2 files or directories selected for comparison" | echo "needs at least 2 files or directories selected for comparison" | ||||
@@ -20,10 +20,9 @@ prompt="device name ['l' lists]: " | |||||
lsblk | lsblk | ||||
echo | |||||
echo "Make sure you aren't still in the mounted device." | |||||
echo -n "$prompt" | |||||
read dev | |||||
printf "\nMake sure you aren't still in the mounted device." | |||||
printf "%s" "$prompt" | |||||
read -r dev | |||||
while ! [ -z "$dev" ] | while ! [ -z "$dev" ] | ||||
do | do | ||||
@@ -34,11 +33,11 @@ do | |||||
else | else | ||||
if grep -qs "$dev " /proc/mounts; then | if grep -qs "$dev " /proc/mounts; then | ||||
sync | sync | ||||
pumount "$dev" | |||||
if [ "$?" -eq "0" ]; then | |||||
if pumount "$dev" | |||||
then | |||||
echo "$dev" unmounted. | echo "$dev" unmounted. | ||||
udisksctl power-off -b /dev/"$dev" | |||||
if [ "$?" -eq "0" ]; then | |||||
if udisksctl power-off -b /dev/"$dev" | |||||
then | |||||
echo "$dev" ejected. | echo "$dev" ejected. | ||||
fi | fi | ||||
fi | fi | ||||
@@ -49,6 +48,6 @@ do | |||||
fi | fi | ||||
echo | echo | ||||
echo -n "$prompt" | |||||
read dev | |||||
printf "%s" "$prompt" | |||||
read -r dev | |||||
done | done |
@@ -6,8 +6,8 @@ | |||||
# Author: juacq97 | # Author: juacq97 | ||||
if ! [ -z "$1" ]; then | if ! [ -z "$1" ]; then | ||||
if [ $(mimetype --output-format %m $1 | awk -F '/' '{print $1}') == "image" ]; then | |||||
nitrogen --set-zoom-fill --save $1 | |||||
if [ "$(mimetype --output-format %m "$1" | awk -F '/' '{print $1}')" = "image" ]; then | |||||
nitrogen --set-zoom-fill --save "$1" | |||||
# 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 "nnn" "Wallpaper changed!" | # notify-send -a "nnn" "Wallpaper changed!" | ||||
# else | # else | ||||
@@ -7,10 +7,10 @@ | |||||
# Shell: POSIX compliant | # Shell: POSIX compliant | ||||
# Author: Arun Prakash Jana | # Author: Arun Prakash Jana | ||||
echo -n "Min file size (MB): " | |||||
read size | |||||
printf "Min file size (MB): " | |||||
read -r size | |||||
find -size +"$size"M -type f -printf '%A+ %s %p\n' | sort | |||||
find . -size +"$size"M -type f -printf '%A+ %s %p\n' | sort | |||||
echo "Press any key to exit" | echo "Press any key to exit" | ||||
read dummy | |||||
read -r _ |
@@ -6,6 +6,6 @@ | |||||
# Author: Arun Prakash Jana | # Author: Arun Prakash Jana | ||||
if ! [ -z "$1" ]; then | if ! [ -z "$1" ]; then | ||||
curl -F "f:1=@"$1"" ix.io | |||||
read input | |||||
curl -F "f:1=@$1" ix.io | |||||
read -r _ | |||||
fi | fi |
@@ -10,7 +10,7 @@ | |||||
# Author: Arun Prakash Jana | # Author: Arun Prakash Jana | ||||
if ! [ -z "$1" ]; then | if ! [ -z "$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 | ||||
@@ -20,10 +20,11 @@ else | |||||
sucmd=: # noop | sucmd=: # noop | ||||
fi | fi | ||||
echo -n "Enter process name ['defunct' for zombies]: " | |||||
read psname | |||||
printf "Enter process name ['defunct' for zombies]: " | |||||
read -r psname | |||||
if ! [ -z "$psname" ]; then | if ! [ -z "$psname" ]; then | ||||
# shellcheck disable=SC2009 | |||||
cmd="$(ps -ax | grep -iw "$psname" | fzy | sed -e 's/^[ \t]*//' | cut -d' ' -f1)" | cmd="$(ps -ax | grep -iw "$psname" | fzy | sed -e 's/^[ \t]*//' | cut -d' ' -f1)" | ||||
$sucmd kill -9 "$cmd" | $sucmd kill -9 "$cmd" | ||||
fi | fi |
@@ -6,8 +6,8 @@ | |||||
# Author: juacq97 | # Author: juacq97 | ||||
if ! [ -z "$1" ]; then | if ! [ -z "$1" ]; then | ||||
if [ $(mimetype --output-format %m $1 | awk -F '/' '{print $1}') == "image" ]; then | |||||
wal -i $1 | |||||
if [ "$(mimetype --output-format %m "$1" | awk -F '/' '{print $1}')" = "image" ]; then | |||||
wal -i "$1" | |||||
# 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 "nnn" "Wallpaper changed!" | # notify-send -a "nnn" "Wallpaper changed!" | ||||
# else | # else | ||||
@@ -6,10 +6,10 @@ | |||||
# Author: Arun Prakash Jana | # Author: Arun Prakash Jana | ||||
if ! [ -z "$1" ]; then | if ! [ -z "$1" ]; then | ||||
tmpf=`basename "$1"` | |||||
tmpf="$(basename "$1")" | |||||
tmpf="${TMPDIR:-/tmp}"/"${tmpf%.*}" | tmpf="${TMPDIR:-/tmp}"/"${tmpf%.*}" | ||||
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' > "$tmpf".txt | pdftotext -nopgbrk -layout "$1" - | sed 's/\xe2\x80\x8b//g' > "$tmpf".txt | ||||
@@ -13,20 +13,21 @@ | |||||
# Author: Arun Prakash Jana | # Author: Arun Prakash Jana | ||||
if [ -n "$1" ]; then | if [ -n "$1" ]; then | ||||
echo -n "start (hh:mm:ss): " | |||||
read start | |||||
printf "start (hh:mm:ss): " | |||||
read -r start | |||||
st=$(date -d "$start" +%s) || exit 1 | st=$(date -d "$start" +%s) || exit 1 | ||||
echo -n "end (hh:mm:ss): " | |||||
read end | |||||
printf "end (hh:mm:ss): " | |||||
read -r end | |||||
et=$(date -d "$end" +%s) || exit 1 | et=$(date -d "$end" +%s) || exit 1 | ||||
if [ $st -ge $et ]; then | |||||
echo "error: start >= end" | |||||
if [ "$st" -ge "$et" ]; then | |||||
printf "error: start >= end " | |||||
read -r _ | |||||
exit 1 | exit 1 | ||||
fi | fi | ||||
interval=$(( $et - $st )) | |||||
interval=$(( et - st )) | |||||
outfile=$(basename "$1") | outfile=$(basename "$1") | ||||
outfile="${outfile%.*}"_ringtone.mp3 | outfile="${outfile%.*}"_ringtone.mp3 | ||||
@@ -12,8 +12,8 @@ selection=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection | |||||
resp=s | resp=s | ||||
if [ -s "$selection" ]; then | if [ -s "$selection" ]; then | ||||
echo -n "press 's' (split current file) or 'j' (join selection): " | |||||
read resp | |||||
printf "press 's' (split current file) or 'j' (join selection): " | |||||
read -r resp | |||||
fi | fi | ||||
if [ "$resp" = "j" ]; then | if [ "$resp" = "j" ]; then | ||||
@@ -37,8 +37,8 @@ if [ "$resp" = "j" ]; then | |||||
elif [ "$resp" = "s" ]; then | elif [ "$resp" = "s" ]; then | ||||
if [ -n "$1" ] && [ -f "$1" ]; then | if [ -n "$1" ] && [ -f "$1" ]; then | ||||
# a single file is passed | # a single file is passed | ||||
echo -n "split size in MB: " | |||||
read size | |||||
printf "split size in MB: " | |||||
read -r size | |||||
if [ -n "$size" ]; then | if [ -n "$size" ]; then | ||||
split -d -b "$size"M "$1" "$1" | split -d -b "$size"M "$1" "$1" | ||||
@@ -16,5 +16,5 @@ if command -v sxiv >/dev/null 2>&1; then | |||||
fi | fi | ||||
else | else | ||||
echo "sxiv missing" | echo "sxiv missing" | ||||
read dummy | |||||
read -r _ | |||||
fi | fi |
@@ -12,6 +12,6 @@ if ! [ -z "$1" ]; then | |||||
lsix "$1" | lsix "$1" | ||||
fi | fi | ||||
echo -n "Press any key to exit..." | |||||
read dummy | |||||
printf "Press any key to exit..." | |||||
read -r _ | |||||
fi | fi |
@@ -7,9 +7,9 @@ | |||||
if ! [ -z "$1" ]; then | if ! [ -z "$1" ]; then | ||||
# Upload the file, show the download link and wait till user presses any key | # Upload the file, show the download link and wait till user presses any key | ||||
curl -s --upload-file "$1" https://transfer.sh/`basename "$1"` | |||||
curl -s --upload-file "$1" https://transfer.sh/"$(basename "$1")" | |||||
echo | echo | ||||
read input | |||||
read -r _ | |||||
# To write download link to "$1".loc and exit | # To write download link to "$1".loc and exit | ||||
# curl -s --upload-file "$1" https://transfer.sh/`basename "$1"` -o `basename "$1"`.loc | # curl -s --upload-file "$1" https://transfer.sh/`basename "$1"` -o `basename "$1"`.loc | ||||
@@ -5,4 +5,5 @@ | |||||
# Shell: POSIX compliant | # Shell: POSIX compliant | ||||
# Author: Arun Prakash Jana, superDuperCyberTechno | # Author: Arun Prakash Jana, superDuperCyberTechno | ||||
# shellcheck disable=SC2012 | |||||
ls -lah --group-directories-first | less | ls -lah --group-directories-first | less |
@@ -6,10 +6,10 @@ | |||||
# Author: Arun Prakash Jana | # Author: Arun Prakash Jana | ||||
# NOTE: This script installs a package, should be issued with admin privilege | # NOTE: This script installs a package, should be issued with admin privilege | ||||
cur=`nnn -v` | |||||
new=`curl -s "https://github.com/jarun/nnn/releases/latest" | grep -Eo "[0-9]+\.[0-9]+"` | |||||
cur="$(nnn -v)" | |||||
new="$(curl -s "https://github.com/jarun/nnn/releases/latest" | grep -Eo "[0-9]+\.[0-9]+")" | |||||
if [ $cur_ver == $new_ver ]; then | |||||
if [ "$cur" = "$new" ]; then | |||||
echo 'Already at latest version' | echo 'Already at latest version' | ||||
exit 0 | exit 0 | ||||
fi | fi | ||||
@@ -18,7 +18,7 @@ fi | |||||
curl -Ls -O "https://github.com/jarun/nnn/releases/download/v$new/nnn_$new-1_debian9.amd64.deb" | curl -Ls -O "https://github.com/jarun/nnn/releases/download/v$new/nnn_$new-1_debian9.amd64.deb" | ||||
# install it | # install it | ||||
sudo dpkg -i nnn_$new-1_debian9.amd64.deb | |||||
sudo dpkg -i nnn_"$new"-1_debian9.amd64.deb | |||||
# remove the file | # remove the file | ||||
rm -rf nnn_$new-1_debian9.amd64.deb | |||||
rm -rf nnn_"$new"-1_debian9.amd64.deb |
@@ -23,5 +23,5 @@ lsix .nthumbs/* | |||||
# remove the thumbnails | # remove the thumbnails | ||||
rm -rf .nthumbs | rm -rf .nthumbs | ||||
echo -n "Press any key to exit..." | |||||
read dummy | |||||
printf "Press any key to exit..." | |||||
read -r _ |