If you are like me and love the terminal, start using fcopy, fcut, fpaste
how does it work, instead of copying through a file explorer, just do:
$ fcopy some/file/
$ fcopy other/file/image.png
then open other terminal and do:
$ fpaste
fcopy() {
if [ "$#" -eq 0 ]; then
echo "fcopy: nothing to copy"
return 1
fi
tmp="$(mktemp)"
printf 'copy\n' > "$tmp"
for item in "$@"; do
if [ -e "$item" ]; then
abs="$(realpath "$item")"
printf '%s\n' "$abs" >> "$tmp"
echo "copied to clipboard: $abs"
else
echo "fcopy: not found: $item" >&2
fi
done
mv "$tmp" ~/.fileclip
}
fcut() {
if [ "$#" -eq 0 ]; then
echo "fcut: nothing to cut"
return 1
fi
tmp="$(mktemp)"
printf 'move\n' > "$tmp"
for item in "$@"; do
if [ -e "$item" ]; then
abs="$(realpath "$item")"
printf '%s\n' "$abs" >> "$tmp"
echo "cut to clipboard: $abs"
else
echo "fcut: not found: $item" >&2
fi
done
mv "$tmp" ~/.fileclip
}
fpaste() {
[ -f ~/.fileclip ] || { echo "fpaste: file clipboard is empty"; return 1; }
mode="$(head -n1 ~/.fileclip)"
count=0
while IFS= read -r src; do
[ -n "$src" ] || continue
if [ ! -e "$src" ]; then
echo "fpaste: source no longer exists: $src" >&2
continue
fi
if [ "$mode" = "move" ]; then
if mv -- "$src" .; then
echo "moved: $src -> $PWD/"
count=$((count + 1))
else
echo "fpaste: failed to move: $src" >&2
fi
else
if cp -a -- "$src" .; then
echo "pasted: $src -> $PWD/"
count=$((count + 1))
else
echo "fpaste: failed to paste: $src" >&2
fi
fi
done < <(tail -n +2 ~/.fileclip)
echo "done: $count item(s)"
}
Top comments (0)