diff options
author | Arun Prakash Jana <engineerarun@gmail.com> | 2019-11-21 00:31:39 +0530 |
---|---|---|
committer | Arun Prakash Jana <engineerarun@gmail.com> | 2019-11-21 00:31:39 +0530 |
commit | 2d91768d88b14568139b51da4ce0c85cbe837df5 (patch) | |
tree | 242b41862ac677a3f275a56aa808a136b5722175 /plugins | |
parent | 0c0f12b5286f1e80b13446c69ebef2ee03ae31ec (diff) | |
download | nnn-2d91768d88b14568139b51da4ce0c85cbe837df5.tar.gz |
Fix some cat abuses in code, plugins
Diffstat (limited to 'plugins')
-rwxr-xr-x | plugins/fzhist | 10 | ||||
-rwxr-xr-x | plugins/ndiff | 4 | ||||
-rwxr-xr-x | plugins/picker | 2 | ||||
-rwxr-xr-x | plugins/readit | 4 |
4 files changed, 9 insertions, 11 deletions
diff --git a/plugins/fzhist b/plugins/fzhist index 52f13bf..ca1db63 100755 --- a/plugins/fzhist +++ b/plugins/fzhist @@ -10,10 +10,10 @@ shellname="$(basename "$SHELL")" if [ "$shellname" = "bash" ]; then hist_file="$HOME/.bash_history" - entry="$(cat "$hist_file" | fzy)" + entry="$(fzy < "$hist_file")" elif [ "$shellname" = "fish" ]; then hist_file="$HOME/.config/fish/fish_history" - entry="$(cat "$hist_file" | grep "\- cmd: " | cut -c 8- | fzy)" + entry="$(grep "\- cmd: " "$hist_file" | cut -c 8- | fzy)" fi if ! [ -z "$entry" ]; then @@ -21,10 +21,8 @@ if ! [ -z "$entry" ]; then echo "$entry" >> $tmpfile $EDITOR $tmpfile - cmd="$(cat $tmpfile)" - - if ! [ -z "$cmd" ]; then - $SHELL -c "$cmd" + if [ -s $tmpfile ]; then + $SHELL -c "$(cat $tmpfile)" fi rm $tmpfile diff --git a/plugins/ndiff b/plugins/ndiff index dff24d2..f5ca0dc 100755 --- a/plugins/ndiff +++ b/plugins/ndiff @@ -25,9 +25,9 @@ if [ -s $selection ]; then else # If xargs supports the -o option, use it to get rid of: # Vim: Warning: Input is not from a terminal - # cat $selection | xargs -0 -o vimdiff + # xargs -0 -o vimdiff < $selection - cat $selection | xargs -0 vimdiff +0 + xargs -0 vimdiff +0 < $selection fi else echo "needs at least 2 files or directories selected for comparison" diff --git a/plugins/picker b/plugins/picker index a500435..91101fe 100755 --- a/plugins/picker +++ b/plugins/picker @@ -21,6 +21,6 @@ nnn -p /tmp/picked if [ -f /tmp/picked ]; then - cat /tmp/picked | tr '\0' '\n' + tr '\0' '\n' < /tmp/picked rm /tmp/picked fi diff --git a/plugins/readit b/plugins/readit index b997235..e0058db 100755 --- a/plugins/readit +++ b/plugins/readit @@ -13,11 +13,11 @@ if ! [ -z "$1" ]; then # Convert using pdftotext pdftotext -nopgbrk -layout "$1" - | sed 's/\xe2\x80\x8b//g' > "$tmpf".txt - pico2wave -w "$tmpf".wav -l en-GB "$(cat "$tmpf".txt | tr '\n' ' ')" + pico2wave -w "$tmpf".wav -l en-GB "$(tr '\n' ' ' < "$tmpf".txt)" rm "$tmpf".txt else - pico2wave -w "$tmpf".wav -l en-GB "$(cat "$1" | tr '\n' ' ')" + pico2wave -w "$tmpf".wav -l en-GB "$(tr '\n' ' ' < "$1")" fi # to jump around and note the time |