npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

smartsh

v0.3.12

Published

Cross-shell command runner enabling Unix-style syntax on any OS.

Downloads

142

Readme

smartsh (alias: sm)

A tiny cross-shell command runner that enables Unix-style commands and connectors (&&, ||) on any OS or shell, with automatic translation of common Unix commands to native PowerShell equivalents.


# ⚡ Smartsh (`sm`) – Universal Cross-Shell Command Translator

[![Install](https://img.shields.io/badge/Install-npm%20i%20--g%20smartsh-CB3837?logo=npm)](https://www.npmjs.com/package/smartsh)
[![npm version](https://img.shields.io/npm/v/smartsh?logo=npm)](https://www.npmjs.com/package/smartsh)
[![Downloads](https://img.shields.io/npm/dm/smartsh)](https://www.npmjs.com/package/smartsh)
[![Install size](https://packagephobia.com/badge?p=smartsh)](https://packagephobia.com/result?p=smartsh)
[![Build & Publish](https://img.shields.io/github/actions/workflow/status/thegreatbey/smartsh/publish.yml?branch=main&label=Build%20%26%20Publish)](https://github.com/thegreatbey/smartsh/actions/workflows/publish.yml)
[![Tests](https://img.shields.io/github/actions/workflow/status/thegreatbey/smartsh/test-npm.yml?branch=main&label=Tests)](https://github.com/thegreatbey/smartsh/actions/workflows/test-npm.yml)
[![License: MIT](https://img.shields.io/npm/l/smartsh)](LICENSE)



---

### **Write Once. Run Anywhere.**
Run **Unix commands on Windows** and **Windows commands on Unix/macOS** without rewriting scripts.

---

## ✅ Features
- **Full Bidirectional Translation**  
  - Unix → PowerShell/CMD  
  - PowerShell/CMD → Unix  
- **Cross-Shell Connectors**  
  Handles `&&`, `||`, pipes, and redirections  
- **Command Coverage**  
  - 171 Unix → PowerShell  
  - 70 Unix → CMD  
  - 484 Windows → Unix reverse translations  
- **Lightweight**  
  - Built: **~904 KB**  
  - Published: **~190 KB**  
- **Zero runtime dependencies**  
- Tested: **251 tests passing**

---

## 📦 Install
```bash
# Global install
npm install -g smartsh

# Or use without install
npx smartsh "rm -rf dist && npm run build"

🚀 Usage

Unix → Windows

sm "rm -rf dist && npm run build"

# PowerShell output:
Remove-Item -Recurse -Force dist; if ($?) { npm run build }

Windows → Unix

sm --reverse "Remove-Item -Recurse -Force dist; npm run build"
# Output:
rm -rf dist && npm run build

🖥 CLI Options

| Flag | Description | | ------------------ | ---------------------------------- | | --reverse | Translate Windows → Unix | | --target <shell> | Force a target shell | | --translate-only | Show translation without execution | | --debug | Verbose logs |


🔍 Examples

# Unix → Windows (PowerShell)
sm "ls -la | grep .ts && echo Done"
# -> Get-ChildItem -Force | Select-String '.ts'; if ($?) { echo Done }

# Windows → Unix
sm --reverse "Get-ChildItem | Select-String .ts; echo Done"
# -> ls | grep .ts && echo Done

🧪 Tests

pnpm test
# 16 files, 251 tests — all passing

⚡ Why Smartsh?

| Feature | Smartsh | shx | cross-env | | ---------------- | ------- | --- | --------- | | Unix→Windows | ✅ | ✅ | ❌ | | Windows→Unix | ✅ | ❌ | ❌ | | Handles &&, || | ✅ | ✅ | ❌ | | Lightweight | ✅ | ✅ | ✅ |


🔥 What’s Cool

  • Bidirectional Translation Added
  • PowerShell → Unix + CMD → Unix support
  • 484 reverse mappings
  • Size optimization: ~190 KB published
  • 251 tests passing, including bidirectional coverage

🛠 Dev Commands

Clean old builds

Windows PowerShell

Remove-Item .\smartsh-*.tgz -Force
Remove-Item .\dist -Recurse -Force

Windows CMD

del smartsh-*.tgz
rmdir /S /Q dist

Unix

rm -rf smartsh-*.tgz dist

Build & Publish

npm version patch
pnpm build
git add -A
git commit -m "update bidirectional support"
git push origin main
npm publish --access public

📜 License

MIT © 2025 cavani21 & Smartsh Contributors

Command Coverage Details
Smartsh doesn’t have equal coverage in every direction. Here’s why:

Why CMD Coverage is Smaller
CMD is a very limited shell compared to PowerShell.

Many Unix utilities (grep, awk, sed, etc.) have no direct CMD equivalent.

CMD lacks advanced flags, pipelines, and scripting capabilities.

Result: Only basic commands (file ops, directory listing) are supported for CMD.

Recommendation: PowerShell is the preferred Windows target.

Why Windows → Unix Has Higher Count
Reverse mapping combines PowerShell + CMD → Unix.

PowerShell commands often have multiple flag combinations that map to shorter Unix equivalents:

Remove-Item -Recurse -Force → rm -rf

Get-ChildItem → ls

Each variation counts as a separate mapping.

CMD adds additional mappings (e.g., copy → cp, move → mv).

Result: More total translations when going Windows → Unix.

| Direction | Count | | ----------------- | ----- | | Unix → PowerShell | 171 | | Unix → CMD | 70 | | Windows → Unix | 484 |


Command Coverage
Unix → PowerShell: 171 commands

Unix → CMD: 70 commands

Windows → Unix: 484 translations

Why CMD coverage is smaller?
CMD is very limited compared to PowerShell, so only basic commands (like copy, move, del) are supported.

Why Windows → Unix has more?
Reverse mapping combines PowerShell + CMD and accounts for multiple flag variations, resulting in a higher count.