Skip to content

One hotkey: Execute selected file, cd to selected folder, and run selected text as command in Terminal.

License

Notifications You must be signed in to change notification settings

willbchang/alfred-run-in-terminal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Run in Terminal Logo
Dedicated to my girlfriend 😘 @YangYang

Run in Terminal

An Alfred Workflow to execute selected file, cd to selected folder, and run selected text in Terminal with one hotkey.

Installation

  1. Download Run in Termianl.alfredworkflow.
  2. Double click Run in Terminal.alfredworkflow to install.
  3. Click Import Button.
  4. Double click Hotkey and set your shortcut.(I'm using alt + t).

Feature & Usage

alt + t run in terminal

  • Launch Terminal if Terminal isn't active.
  • Bring Terminal to the front window if Terminal is active.
  • Run selected text in Terminal, it avoids $ in the beginning of the first line.
    $ echo select me and press hotkey!
     $ echo Hello $(whoami)
       $    echo Alfred Loves You!
  • cd selected file/folder from Finder or Alfred File Browser.
    1. Enable Quick Search Mode in Features -> File Action.
    2. Launch Alfred and press spacebar or input a single quote.
    3. Move the highlight block to the destination folder.
    4. Notice: if you enabled Advanced -> History and browse file with it, you should use tab or or to avoid Alfred's default selection.
    5. Press alt + t or your own shortcut.

Change Terminal App

  1. Open Alfred Preferences -> Workflows -> Open in Terminal.
  2. Double click Run Script, replace Terminal with YOUR TERMINAL APP.
  3. Make sure the app name surrounds with double quote "".

Add Runtimes

  1. Open Alfred Preferences -> Workflows -> Open in Terminal.
  2. Right click Run in Terminal workflow -> Open in Finder
  3. Open script.rb, press Command + F to find runtimes.
    runtimes = {
      rb: 'ruby',
      sh: 'sh',
      py: 'python',
      go: 'go',
      php: 'php',
      js: 'node',
      ts: 'deno',
      rs: 'rust'
    }
  4. Add new FILETYPE: RUNTIME, you can also set other command for specific file type.

Contribution

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Credits

Icon made by https://www.flaticon.com/authors/kirill-kazachek
It was built with 💖 in NeoVim & RubyMine.

License

AGPL-3.0

About

One hotkey: Execute selected file, cd to selected folder, and run selected text as command in Terminal.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published