Scriptable クリップボード & Custom Actions
L2Cache lets you build your own custom クリップボード Actions using standard shell commands, ruby scripts, or AI Prompts. Scoped dynamically to target only specific content types.
Standard clipboard managers are passive filing cabinets. They store your copied strings but can't do anything with them. If you want to transform a clipboard item (e.g. format JSON, strip formatting, extract IDs), you are forced to paste it into a scratchpad app, modify it, and copy it back.
L2Cache makes your clipboard programmable. With Custom Shell Actions, you can run any tool that accepts standard input (stdin), processes it, and returns the output via standard output (stdout).
How Custom Shell Actions Work
When you create a custom action, you write a standard shell command. When you copy an item and trigger that action:
- L2Cache pipes the copied text directly into the standard input (
stdin) of your shell script. - Your shell script executes (using
/bin/bash -cunder the hood). - L2Cache intercepts the output (
stdout) and updates the clipboard copy with the formatted result.
💡 Accessing the clipboard text: Your command receives the clipboard string via standard input (stdin). You can read it directly in Ruby using STDIN.read, in Perl using default inputs, or inside bash/curl commands using $(cat) to pass it as a parameter.
Scoped Content Filtering
You don't want a "Format SQL" action cluttering your options when you copy an image or a URL. L2Cache lets you choose exactly which content types trigger your action:
- JSON, YAML, XML, SQL, Markdown, GraphQL
- Docker commands, Kubernetes manifests, AWS resources
- Git URLs, raw URLs, plain text, or code blocks
11 Shell Action Recipes to Try
curl -s -X POST -H "Content-Type: application/json" -d "$(cat)" http://localhost:3000/api/webhook
id, name, email, price, created_at) and generate mock JSON output instantly.ruby -rjson -rtime -e '
fields = STDIN.read.strip.split(/\s*,\s*|\s+/)
mock = fields.each_with_object({}) do |f, h|
h[f] = case f
when /id/i; rand(1000..9999)
when /email/i; "user@example.com"
when /name/i; "John Doe"
when /created_at|updated_at|date/i; Time.now.utc.iso8601
when /status/i; "active"
when /price|amount/i; rand(9.99..99.99).round(2)
else; "mock_value"
end
end
puts JSON.pretty_generate(mock)
'
ruby -ruri -e '
uri = URI.parse(STDIN.read.strip)
if uri.query
params = URI.decode_www_form(uri.query).reject { |k,_| k.start_with?("utm_") }
uri.query = params.empty? ? nil : URI.encode_www_form(params)
end
puts uri.to_s
'
ruby -rjson -e '
sql = STDIN.read
fields = sql.scan(/(\w+)\s+(VARCHAR|INT|TEXT|TIMESTAMP|DATETIME)/i)
puts JSON.pretty_generate(fields.to_h.transform_values(&:downcase))
'
curl -s -F "f:1=$(cat)" ix.io
ruby -rtime -e '
val = STDIN.read.strip.to_i
val = val / 1000 if val > 9999999999
t = Time.at(val)
puts "Local: #{t.strftime("%Y-%m-%d %H:%M:%S %Z")}"
puts "UTC: #{t.utc.strftime("%Y-%m-%d %H:%M:%S UTC")}"
puts "ISO: #{t.iso8601}"
'
ruby -e '
str = STDIN.read.strip
if str =~ /_/
puts str.gsub(/_([a-z])/) { $1.upcase }
else
puts str.gsub(/([a-z\d])([A-Z])/, "\\1_\\2").downcase
end
'
ruby -rcsv -e '
rows = CSV.parse(STDIN.read.strip)
exit if rows.empty?
headers = rows.first
divider = headers.map { |h| "-" * [h.to_s.length, 3].max }
puts "| " + headers.map(&:to_s).join(" | ") + " |"
puts "| " + divider.join(" | ") + " |"
rows[1..].each do |row|
next if row.nil? || row.empty?
puts "| " + row.map { |v| v.to_s.gsub("|", "\\|") }.join(" | ") + " |"
end
'
ruby -rcgi -e 'puts CGI.escapeHTML(STDIN.read)'
ruby -rjson -e 'puts JSON.dump(STDIN.read.strip)'
ruby -rjson -e '
def redact(obj)
case obj
when Hash
obj.each_with_object({}) do |(k, v), h|
if k.to_s =~ /password|secret|key|token|auth|email|card|phone/i
h[k] = "[REDACTED]"
else
h[k] = redact(v)
end
end
when Array
obj.map { |v| redact(v) }
else
obj
end
end
puts JSON.pretty_generate(redact(JSON.parse(STDIN.read)))
'
📋 Copy this sample payload to your clipboard to test the action:
{
"user": "dinesh_dev",
"email": "dinesh@example.com",
"session": {
"auth_token": "live_tok_9823fha8921fh",
"expires_at": "2026-09-01T00:00:00Z"
},
"payment": {
"card_number": "4111-2222-3333-4444",
"amount_usd": 49.00
},
"config": {
"debug_mode": true,
"aws_secret": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
}
}
Custom AI Prompt Actions
Beyond traditional shell scripts, L2Cache allows you to define Custom AI Prompts that execute locally (via Ollama) or via cloud (Anthropic, OpenAI) against your clipboard contents.
Create a TypeScript interface for this JSON payload. Use proper typings and nested interfaces where appropriate.
Explain this bash command step-by-step and describe what each flag does in plain English.
Summarize this error log, explain the likely root cause, and suggest a fix. Keep it concise.
Analyze this code snippet for security vulnerabilities, such as injection flaws or memory leaks, and suggest improvements.
Local by Default, External Only When You Choose
Custom Shell Actions execute locally on your Mac. Commands that use local scripts, command-line tools, or localhost services can process clipboard content without sending it to a cloud service. If you create and invoke an action that calls an external API, webhook, or cloud LLM, that command sends the selected clipboard content to the endpoint you configured. Review the destination and its privacy policy before transmitting sensitive or proprietary data.
Looking for practical ideas? Explore these developer clipboard automation workflows for testing local APIs, replaying webhooks, querying developer tools, and invoking services you choose.