Last active
June 23, 2022 07:45
-
-
Save Ptujec/725b2f2239a608ec2e1e67096965e896 to your computer and use it in GitHub Desktop.
My Snippets for LaunchBar Actions in VS Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
// LaunchBar Snippets | |
"LaunchBar alert": { | |
"prefix": "lAlert", | |
"body": "LaunchBar.alert($1);", | |
"description": "Creates a LaunchBar alert code" | |
}, | |
"LaunchBar alert with response": { | |
"prefix": "lAlertResponse", | |
"body": [ | |
"var response = LaunchBar.alert(", | |
" '${1:title}',", | |
" '${2:subtitle}',", | |
" '${3:Ok}',", | |
" '${4:Cancel}',", | |
");", | |
" switch (response) {", | |
" case 0:", | |
" // Ok … do something", | |
" $5", | |
" case 1:", | |
" break;", | |
"}" | |
], | |
"description": "Creates a LaunchBar alert with response code" | |
}, | |
"LaunchBar paste": { | |
"prefix": "lPaste", | |
"body": "LaunchBar.paste($1);", | |
"description": "Creates a LaunchBar paste code" | |
}, | |
"LaunchBar getClipboardString": { | |
"prefix": "lGetClipboardString", | |
"body": "LaunchBar.getClipboardString($1);", | |
"description": "Creates a LaunchBar getClipboardString code" | |
}, | |
"LaunchBar setClipboardString": { | |
"prefix": "lSetClipboardString", | |
"body": "LaunchBar.setClipboardString($1);", | |
"description": "Creates a LaunchBar setClipboardString code" | |
}, | |
"LaunchBar clearClipboard": { | |
"prefix": "lClearClipboard", | |
"body": "LaunchBar.clearClipboard();", | |
"description": "LaunchBar clearClipboard" | |
}, | |
"LaunchBar displayNotification": { | |
"prefix": "lNotification", | |
"body": [ | |
"LaunchBar.displayNotification({", | |
" title: $1,", | |
" string: $2,", | |
" url: $3", | |
"});" | |
], | |
"description": "Creats a LaunchBar Notification code" | |
}, | |
"LaunchBar displayInLargeType": { | |
"prefix": "lLargeType", | |
"body": [ | |
"LaunchBar.displayInLargeType({", | |
" title: $1,", | |
" string: $2,", | |
" sound: 'Purr'", | |
"});" | |
], | |
"description": "Creats a LaunchBar Large Type code" | |
}, | |
"LaunchBar openURL": { | |
"prefix": "lOpenURL", | |
"body": [ | |
"LaunchBar.openURL($1);" | |
], | |
"description": "Creats a LaunchBar Open URL code" | |
}, | |
"LaunchBar hide": { | |
"prefix": "lHide", | |
"body": [ | |
"LaunchBar.hide();" | |
], | |
"description": "Creats a LaunchBar Hide code" | |
}, | |
"LaunchBar performAction": { | |
"prefix": "lPerformAction", | |
"body": [ | |
"LaunchBar.performAction(${1:actionName}, ${2:argument});" | |
], | |
"description": "Creats a LaunchBar performAction code" | |
}, | |
"LaunchBar execute": { | |
"prefix": "lExecute", | |
"body": [ | |
"var ${1:result} = LaunchBar.execute('${2:/usr/bin/grep}', '$3');" | |
], | |
"description": "Create LaunchBar execute code" | |
}, | |
"LaunchBar executeAppleScriptFile": { | |
"prefix": "lASF", | |
"body": [ | |
"var ${1:output} = LaunchBar.executeAppleScriptFile('.${2:/}', ${3:argument})", | |
" .trim()" | |
], | |
"description": "Creat LaunchBar executeAppleScriptFile code" | |
}, | |
"LaunchBar executeAppleScript": { | |
"prefix": "lAS", | |
"body": [ | |
"LaunchBar.executeAppleScript(", | |
" 'tell application \"${1:System Events}\"',", | |
" ' ${2:-- do something}',", | |
" 'end tell'", | |
");" | |
], | |
"description": "Create LaunchBar executeAppleScript code" | |
}, | |
"LaunchBar formatDate": { | |
"prefix": "lFormatDate", | |
"body": [ | |
"var ${1:newDate} = LaunchBar.formatDate(new Date($2), {", | |
" relativeDateFormatting: ${3:true},", | |
" timeStyle: '${4:short}',", | |
" dateStyle: '${5:full}'", | |
"});" | |
], | |
"description": "Create LaunchBar formatDate code" | |
}, | |
"LaunchBar Key Options": { | |
"prefix": "lKeyOptions", | |
"body": [ | |
"if (LaunchBar.options.${1|shiftKey,controlKey,commandKey,alternateKey,spaceKey|}) {", | |
" $2", | |
"}" | |
], | |
"description": "Create If-Statement with LaunchBar Key Options" | |
}, | |
"LaunchBar Action Prefs": { | |
"prefix": "lPrefs", | |
"body": [ | |
"Action.preferences.${1:apiToken}" | |
], | |
"description": "Create LaunchBar Action Prefs code" | |
}, | |
"LaunchBar Stringify Alert ": { | |
"prefix": "lStringify", | |
"body": [ | |
"LaunchBar.alert(JSON.stringify($1));" | |
], | |
"description": "LaunchBar Stringify Alert " | |
}, | |
// LaunchBar HTTP | |
"LaunchBar getJSON": { | |
"prefix": "lGJSON", | |
"body": [ | |
"var ${1:result} = HTTP.getJSON('${2:https://api…}' + encodeURI(${3:argument}), {", | |
" headerFields: {", | |
" 'Authorization': 'Token ' + ${4:apiToken}", | |
" }", | |
"});" | |
], | |
"description": "LaunchBar getJSON" | |
}, | |
"LaunchBar postJSON": { | |
"prefix": "lPJSON", | |
"body": [ | |
"var ${1:result} = HTTP.postJSON('${2:https://httpbin.org/post}', {", | |
" body: {", | |
" $3", | |
" }", | |
"});" | |
], | |
"description": "LaunchBar postJSON" | |
}, | |
"PUT Snippet": { | |
"prefix": "putSnippet", | |
"body": [ | |
"var req = HTTP.createRequest('${1:putURL}', {", | |
" method: 'PUT',", | |
" body: {", | |
" $2", | |
" },", | |
" bodyType: 'json'", | |
"});", | |
"var putAnswer = HTTP.loadRequest(req);" | |
], | |
"description": "PUT Snippet" | |
}, | |
// LaunchBar File | |
"LaunchBar Get Directory Contents": { | |
"prefix": "lGetDirectoryContents", | |
"body": [ | |
"var contents = File.getDirectoryContents('${1:/Applications/}', {", | |
" includeHidden: false,", | |
"});" | |
], | |
"description": "LaunchBar Get Directory Contents" | |
}, | |
"LaunchBar File exists": { | |
"prefix": "lFileExists", | |
"body": [ | |
"File.exists($1)" | |
], | |
"description": "LaunchBar File exists" | |
}, | |
"LaunchBar File isDirectory": { | |
"prefix": "lFileIsDirectory", | |
"body": [ | |
"File.isDirectory($1)" | |
], | |
"description": "LaunchBar File isDirectory" | |
}, | |
"LaunchBar File displayName": { | |
"prefix": "lFileDisplayName", | |
"body": [ | |
"var ${1:fileName} = File.displayName($2);" | |
], | |
"description": "LaunchBar File displayName" | |
}, | |
"LaunchBar File fileURLForPath": { | |
"prefix": "lFileURLForPath", | |
"body": [ | |
"var ${1:fileURL} = File.fileURLForPath($2)" | |
], | |
"description": "LaunchBar File fileURLForPath" | |
}, | |
"LaunchBar File pathForFileURL": { | |
"prefix": "lPathForFileURL", | |
"body": [ | |
"var ${1:filePath} = File.pathForFileURL($2)" | |
], | |
"description": "LaunchBar File pathForFileURL" | |
}, | |
"LaunchBar File absolutePath": { | |
"prefix": "lAbsolutePath", | |
"body": [ | |
"var ${1:absolutePath} = File.pathForFileURL(File.fileURLForPath('${2:~}'))" | |
], | |
"description": "LaunchBar File absolutePath" | |
}, | |
"LaunchBar File readPlist": { | |
"prefix": "lReadPlist", | |
"body": [ | |
"var plist = File.readPlist(${1});" | |
], | |
"description": "LaunchBar File readPlist" | |
}, | |
"LaunchBar File readJSON": { | |
"prefix": "lReadJSON", | |
"body": [ | |
"var ${1:object} = File.readJSON(${2});" | |
], | |
"description": "LaunchBar File readJSON" | |
}, | |
"LaunchBar File readText": { | |
"prefix": "lReadText", | |
"body": [ | |
"var text = File.readText(${1});" | |
], | |
"description": "LaunchBar File readText" | |
}, | |
"LaunchBar File createDirectory": { | |
"prefix": "lCreateDirectory", | |
"body": [ | |
"File.createDirectory('${1:~/Desktop/New Directory}');" | |
], | |
"description": "LaunchBar File createDirectory" | |
}, | |
"LaunchBar File writeText": { | |
"prefix": "lWriteText", | |
"body": [ | |
"File.writeText(${1:text}, ${2:fileLocation});" | |
], | |
"description": "LaunchBar File writeText" | |
}, | |
"LaunchBar File writeJSON": { | |
"prefix": "lWriteJSON", | |
"body": [ | |
"File.writeJSON(${1:data}, ${2:fileLocation});" | |
], | |
"description": "LaunchBar File writeJSON" | |
}, | |
"LaunchBar File writePlist": { | |
"prefix": "lWritePlist", | |
"body": [ | |
"File.writePlist(${1:object}, ${2:fileLocation});" | |
], | |
"description": "LaunchBar File writePlist" | |
}, | |
// LaunchBar Properties | |
"LaunchBar currentLocale": { | |
"prefix": "currentLocale", | |
"body": [ | |
"LaunchBar.currentLocale" | |
], | |
"description": "LaunchBar currentLocale" | |
}, | |
// LaunchBar Properties | |
"LaunchBar homeDirectory": { | |
"prefix": "lHomeDirectory", | |
"body": [ | |
"LaunchBar.homeDirectory" | |
], | |
"description": "LaunchBar homeDirectory" | |
}, | |
"LaunchBar Properties Title": { | |
"prefix": "title", | |
"body": [ | |
"title" | |
], | |
"description": "LaunchBar Properties Title" | |
}, | |
"LaunchBar Properties Subtitle": { | |
"prefix": "subtitle", | |
"body": [ | |
"subtitle" | |
], | |
"description": "LaunchBar Properties Subtitle" | |
}, | |
"LaunchBar Properties Icon": { | |
"prefix": "icon", | |
"body": [ | |
"icon" | |
], | |
"description": "LaunchBar Properties Icon" | |
}, | |
// LaunchBar Options | |
"LaunchBar Options commandKey": { | |
"prefix": "commandKey", | |
"body": [ | |
"commandKey" | |
], | |
"description": "LaunchBar Options commandKey" | |
}, | |
"LaunchBar Options alternateKey": { | |
"prefix": "alternateKey", | |
"body": [ | |
"alternateKey" | |
], | |
"description": "LaunchBar Options alternateKey" | |
}, | |
"LaunchBar Options shiftKey": { | |
"prefix": "shiftKey", | |
"body": [ | |
"shiftKey" | |
], | |
"description": "LaunchBar Options shiftKey" | |
}, | |
"LaunchBar Options controlKey": { | |
"prefix": "controlKey", | |
"body": [ | |
"controlKey" | |
], | |
"description": "LaunchBar Options controlKey" | |
}, | |
"LaunchBar Options actionRunsInBackground": { | |
"prefix": "lactionRunsInBackground", | |
"body": [ | |
"actionRunsInBackground: true" | |
], | |
"description": "LaunchBar Options actionRunsInBackground" | |
}, | |
// Other Snippets | |
"Sort function": { | |
"prefix": "sortFunction", | |
"body": [ | |
"${1:result}.sort(function (a, b) {", | |
" return a.${2:title} > b.${2:title};", | |
"});" | |
], | |
"description": "Create sort function" | |
}, | |
"For Loop Snippet": { | |
"prefix": "forSnippet", | |
"body": [ | |
"var result = []", | |
"for (var i = 0; i < ${1:test}.length; i++) {", | |
" $2", | |
" result.push({", | |
" title: ${1:test}[i],", | |
" subtitle: ${3:sub},", | |
" icon: ${4:icon},", | |
" action: '${5:action}',", | |
" actionArgument: ${1:test}[i]", | |
" });", | |
"}", | |
"return result" | |
], | |
"description": "For Loop Snippet" | |
}, | |
"For Each Snippet": { | |
"prefix": "forEachSnippet", | |
"body": [ | |
"${1:contents}.forEach(function (item) {", | |
" $2", | |
"});" | |
], | |
"description": "For Loop Snippet" | |
}, | |
"Eval Snippet": { | |
"prefix": "evalSnippet", | |
"body": [ | |
"var ${1:data} = eval('[' + ${2:result.data} + ']')" | |
], | |
"description": "eval snippet" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment