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
63 changes: 63 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.project
.idea/
*.iml
__pycache__/

# Tooling
.direnv/
.env
.env.*
.glassfish/
.gradle/
.jekyll-cache/
.pub-cache/
.pub/
.sandbox/
.vscode/

# Flutter/Dart-specific
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
build/
ephemeral/

# Android-specific
android/app/local.properties
android/app/flutter_bootstrap.properties
android/key.properties
android/app/src/main/assets/

# iOS-specific
ios/Flutter/Generated.xcconfig
ios/Flutter/flutter_export_environment.sh
ios/Flutter/App.framework
ios/Flutter/Flutter.framework
ios/Flutter/Flutter.podspec
ios/derived_data/
ios/Pods/

# macOS-specific
macos/Flutter/Generated.xcconfig
macos/Flutter/flutter_export_environment.sh
macos/Flutter/ephemeral/
macos/Pods/

# Windows-specific
windows/flutter/ephemeral/

# Linux-specific
linux/flutter/ephemeral/

# Web-specific
web/flutter_service_worker.js
45 changes: 45 additions & 0 deletions .metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.

version:
revision: "90673a4eef275d1a6692c26ac80d6d746d41a73a"
channel: "stable"

project_type: app

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: 90673a4eef275d1a6692c26ac80d6d746d41a73a
base_revision: 90673a4eef275d1a6692c26ac80d6d746d41a73a
- platform: android
create_revision: 90673a4eef275d1a6692c26ac80d6d746d41a73a
base_revision: 90673a4eef275d1a6692c26ac80d6d746d41a73a
- platform: ios
create_revision: 90673a4eef275d1a6692c26ac80d6d746d41a73a
base_revision: 90673a4eef275d1a6692c26ac80d6d746d41a73a
- platform: linux
create_revision: 90673a4eef275d1a6692c26ac80d6d746d41a73a
base_revision: 90673a4eef275d1a6692c26ac80d6d746d41a73a
- platform: macos
create_revision: 90673a4eef275d1a6692c26ac80d6d746d41a73a
base_revision: 90673a4eef275d1a6692c26ac80d6d746d41a73a
- platform: web
create_revision: 90673a4eef275d1a6692c26ac80d6d746d41a73a
base_revision: 90673a4eef275d1a6692c26ac80d6d746d41a73a
- platform: windows
create_revision: 90673a4eef275d1a6692c26ac80d6d746d41a73a
base_revision: 90673a4eef275d1a6692c26ac80d6d746d41a73a

# User provided section

# List of Local paths (relative to this file) that should be
# ignored by the migrate tool.
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'
137 changes: 61 additions & 76 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,108 +1,93 @@
# cmdclip 📋

> A smart, cross-platform command clipboard manager for the terminal.
> Built by [M5 Dev](https://github.com/M5Develop) — GPL-3.0
> A lightweight, offline-first, cross-platform clipboard manager with LAN Sync and secure secret tracking.
> Built with Flutter and Material 3 — GPL-3.0 License.

**cmdclip** is a modern, high-performance clipboard manager designed to run natively on **Windows**, **Linux**, and **Android** from a single codebase. It is 100% offline, requires no cloud accounts, no internet, and has absolutely zero telemetry.

---

## Why cmdclip?
## 🚀 Key Features

`history` is short. `grep` is tedious. `pet` is Go-only.
**cmdclip** is Python, works on Linux / macOS / Windows, and has AI built in.
1. **Clipboard History** — Polling-based background tracking captures everything you copy with accurate timestamps.
2. **Pinning & Categories** — Organizes clips instantly. Pin important snippets to keep them at the top, or assign entries to custom user-defined categories (e.g., *Work*, *Terminal*, *Code*, *Personal*).
3. **Secure Secret Mode** — One-tap toggle disables history recording. Copies during Secret Mode trigger a secure countdown timer that automatically overwrites/clears your system clipboard after a user-defined timeout (e.g., 30s, 60s).
4. **Command Templates** — Supports placeholders like `ssh {user}@{host} -p {port=22}`. Prompts with a sleek, interactive input form to resolve variables, pre-filling defaults before copying the finalized command.
5. **Regex Search** — Seamless regular expression search across your history with an easy toggle button.
6. **Local LAN Sync** — Real-time clipboard sharing between desktops and Android over your local Wi-Fi network. Acts as both an HTTP server and a UDP client to perform auto-discovery and direct paired synchronization. No internet, cloud, or accounts required!
7. **JSON & CSV Export/Import** — Easily back up, share, or migration-import history. Hand-written custom CSV state machine parser handles multi-line cells and quotes cleanly.

---

## Install
## 📂 Project Structure

```bash
pip install cmdclip
```
.
├── android/ # Android Native Platform Configuration
├── linux/ # Linux Native Platform Configuration
├── windows/ # Windows Native Platform Configuration
├── lib/
│ ├── main.dart # Responsive Material 3 UI Layout & View Controllers
│ ├── models.dart # ClipboardItem, CommandTemplate, SyncPeer Definitions
│ ├── storage.dart # Persistent cached JSON local storage & CSV/JSON Export/Import Engine
│ ├── sync_service.dart # Background Poller, HTTP Sync Server, UDP LAN Auto-Discovery
│ └── secret_manager.dart # Secret mode clipboard timer & template resolution engine
├── test/
│ ├── app_test.dart # Exhaustive Model, Storage, CSV/JSON, Secret, and Template unit tests
│ └── widget_test.dart # App Widget rendering and smoke tests
├── pubspec.yaml # Flutter project dependency configuration
└── README.md # Documentation & build guide
```

---

## Quick start

```bash
# Save a command
cmdclip add "docker ps -a --format '{{.Names}}'" --tags docker,ops --note "list container names"

# List all
cmdclip list

# Search
cmdclip search docker

# Run by ID
cmdclip run a3f9
## 🛠 Build Instructions

# Dry-run with AI explanation
cmdclip run a3f9 --dry-run
### Prerequisites
1. Install [Flutter SDK](https://docs.flutter.dev/get-started/install). Ensure `flutter doctor` passes successfully.
2. For desktop builds, ensure you have the appropriate native compiler toolchain installed.

# AI explain any saved command
cmdclip explain a3f9

# Import from shell history (smart — picks commands used 5+ times)
cmdclip history

# Export / import
cmdclip export --output backup.json
cmdclip import backup.json --safe

# Share as a snippet (copies to clipboard)
cmdclip share a3f9

# Usage stats
cmdclip stats
### 🐧 1. Linux Desktop
Install build dependencies (on Ubuntu/Debian):
```bash
sudo apt-get update
sudo apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev lld
```

---

## AI features (Groq)

Build the release bundle:
```bash
# Save your Groq API key once
cmdclip config set-key gsk_xxxxxxxxxxxx

# Now add / explain / dry-run all use AI automatically
flutter build linux --release
```
The compiled binary can be found under:
`build/linux/x64/release/bundle/cmdclip`

Get a free key at [console.groq.com](https://console.groq.com).

---

## Command templates

Use `{variable}` or `{variable=default}` syntax:

### 🪟 2. Windows Desktop
Ensure you have "Desktop development with C++" installed via Visual Studio Installer.
Build the release bundle:
```bash
cmdclip add "ssh {user}@{host} -p {port=22}" --name ssh-connect
cmdclip run <id>
# Fill in: user? host? port [22]?
flutter build windows --release
```
The executable can be found under:
`build\windows\x64\release\runner\cmdclip.exe`

---

## Safe mode

Import with `--safe` to automatically quarantine dangerous commands
(`rm -rf`, `sudo rm`, `DROP TABLE`, etc.) into a separate file.

### 🤖 3. Android Mobile
Ensure Android SDK & command-line tools are installed.
Build the release APK:
```bash
cmdclip import backup.json --safe
flutter build apk --release
```
The generated APK can be found under:
`build/app/outputs/flutter-apk/app-release.apk`

---

## Cross-platform paths
## 🧪 Running Tests

| OS | Data directory |
|----|---------------|
| Linux / macOS | `~/.cmdclip/` |
| Windows | `%LOCALAPPDATA%\cmdclip\` |
A comprehensive unit, integration, and widget test suite is included. To execute all tests, run:
```bash
flutter test
```

---

## License

GNU General Public License v3.0 — see [LICENSE](LICENSE)
© M5 Dev
## GPL-3.0 License
© cmdclip developers. Licensed under the GNU General Public License v3.0. See [LICENSE](LICENSE) for details.
28 changes: 28 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# This file configures the analyzer, which statically analyzes Dart code to
# check for errors, warnings, and lints.
#
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.

# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml

linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at https://dart.dev/lints.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
# or a specific dart file by using the `// ignore: name_of_lint` and
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
14 changes: 14 additions & 0 deletions android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
gradle-wrapper.jar
/.gradle
/captures/
/gradlew
/gradlew.bat
/local.properties
GeneratedPluginRegistrant.java
.cxx/

# Remember to never publicly share your keystore.
# See https://flutter.dev/to/reference-keystore
key.properties
**/*.keystore
**/*.jks
44 changes: 44 additions & 0 deletions android/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
plugins {
id("com.android.application")
id("kotlin-android")
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
id("dev.flutter.flutter-gradle-plugin")
}

android {
namespace = "com.cmdclip.cmdclip"
compileSdk = flutter.compileSdkVersion
ndkVersion = flutter.ndkVersion

compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.toString()
}

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId = "com.cmdclip.cmdclip"
// You can update the following values to match your application needs.
// For more information, see: https://flutter.dev/to/review-gradle-config.
minSdk = flutter.minSdkVersion
targetSdk = flutter.targetSdkVersion
versionCode = flutter.versionCode
versionName = flutter.versionName
}

buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig = signingConfigs.getByName("debug")
}
}
}

flutter {
source = "../.."
}
7 changes: 7 additions & 0 deletions android/app/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- The INTERNET permission is required for development. Specifically,
the Flutter tool needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>
Loading
Loading