quick-sh
v1.0.8
Published
A local script management tool for quick execution of JavaScript and Shell scripts with alias support
Downloads
11
Maintainers
Readme
Quick Sh
A local script management tool for quick execution of JavaScript and Shell scripts with advanced alias support.
中文文档 | English
Features
- 🚀 Quick Execution: Run local scripts with simple
q script-namecommand - 📁 Multiple Formats: Support JavaScript (.js), Shell scripts (.sh), and directories
- 🔗 Advanced Aliases: Configure custom aliases with relative paths, absolute paths, and system commands
- 📝 Parameter Forwarding: Pass arguments transparently to your scripts
- 🎯 Smart Priority: Alias config > Script files > System commands
- ⚡ Global Access: Install once, use anywhere
- 🧪 Comprehensive Testing: 16 automated test cases ensure reliability
Installation
npm install -g quick-shAfter installation, you can use the q command globally.
Quick Start
1. Set Script Directory
# Set your script directory
q -path /path/to/your/scripts
# Check current status
q -list2. Run Scripts
# Run a JavaScript file
q myscript
# Run a shell script
q deploy.sh
# Run with parameters
q backup --target /data --compress
# Execute directory (looks for index.js or index.sh)
q myproject3. Configure Aliases
Create or edit config.json in your script directory:
{
"aliases": {
"deploy": {
"bin": "./deploy/index.js"
},
"backup": {
"bin": "/usr/local/bin/backup.sh"
},
"start": {
"bin": "npm start"
}
}
}Commands
| Command | Description | Example |
|---------|-------------|---------|
| q -path <dir> | Set script directory | q -path ~/scripts |
| q -list | Show current status and available scripts | q -list |
| q -help | Display help information | q -help |
| q <script> | Execute script or alias | q deploy |
Alias Configuration
Supported Alias Types
Relative Path: Relative to script directory
{ "aliases": { "deploy": {"bin": "./deploy/index.js"} } }Absolute Path: Full system path
{ "aliases": { "backup": {"bin": "/usr/local/bin/backup.sh"} } }System Command: Execute system commands
{ "aliases": { "list": {"bin": "ls -la"}, "findnode": {"bin": "which node"} } }
Execution Priority
- Alias Configuration (highest priority)
- Script Files (medium priority)
- System Commands (lowest priority)
Parameter Forwarding
All parameters are transparently forwarded to target scripts:
# These parameters will be passed to the script
q deploy --env production --verbose
q backup /data/important --compressIn your script, access parameters normally:
- JavaScript:
process.argv - Shell:
$1,$2, etc.
Examples
Directory Structure
~/scripts/
├── config.json
├── deploy.js
├── backup.sh
└── utils/
└── index.jsconfig.json
{
"aliases": {
"deploy": {"bin": "./deploy.js"},
"util": {"bin": "./utils"},
"backup": {"bin": "./backup.sh"},
"start": {"bin": "npm start"}
}
}Usage
# Execute via alias
q deploy --env prod
# Execute shell script
q backup.sh /data
# Execute directory (looks for utils/index.js)
q utils --help
# System command via alias
q startDevelopment
Testing
# Run all tests
npm test
# Manual testing with example scripts
npm run test:manualProject Structure
quick-sh/
├── bin/ # CLI entry point
├── lib/ # Core modules
│ ├── config.js # Configuration management
│ ├── executor.js # Script execution
│ ├── help.js # Help text
│ ├── script-manager.js # Main logic
│ └── utils.js # Utilities
├── test/ # Test suite
└── examples/ # Example scriptsRequirements
- Node.js >= 14.0.0
- npm or yarn
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Author
- Young6118 - Initial work
Support
If you encounter any issues or have questions, please open an issue on GitHub.
