https://github.com/lvqq/command-alias
Generate alias for different command system
https://github.com/lvqq/command-alias
alias bash command windows-powershell zsh
Last synced: about 2 months ago
JSON representation
Generate alias for different command system
- Host: GitHub
- URL: https://github.com/lvqq/command-alias
- Owner: lvqq
- License: mit
- Created: 2022-12-01T17:36:55.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-05-07T04:20:48.000Z (about 3 years ago)
- Last Synced: 2025-03-12T23:02:11.550Z (over 1 year ago)
- Topics: alias, bash, command, windows-powershell, zsh
- Language: TypeScript
- Homepage:
- Size: 62.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# command-alias
[](https://www.npmjs.com/package/command-alias)  [](https://coveralls.io/github/lvqq/command-alias?branch=main) 
Generate alias for different command system, support `zsh/bash` and `Windows Command/PowerShell`.
## Usage
### Installation
```bash
# npm
npm install command-alias --save-dev
# yarn
yarn add command-alias --dev
# pnpm
pnpm add command-alias --save-dev
```
### Api
Using the following api will generate a few alias file under output directory throught `alias.yaml`:
```typescript
import { transform } from 'command-alias'
transform('alias.yaml', 'output')
```
### Params
```typescript
type generateCommandAliasByPlugin = (
source: string,
outDir: string,
options?: Options
) => Promise
type Options = {
filename?: string;
plugins?: string[];
}
```
#### source
Alias config filepath, support `json/yaml` format.
- source file yaml [example](https://github.com/x-toolkit/command-alias/blob/main/test/fixtures/alias.yaml):
```yaml
part1:
sa: short alias
part2:
saa: short alias with optionA
sab: short alias with optionB
```
- source file json [example](https://github.com/x-toolkit/command-alias/blob/main/test/fixtures/alias.json):
```json
{
"part1": {
"sa": "short alias"
},
"part2": {
"saa": "short alias with optionA",
"sab": "short alias with optionB"
}
}
```
#### outDir
Alias output directory, all alias files will be placed under outDir.
#### options
Optional configs.
##### options.filename
Define the output filename, default is `alias`.
##### options.plugins
Define the using plugins to generate, without specifying will use all plugins by default.
Support options:
- `sh`: for bash-like command, like `zsh/bash`
- `bat`: for `Windows Command`
- `ps1`: for `Windows PowerShell`
## Development
Install dependencies:
```bash
pnpm install
```
Make changes and run tests:
```bash
pnpm run test
```
# License
[MIT](https://github.com/x-toolkit/command-alias/blob/main/LICENSE)