项目作者: willbchang

项目描述 :
One hotkey: Execute selected file, cd to selected folder, and run selected text as command in Terminal.
高级语言: Ruby
项目地址: git://github.com/willbchang/alfred-run-in-terminal.git
创建时间: 2020-06-05T06:55:55Z
项目社区:https://github.com/willbchang/alfred-run-in-terminal

开源协议:GNU Affero General Public License v3.0

下载



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 hyper + t).

Features

  1. Auto-detect whether current selected text is a filepath and run cd if it is.
    • ~ will be auto expanded to /Users/$(whoami) for checking the filepath.
    • Spaces before filepath will be removed in order to use cd.
      Input:
      1. ~/Library/Application Support/
      Output:
      1. cd "/Users/$(whoami)/Library/Application Support/"
  2. Auto remove the solo $ in the beginning of lines.

    • Some bash code snippets always prefix with $, it’s annoying when copy and running them.
    • It won’t affect the bash argument, only the $ with space will be removed, regex: /^\s*\$\s+/

    Input:

    1. $ temp=$(mktemp)
    2. $ echo "$temp"
    3. $ rm "$temp"
    4. $(whoami)

    Output:

    1. temp=$(mktemp)
    2. echo "$temp"
    3. rm "$temp"
    4. $(whoami)
  3. Auto-detect whether current Terminal tab is running command, it will open a new tab if current tab has active process.
  4. It won’t mess up with escaping characters even though this extension uses ruby, applescript and shell script together.

    Input:

    1. variable="This is a \$10 \"quote\""
    2. echo $variable

    Output:

    1. variable="This is a \$10 \"quote\""
    2. echo $variable

Only Terminal.app is supported, the AppleScript that Terminal.app uses is not compatible with iTerm.app, pull requests are welcome for iTerm.app or other terminal emulators.

LICENSE

AGPL-3.0