Running Part of Stata Code

Hello,

I am a new PopClip user and am trying to integrate it into my workflow. I code in Stata using its built-in editor, and I often select a portion of code and execute only that section through a menu command. Is there a PopClip extension that would allow me to run the selected code directly, without having to navigate to the menu each time?

Apologies if the above description is unclear. Thanks for your help.

If there is a keyboard shortcut to run the selected code, you likely can emulate this shortcut with a PopClip action.

here is an example: How to make a Key Press extension in PopClip — TextExpander example

1 Like

First, find Stata’s bundle ID (you’ll need it for the filter, and I’m not certain what it is for your edition):

osascript -e 'id of app "StataMP"'

Replace StataMP with your edition (StataSE, StataBE). You’ll get back something like com.stata.stata18.

Then the snippet - select it, and PopClip will offer to “Install Extension”:

# popclip
name: Send to Stata
icon: square filled S
required apps: [com.stata.stata18]   # ← your bundle ID from above
key combo: command shift D            # ← your key combination

The combo string uses a human-readable format of modifiers plus a key. For example, command b holds Command and presses the b key; option shift . holds Option and Shift and presses the period. Special keys are referenced by name, such as return, space, escape, up, and so on, and for multi-step sequences, there’s key combos (plural) with optional wait steps.

2 Likes

Thank you both - both of your examples helped me and I managed to get the extension working.

1 Like