Skip to content

jroth55/filesc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

# filesc - Files to Clipboard

A powerful bash utility that intelligently copies code repositories to your clipboard in a structured format, perfect for sharing with AI assistants, documentation, or code reviews.

**Version:** 1.1.0  
**Author:** jroth55  
**Last Updated:** 2025-03-23 08:12:24 UTC

## Overview

`filesc` scans your project directories, intelligently filters files, and copies them to your clipboard in a formatted structure. It handles binary detection, large file filtering, and supports both Markdown and XML output formats.

## Features

- **Multiple output formats:**
  - **Markdown** (default): Clean, readable code blocks with syntax highlighting
  - **XML**: Structured format for programmatic processing
- **Intelligent filtering:**
  - Skips binary files automatically
  - Excludes files larger than 1MB (configurable)
  - Ignores common non-code file extensions
  - Skips common directories like `.git` and `node_modules`
- **Smart language detection** for proper syntax highlighting
- **Cross-platform support:**
  - macOS (pbcopy)
  - Linux (xclip/xsel)
  - Windows (clip)
- **Character encoding detection** with automatic repair attempts
- **Progress reporting** for large repositories
- **Robust error handling** with detailed feedback

## Installation

### Option 1: Manual Installation

1. Clone this repository:
   ```bash
   git clone https://github.com/jroth55/filesc.git
   ```

2. Make the script executable:
   ```bash
   chmod +x filesc/filesc.sh
   ```

3. Create a symbolic link to make it globally available:
   ```bash
   sudo ln -s $(pwd)/filesc/filesc.sh /usr/local/bin/filesc
   ```

### Option 2: Direct Download

```bash
curl -o /usr/local/bin/filesc https://raw.githubusercontent.com/jroth55/filesc/main/filesc.sh
chmod +x /usr/local/bin/filesc
```

## Usage

```bash
filesc [OPTIONS] [DIRECTORY]
```

### Options

- `-h, --help`: Show help message
- `-f, --format FORMAT`: Output format (markdown or xml), default: markdown
- `-v, --version`: Show version information

### Examples

```bash
# Copy files from current directory in markdown format
filesc

# Copy files from a specific directory
filesc /path/to/project

# Copy files in XML format
filesc -f xml

# Show help
filesc --help
```

## Example Output

### Markdown Format (Default)

```markdown
# Files from: /path/to/project
# Generated on: 2025-03-23 08:12:24
# Generated by: filesc v1.1.0

## File: `app.js`

```javascript
const express = require('express');
const app = express();

app.get('/', (req, res) => {
  res.send('Hello World!');
});

app.listen(3000, () => {
  console.log('Server started on port 3000');
});
```

## File: `README.md`

```markdown
# My Project
This is a sample project
```
```

### XML Format

```xml
<files>
<!-- Generated by filesc v1.1.0 on 2025-03-23 08:12:24 -->
<!-- Repository: /path/to/project -->
<file path="app.js">
const express = require('express');
const app = express();

app.get('/', (req, res) => {
  res.send('Hello World!');
});

app.listen(3000, () => {
  console.log('Server started on port 3000');
});
</file>
<file path="README.md">
# My Project
This is a sample project
</file>
</files>
```

## Customization

You can customize the behavior by editing these variables at the top of the script:

```bash
# Max file size in bytes (default: 1MB)
MAX_FILE_SIZE=$((1024 * 1024))

# Excluded file extensions
EXCLUDE_EXTENSIONS=(
    .env .log .gitignore .json .npmrc .prettierrc .eslintrc .babelrc 
    .pyc .pyo .pyd .class
    # Image files
    .jpg .jpeg .png .gif .bmp .tiff .webp .svg .ico .avif
)

# Excluded directories
EXCLUDE_DIRS=(
    .git .svn .vscode .idea node_modules venv .venv
    build dist out .next coverage
)
```

## Use Cases

1. **Share code with AI assistants**: Quickly copy your project for AI pair programming
2. **Code reviews**: Share multiple files at once with team members
3. **Documentation**: Generate code snippets for technical documentation
4. **Archiving**: Create text-based snapshots of small projects

## Requirements

- Bash shell
- `find` command
- One of the following clipboard utilities:
  - `pbcopy` (macOS)
  - `xclip` or `xsel` (Linux)
  - `clip` (Windows)

## Troubleshooting

- **No output**: Check exclusion lists and make sure files match your criteria
- **Clipboard errors**: Ensure you have a clipboard utility installed
- **Large repositories**: The script limits to 500 files by default to avoid memory issues

## License

MIT

---

**Made with ❤️ by jroth55**  
Last updated: 2025-03-23 08:12:24 UTC

About

Copy entire code repository into the clipboard

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages