Back to list
dev_to 2026年3月15日

ターミナルのヒント 🤩 fcopy, fcut, fpaste

Terminal Tip 🤩 fcopy, fcut, fpaste

Translated: 2026/3/15 3:00:22
bashshell-scriptsterminal-hacksfile-operationsproductivity-tools

Japanese Translation

ターミナルを愛している方と同じなら、fcpo、fcu、fpa 使用を開始しましょう。ファイルエクスプローラーを通じてコピーする代わりに、次のコマンドを実行します:$ fcopy some/file/ $ fcopy other/file/image.png その後、別のターミナルを開き、以下を実行します:$ fpaste fcopy() の定義は以下の通りです。

Original Content

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)" }