Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Clip2File

Clip2File is a small Linux Bash utility that saves clipboard text to a file and then places a reference to that file on the clipboard. Its primary workflow is:

Copy text → run clip2file → paste into an application that accepts files

Running clip2file with no arguments creates a temporary output file. The file is intentionally retained after the script exits because the receiving application may not read it until you paste. Intermediate working files are removed automatically.

Installation

Clone the repository:

git clone https://github.com/Dimension-Eight-Labs/Clip2File.git
cd Clip2File

Install for your user:

mkdir -p ~/bin
cp clip2file ~/bin/
chmod +x ~/bin/clip2file

Ensure ~/bin is included in your PATH.

Alternatively install system-wide:

sudo cp clip2file /usr/local/bin/
sudo chmod +x /usr/local/bin/clip2file

Usage

Create a temporary file and put its file reference on the clipboard:

clip2file

Create a permanent named file:

clip2file --output response.md

The positional shorthand remains available:

clip2file response.md

Options:

Option Description
-o, --output FILE Save permanently to FILE
-t, --timestamp Save permanently as YYYY-MM-DD_HHMMSS.txt
-T, --temp Create a temporary output file (the default)
--unix Normalize line endings to LF
--dos Normalize line endings to CRLF
--stdout Write clipboard text to stdout without creating a file
-f, --overwrite Allow replacement of an existing file
-v, --verbose Print diagnostics to stderr
-h, --help Show command help
--version Show the version

Clip2File preserves the clipboard text bytes by default; it does not convert arbitrary input to UTF-8. The --unix and --dos options only normalize line endings.

Clipboard support

On Wayland, Clip2File uses wl-paste and wl-copy from wl-clipboard. On X11, it prefers xclip. Both Wayland and xclip place a percent-encoded file:// URI on the clipboard as text/uri-list.

If only xsel is available, Clip2File can still read clipboard text, but xsel cannot reliably advertise the typed file-reference format. The fallback puts the original absolute pathname on the clipboard and prints a warning; whether pasting it is useful depends on the receiving application.

Install the appropriate clipboard tool with your distribution's package manager, for example wl-clipboard, xclip, or xsel on Debian-based systems. Clipboard file-paste behavior varies between applications and desktops.

License

This project is licensed under the GNU General Public License v3.0 (GPL-3.0). See the LICENSE file for details.

About

copy text to the clipboard, then clip2file swaps that text for a file with the text as it's content

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages