Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Ever wanted to:
- Get just the structure without the contents?
- Know how many tokens your project weighs in at?

`ctxify` does it all. Its lightweight, fast, and skips the fluff (like lock files or `.gitignore`). Built with Python 3.13 and Git magic. ✨
`ctxify` does it all. It's lightweight, fast, and skips the fluff (like lock files or `.gitignore`). Built with Python 3.13 and Git magic. ✨

---

Expand Down Expand Up @@ -54,10 +54,12 @@ On Linux, install `xclip`:
sudo apt install xclip
```

On macOS, clipboard support is built-in (uses `pbcopy`), so no additional installation is needed.

---

## Usage
Run it from your Git repos root:
Run it from your Git repo's root:

```bash
ctxify
Expand Down
26 changes: 20 additions & 6 deletions src/ctxify/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from prompt_toolkit import PromptSession
from prompt_toolkit.completion import FuzzyWordCompleter
import platform

# Files/extensions to skip (non-code files) for content inclusion
NON_CODE_PATTERNS = {
Expand Down Expand Up @@ -133,17 +134,30 @@ def get_git_files(


def copy_to_clipboard(text: str) -> bool:
"""Copy text to system clipboard using xclip"""
"""Copy text to system clipboard using pbcopy (macOS) or xclip (Linux)"""
system = platform.system().lower()
try:
subprocess.run(
['xclip', '-selection', 'clipboard'], input=text.encode('utf-8'), check=True
)
if system == 'darwin': # macOS
subprocess.run(
['pbcopy'], input=text.encode('utf-8'), check=True
)
elif system == 'linux': # Linux
subprocess.run(
['xclip', '-selection', 'clipboard'], input=text.encode('utf-8'), check=True
)
else:
print(f'Warning: Clipboard operations not supported on {platform.system()}')
return False
return True
except subprocess.CalledProcessError:
print('Warning: Failed to copy to clipboard (xclip error)')
cmd = 'pbcopy' if system == 'darwin' else 'xclip'
print(f'Warning: Failed to copy to clipboard ({cmd} error)')
return False
except FileNotFoundError:
print("Warning: xclip not installed. Install it with 'sudo apt install xclip'")
if system == 'darwin':
print("Warning: pbcopy not found. This is unexpected as it should be built into macOS")
else:
print("Warning: xclip not installed. Install it with 'sudo apt install xclip'")
return False


Expand Down