Last active
August 28, 2025 05:49
-
-
Save flipeador/ae8b33d009c2f31c5e600ed82baa29a8 to your computer and use it in GitHub Desktop.
CLI tool to read files and copy text to the Windows clipboard.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;@Ahk2Exe-ConsoleApp | |
| #Requires AutoHotkey v2 | |
| #SingleInstance Off | |
| Persistent(true) | |
| FileEncoding('UTF-8') | |
| SetWorkingDir(A_InitialWorkingDir) | |
| parent := ProcessGetName(ProcessGetParent()) | |
| message := ' | |
| ( | |
| Usage: | |
| clip.exe [parameters] [file-path] | |
| Parameters: | |
| -h `tDisplays this help message. | |
| -d `tSet the delimiter. | |
| -t `tSet a literal string. | |
| Examples: | |
| echo text | clip.exe `tCopy a literal string. | |
| clip.exe < file.txt `tCopy the content from a file. | |
| clip.exe -t text `tCopy a literal string. | |
| clip.exe a.txt b.txt `tCopy the content from 2 files. | |
| )' | |
| if Args(1, '-h') == '-h' { | |
| Print(message) | |
| if parent == 'explorer.exe' | |
| return | |
| ExitApp() | |
| } | |
| delimiter := '' | |
| content := FileOpen('*', 'r').Read() | |
| loop A_Args.Length { | |
| cmd := Args(A_Index) | |
| arg := Args(A_Index + 1) | |
| if cmd == '-d' | |
| A_Index++, delimiter := arg | |
| else if cmd == '-t' | |
| A_Index++, content .= arg | |
| else { | |
| if content != '' | |
| content .= delimiter | |
| try content .= FileRead(cmd) | |
| } | |
| } | |
| A_Clipboard := content | |
| ExitApp() | |
| Args(index, defarg:='') { | |
| try return A_Args[index] | |
| return defarg | |
| } | |
| Print(str:='', values*) { | |
| FileAppend(Format(str . '`n', values*), '*') | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Clip
CLI tool to read files and copy text to the Windows clipboard.
Instructions
Download AutoHotkey 2 and compile
clip.ahk.Run
clip.exe -hin the Terminal to display the help message.You can also open
clip.exedirectly from the Windows file explorer.Download
https://asset.cloudinary.com/flipeador/e0fcce61b23fb62d83912c1974ced0ac