- Created by epilande
- 🗓 Last Updated: 14/01/22 19:31:46
- 🌟 Stars on GitHub: 52
- Please consider supporting the creator by Starring or Sponsoring them on GitHub!
- Get Latest Release
- Get Source Code
From their 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
Installation
- Install dependencies
node
andprettier
(must be installed globally). - Download the Alfred Workflow (Prettier-Clipboard.alfredworkflow).
- Double-click to import into Alfred (requires Powerpack).
- Customize prettier with workflow variable
PRETTIER_OPTIONS
or.prettierrc
(see 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
- Go to Alfred workflows, find Prettier Clipboard. You can also do this by typing
?prettier
in Alfred. - Right-click -> Open in terminal.
- 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 - Search browser tabs from Chrome, Brave, & Safari.
- 🤫 alfred-be-quiet - Workflow to automatically pause audio/video playing.
- 🔐 alfred-wifi-password - Get Wi-Fi password from Keychain.
- 🗝 alfred-password-generator - Workflow to generate passwords.