mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 03:41:27 +00:00
Fix some cat abuses in code, plugins
This commit is contained in:
parent
0c0f12b528
commit
2d91768d88
|
@ -8,16 +8,16 @@
|
||||||
SELECTION=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection
|
SELECTION=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection
|
||||||
|
|
||||||
# Linux
|
# Linux
|
||||||
cat "$SELECTION" | xargs -0 | xsel -bi
|
xargs -0 < "$SELECTION" | xsel -bi
|
||||||
|
|
||||||
# macOS
|
# macOS
|
||||||
# cat "$SELECTION" | xargs -0 | pbcopy
|
# xargs -0 < "$SELECTION" | pbcopy
|
||||||
|
|
||||||
# Termux
|
# Termux
|
||||||
# cat "$SELECTION" | xargs -0 | termux-clipboard-set
|
# xargs -0 < "$SELECTION" | termux-clipboard-set
|
||||||
|
|
||||||
# Cygwin
|
# Cygwin
|
||||||
# cat "$SELECTION" | xargs -0 | clip
|
# xargs -0 < "$SELECTION" | clip
|
||||||
|
|
||||||
# Wayland
|
# Wayland
|
||||||
# cat "$SELECTION" | xargs -0 | wl-copy
|
# xargs -0 < "$SELECTION" | wl-copy
|
||||||
|
|
|
@ -10,10 +10,10 @@ shellname="$(basename "$SHELL")"
|
||||||
|
|
||||||
if [ "$shellname" = "bash" ]; then
|
if [ "$shellname" = "bash" ]; then
|
||||||
hist_file="$HOME/.bash_history"
|
hist_file="$HOME/.bash_history"
|
||||||
entry="$(cat "$hist_file" | fzy)"
|
entry="$(fzy < "$hist_file")"
|
||||||
elif [ "$shellname" = "fish" ]; then
|
elif [ "$shellname" = "fish" ]; then
|
||||||
hist_file="$HOME/.config/fish/fish_history"
|
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
|
fi
|
||||||
|
|
||||||
if ! [ -z "$entry" ]; then
|
if ! [ -z "$entry" ]; then
|
||||||
|
@ -21,10 +21,8 @@ if ! [ -z "$entry" ]; then
|
||||||
echo "$entry" >> $tmpfile
|
echo "$entry" >> $tmpfile
|
||||||
$EDITOR $tmpfile
|
$EDITOR $tmpfile
|
||||||
|
|
||||||
cmd="$(cat $tmpfile)"
|
if [ -s $tmpfile ]; then
|
||||||
|
$SHELL -c "$(cat $tmpfile)"
|
||||||
if ! [ -z "$cmd" ]; then
|
|
||||||
$SHELL -c "$cmd"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm $tmpfile
|
rm $tmpfile
|
||||||
|
|
|
@ -25,9 +25,9 @@ if [ -s $selection ]; then
|
||||||
else
|
else
|
||||||
# If xargs supports the -o option, use it to get rid of:
|
# If xargs supports the -o option, use it to get rid of:
|
||||||
# Vim: Warning: Input is not from a terminal
|
# 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
|
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"
|
||||||
|
|
|
@ -21,6 +21,6 @@
|
||||||
nnn -p /tmp/picked
|
nnn -p /tmp/picked
|
||||||
|
|
||||||
if [ -f /tmp/picked ]; then
|
if [ -f /tmp/picked ]; then
|
||||||
cat /tmp/picked | tr '\0' '\n'
|
tr '\0' '\n' < /tmp/picked
|
||||||
rm /tmp/picked
|
rm /tmp/picked
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -13,11 +13,11 @@ if ! [ -z "$1" ]; 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
|
||||||
|
|
||||||
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
|
rm "$tmpf".txt
|
||||||
else
|
else
|
||||||
pico2wave -w "$tmpf".wav -l en-GB "$(cat "$1" | tr '\n' ' ')"
|
pico2wave -w "$tmpf".wav -l en-GB "$(tr '\n' ' ' < "$1")"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# to jump around and note the time
|
# to jump around and note the time
|
||||||
|
|
|
@ -891,7 +891,7 @@ static bool listselfile(void)
|
||||||
if (!sb.st_size)
|
if (!sb.st_size)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
snprintf(g_buf, CMD_LEN_MAX, "cat %s | tr \'\\0\' \'\\n\'", g_selpath);
|
snprintf(g_buf, CMD_LEN_MAX, "tr \'\\0\' \'\\n\' < %s", g_selpath);
|
||||||
spawn(utils[SH_EXEC], g_buf, NULL, NULL, F_CLI | F_CONFIRM);
|
spawn(utils[SH_EXEC], g_buf, NULL, NULL, F_CLI | F_CONFIRM);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -1346,7 +1346,7 @@ static bool cpmv_rename(int choice, const char *path)
|
||||||
|
|
||||||
/* selsafe() returned TRUE for this to be called */
|
/* selsafe() returned TRUE for this to be called */
|
||||||
if (!selbufpos) {
|
if (!selbufpos) {
|
||||||
snprintf(buf, sizeof(buf), "cat %s | tr '\\0' '\\n' > %s", g_selpath, g_tmpfpath);
|
snprintf(buf, sizeof(buf), "tr '\\0' '\\n' < %s > %s", g_selpath, g_tmpfpath);
|
||||||
spawn(utils[SH_EXEC], buf, NULL, NULL, F_CLI);
|
spawn(utils[SH_EXEC], buf, NULL, NULL, F_CLI);
|
||||||
|
|
||||||
count = lines_in_file(fd, buf, sizeof(buf));
|
count = lines_in_file(fd, buf, sizeof(buf));
|
||||||
|
|
Loading…
Reference in a new issue