Skip to content

Commit

Permalink
Add Code Scratchpad action (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
mirka committed Mar 28, 2021
1 parent 79a986a commit 41d1da9
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 0 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ _Requires LaunchBar 6+._
<!-- toc -->

- [Actions](#actions)
* [Code Scratchpad](#code-scratchpad)
* [Copy Application Icon](#copy-application-icon)
* [New File Here](#new-file-here)
* [Relaunch Application](#relaunch-application)
Expand All @@ -21,6 +22,14 @@ _Requires LaunchBar 6+._

## Actions

### Code Scratchpad

<img src="https://raw.githubusercontent.com/mirka/launchbar-actions/master/assets/code-scratchpad.gif" alt="Typing the extension 'json' into the LaunchBar input" width="480">

Open a temporary scratchpad file with a given extension.

This is for when you want to quickly type out a few lines of code, but with proper indentation and syntax highlighting. (The assumption being that, you have your Finder set up to open files with certain extensions in the code editor of your choice.)

### Copy Application Icon

Given an application, copy its icon to the clipboard.
Expand Down
Binary file added assets/code-scratchpad.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 41 additions & 0 deletions src/code-scratchpad/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleIconFile</key>
<string>font-awesome:code</string>
<key>CFBundleIdentifier</key>
<string>com.jaguchi.LaunchBar.action.CodeScratchpad</string>
<key>CFBundleName</key>
<string>Code Scratchpad</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>LBArgument</key>
<string>File extension for the language.</string>
<key>LBDescription</key>
<dict>
<key>LBArgument</key>
<string>File extension for the desired language.</string>
<key>LBSummary</key>
<string>Open a temporary scratchpad with the given file type.</string>
</dict>
<key>LBMinimumLaunchBarVersion</key>
<integer>6</integer>
<key>LBScripts</key>
<dict>
<key>LBDefaultScript</key>
<dict>
<key>LBAcceptedArgumentTypes</key>
<array>
<string>string</string>
</array>
<key>LBRequiresArgument</key>
<true/>
<key>LBScriptName</key>
<string>default.scpt</string>
</dict>
</dict>
<key>LBTextInputTitle</key>
<string>File extension</string>
</dict>
</plist>
7 changes: 7 additions & 0 deletions src/code-scratchpad/Scripts/default.applescript
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
on handle_string(extension)
tell application "Finder"
set filename to (do shell script "date +%s") & "." & extension
set temp_file to make new file at (path to temporary items) with properties {name:filename}
open temp_file
end tell
end handle_string

0 comments on commit 41d1da9

Please sign in to comment.