forked from raycast/script-commands
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate-image-from-code.sh
executable file
·44 lines (36 loc) · 1.55 KB
/
create-image-from-code.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Create Image from Code
# @raycast.mode silent
# Optional parameters:
# @raycast.icon ./images/ray-so.png
# @raycast.argument1 { "type": "text", "placeholder": "Title", "optional": true }
# Documentation:
# @raycast.description Create beautiful images of your code with https://ray.so
# @raycast.author Thomas Paul Mann
# @raycast.authorURL https://github.com/thomaspaulmann
# Customization:
# Set colors. Available options: candy, breeze, midnight or sunset
COLORS="midnight"
# Toggle background. Available options: true or false
BACKGROUND="true"
# Toggle dark mode. Available options: true or false
DARK_MODE="true"
# Set padding. Available options: 16, 32, 64 or 128
PADDING="64"
# Set language. Available options: shell, cpp (C/C++), csharp, clojure, coffeescript, crystal, css, d, dart, diff, dockerfile, elm, erlang, fortran, gherkin,
# go, groovy, haskell, xml, java, javascript, json, jsx, julia, kotlin, latex, lisp, lua, markdown, mathematica, octave, nginx, objectivec, ocaml (F#), perl, php,
# powershell, python, r, ruby, rust, scala, smalltalk, sql, swift, typescript, (for Tsx, use jsx), twig, verilog, vhdl, xquery, yaml
LANGUAGE="auto"
# Main:
if [[ -z "$1" ]]
then
TITLE="Untitled-1"
else
TITLE=$(php -r "echo urlencode(\"$1\");")
fi
CODE=$(pbpaste | base64)
# Urlencode any + symbols in the base64 encoded string
CODE=${CODE//+/%2B}
open "https://ray.so/?colors=$COLORS&background=$BACKGROUND&darkMode=$DARK_MODE&padding=$PADDING&title=$TITLE&code=$CODE&language=$LANGUAGE"