Coder Social home page Coder Social logo

iterm2fromfinder's Introduction

iTerm2fromFinder

Alfred workflow which launch iTerm2 and change dir to the window Finder working on. Also execute commands.

Motivation

I was using Terminal to open Finder working on directory.

But since I am using iTerm2 a lot, I decided to search on the internet about launch iTerm2 and 'cd $DIR' function script. I tried a lot, but none of them working perfect match my usecase.

Also the iTerm2 officially anounce support python3 for launch iTerm2 in newly versions, but that depends on installing AppKit which I met a lot of errors.

I prefer old ways. So I tried using Applescript and Bash to do that work, cause for me it is simple.

Installation

Just clone this repo or download the alfredworkflow file, then double click the alfredworkflow file. Right now I am tested on Alfred 5.

Explained

I want adding more details about source code.
The workflow is a binary like file.
This workflow is triggered by hotkey or keywords. After trigger there is a Bash script to execute, which include:

  1. Using applescript to get Finder APP working directory, return the result to step 2.
  2. Launch iTerm2 window. This is done by another Applescript embeded in the run.sh.
  3. Execute command inside iTerm2.
    • Change directory to the Step 1 result.
    • If triggered by keywords there should be arguments which is a command want to be executed.
  4. Done.

Please refer to run.sh and terminalcommandhere.applescript which I exported from my workflow.

References

References:
    iTerm AppleScript Examples:
    https://gitlab.com/gnachman/iterm2/wikis/Applescript

Credit:
    Franz Heidl  -- www.franzheidl.de -- Alfred workflow runterminalcommandhere
    Open iTerm2 and Execute -- https://gist.github.com/vyder/96891b93f515cb4ac559e9132e1c908
    https://gist.github.com/geyang/a495a5ea8e6fdd2f79f8e874616ea182

Questions?

If there are problems, please open issues. I will look at when I have time. Thanks and enjoy!

iterm2fromfinder's People

Contributors

zzuse avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.