fcmd is a lightweight command-line application written in Go that helps users discover and manage popular command-line utilities across Windows, macOS, and Linux. It maintains an SQLite database of commands, each with a short description, and supports searching, adding, and deleting entries.
Features
- Search: Keyword-based search on command names or descriptions (e.g.,
fcmd git)
- Add: Insert new commands with descriptions (e.g.,
fcmd -a "Clone a Git repo" git clone <url>)
- Delete: Remove entries by 1-based index from the last search (e.g.,
fcmd -r 2)
- Cross-platform: Works on Windows, macOS, and Linux
- Automatic seeding: Pre-populated with common commands for each OS
- SQLite database: Lightweight, file-based storage
Installation
From Source
git clone https://github.com/orvado/fcmd.git
cd fcmd
go build -o fcmd ./cmd/fcmd
Using Go Install
go install github.com/orvado/fcmd@latest
Usage
Basic Commands
Search Commands
Search for commands by keyword:
# Search for git commands
fcmd git
# Search for file operations
fcmd file
# Search for network commands
fcmd network
Add New Commands
Add a new command with a description:
# Add a new command
fcmd -a "List files in long format" ls -la
# Add a complex command
fcmd -a "Find large files over 100MB" find . -type f -size +100M
Delete Commands
Delete a command by its index from the last search:
# First search to get the index
fcmd git
# Then delete by index (e.g., delete the 2nd result)
fcmd -r 2
Advanced Options
Target Specific OS
Search or add commands for a specific operating system:
# Search Windows commands from any OS
fcmd --os=windows dir
# Add a Linux command from any OS
fcmd --os=linux -a "List packages" apt list --installed
Search All OSes
Search across all operating systems:
# Search for ping commands on all OSes
fcmd --all ping
Get Help
fcmd --help
Examples
Example 1: Finding Git Commands
$ fcmd git
Found 5 command(s) for: git
1. git clone <url> - Clone Git repository [linux]
2. git status - Show Git status [linux]
3. git add . - Stage all changes [linux]
4. git commit -m "message" - Commit changes [linux]
5. git push - Push to remote [linux]
Example 2: Adding a Custom Command
$ fcmd -a "Show system uptime" uptime
Added: uptime - Show system uptime
$ fcmd --all list directory
Found 3 command(s) for: list directory
1. ls -la - List all files with details [linux]
2. dir - List directory contents [windows]
3. ls -la - List all files with details [macos]
Database
The application stores its data in an SQLite database located at:
- Windows:
%USERPROFILE%\.fcmd\fcmd.db
- macOS/Linux:
~/.fcmd/fcmd.db
Initial Seeding
On first run, the database is automatically seeded with hundreds of common commands for each operating system, including:
- Linux: File operations, system administration, networking, development tools
- macOS: Unix commands, macOS-specific utilities, Homebrew commands
- Windows: CMD commands, PowerShell commands, Windows utilities
Development
Project Structure
fcmd/
├── cmd/
│ └── fcmd/
│ └── main.go # Entry point
├── internal/
│ ├── db/ # Database operations
│ │ ├── schema.sql
│ │ ├── seed.go
│ │ └── db.go
│ ├── cli/ # CLI commands
│ │ └── commands.go
│ └── models/ # Data structures
│ └── command.go
├── go.mod
├── go.sum
└── README.md
Building
go build -o fcmd ./cmd/fcmd
Cross-Compilation
# Windows
GOOS=windows GOARCH=amd64 go build -o fcmd.exe ./cmd/fcmd
# macOS
GOOS=darwin GOARCH=amd64 go build -o fcmd-darwin ./cmd/fcmd
# Linux
GOOS=linux GOARCH=amd64 go build -o fcmd-linux ./cmd/fcmd
Dependencies
Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature)
- Commit your changes (
git commit -m 'Add amazing feature')
- Push to the branch (
git push origin feature/amazing-feature)
- Open a Pull Request
Adding New Commands
To add new commands to the seed data, edit internal/db/seed.go and add entries to the SeedData slice:
{"linux", "new-command", "Description of the command"},
{"windows", "windows-command", "Windows-specific command"},
{"macos", "macos-command", "macOS-specific command"},
License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Troubleshooting
Database Issues
If you encounter database issues, you can reset the database by deleting the database file:
# Windows
del %USERPROFILE%\.fcmd\fcmd.db
# macOS/Linux
rm ~/.fcmd/fcmd.db
The database will be recreated and reseeded on the next run.
Permission Issues
If you encounter permission issues, ensure you have write access to your home directory and the .fcmd subdirectory.
Build Issues
If you encounter build issues, ensure you have Go 1.21+ installed and run:
go mod tidy
go build -o fcmd ./cmd/fcmd