Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/epilande/alfred-prettier-clipboard
🎨 Format code in your clipboard with Prettier
https://github.com/epilande/alfred-prettier-clipboard
alfred alfred-workflow clipboard code format prettier workflow
Last synced: about 2 months ago
JSON representation
🎨 Format code in your clipboard with Prettier
- Host: GitHub
- URL: https://github.com/epilande/alfred-prettier-clipboard
- Owner: epilande
- License: mit
- Created: 2020-12-29T19:40:00.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-01-14T19:31:46.000Z (over 2 years ago)
- Last Synced: 2024-04-06T15:33:51.883Z (5 months ago)
- Topics: alfred, alfred-workflow, clipboard, code, format, prettier, workflow
- Language: JavaScript
- Homepage:
- Size: 10.1 MB
- Stars: 53
- Watchers: 4
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Alfred Prettier Clipboard 🎨
Format code in your clipboard with Prettier
## Why?
Sometimes you're writing code in a textarea where you don't have plugins/extension to automatically format your code.
Rather than manually formatting, you can run prettier on it with this workflow.## Requirements
- [`node`](https://nodejs.org/) - Node.js JavaScript runtime.
- [`prettier`](https://prettier.io/) - Opinionated Code Formatter.## Installation
1. Install dependencies [`node`](https://nodejs.org/) and [`prettier`](https://prettier.io/) (must be installed globally).
1. Download the Alfred Workflow ([Prettier-Clipboard.alfredworkflow](https://github.com/epilande/alfred-prettier-clipboard/releases/latest/download/Prettier-Clipboard.alfredworkflow)).
1. Double-click to import into Alfred (requires Powerpack).
1. Customize prettier with workflow variable `PRETTIER_OPTIONS` or `.prettierrc` (see [configuration](#configuration)).## Usage
`prettier {parser}` - Run prettier on your clipboard with selected `{parser}`.
## Demo
## Environment variables
| Key | Default | Description |
| ------------------ | ------------------ | ------------------------------------------- |
| `PRETTIER_OPTIONS` | | Options to be passed to `prettier` command. |
| `PRETTIER_PATH` | `"/usr/local/bin"` | Where to find `prettier`. |## Configuration
To customize prettier, we can either pass options with environment variables `PRETTIER_OPTIONS` or create a configuration file i.e. `.prettierrc`.
#### `PRETTIER_OPTIONS`
With `PRETTIER_OPTIONS` we can use the CLI overrides from https://prettier.io/docs/en/options.html.
#### Configuration file
Prettier will automatically pick up configuration files, so we can customize prettier by adding a `.prettierrc` file in the workflow directory or globally at `~/.prettierc`.
To add `.prettierrc` in the workflow directory
1. Go to Alfred workflows, find Prettier Clipboard. You can also do this by typing `?prettier` in Alfred.
1. Right-click -> Open in terminal.
1. Create `.prettierrc` for example: `$ echo '{ "semi": false, "trailingComma": "all" }' > .prettierrc`
(see https://prettier.io/docs/en/options.html for available options).## More workflows
- 🔍 [alfred-browser-tabs](https://github.com/epilande/alfred-browser-tabs) - Search browser tabs from Chrome, Brave, & Safari.
- 🤫 [alfred-be-quiet](https://github.com/epilande/alfred-be-quiet) - Workflow to automatically pause audio/video playing.
- 🔐 [alfred-wifi-password](https://github.com/epilande/alfred-wifi-password) - Get Wi-Fi password from Keychain.
- 🗝 [alfred-password-generator](https://github.com/epilande/alfred-password-generator) - Workflow to generate passwords.## License
[MIT License](https://oss.ninja/mit/epilande/)