Thanks to visit codestin.com
Credit goes to github.com

Skip to content
/ copyfile Public template

A simple command-line Python script that copies the contents of a text file to the clipboard. Works with Linux X11 environments and uses `tkinter` to interface with the clipboard.

License

JPDeerenberg/copyfile

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

CopyFile - Clipboard File Copier

A simple command-line Python script that copies the contents of a text file to the clipboard. Works with Linux X11 environments and uses tkinter to interface with the clipboard.

Features

  • Copy the contents of a file to the clipboard.
  • Trim whitespace before copying (optional).
  • Print the file contents to stdout (optional).
  • Verbose output for debugging (optional).
  • Supports running the script with a simple copyfile command after setup.

Prerequisites

  • Python 3.x
  • X11 (for clipboard access)
  • Tkinter (for clipboard management with X11)

Installation

1. Clone the repository

git clone https://github.com/JPDeerenberg/copyfile
cd copyfile

2. Make the script executable

chmod +x copyfile.py

3. Rename the script (optional)

mv copyfile.py copyfile

4. Add the script to your PATH

To run the copyfile command from anywhere, you need to add it to your system's PATH.

Option 1: Move the script to a directory in your PATH (e.g., /usr/local/bin)

sudo mv copyfile /usr/local/bin/

Option 2: Add the current directory to your PATH

Add this line to your shell config (~/.bashrc, ~/.zshrc, etc.):

export PATH=$PATH:/path/to/your/script/directory

Then source the file:

source ~/.bashrc  # or source ~/.zshrc

Usage

Once installed, you can use the script from the command line.

Basic Command

copyfile filename.txt

Copies the contents of filename.txt to the clipboard.

Optional Flags

  • --trim: Trim whitespace before copying.
  • --print: Print file contents to stdout.
  • -v, --verbose: Show verbose output during copying.

Example:

copyfile filename.txt --trim --verbose

Error Handling

  • The script checks for missing or unreadable files.
  • It ensures you're running in an X11 environment with the DISPLAY variable set.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

A simple command-line Python script that copies the contents of a text file to the clipboard. Works with Linux X11 environments and uses `tkinter` to interface with the clipboard.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages