Skip to content

Instantly share code, notes, and snippets.

@MSayib
Created October 9, 2023 07:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MSayib/6930e79220397dc448619cc2a252aaf6 to your computer and use it in GitHub Desktop.
Save MSayib/6930e79220397dc448619cc2a252aaf6 to your computer and use it in GitHub Desktop.
Quick Start PHP Dev MacOS

This is a tutorial how to create a command that runs/start any app with arguments with iTerm2 on MacOS In my case, i made a local php development server for quick start for working.

  • Install iTerm2 + Py Runtime Enabled
  • Make alias on your zsh/bash -> alias ss1='php -S localhost:8001 -t public'
  • Create new .py script on iTerm2 Script Folder (/Users/YourUser/Library/Application Support/iTerm2/Scripts) (e.g: Launch Service #1)
  • Create your desired script, in my case looks like below script:
import iterm2
async def main(connection):
    app = await iterm2.async_get_app(connection)
    window = app.current_terminal_window
    if window is not None:
        await window.async_create_tab()
        session = app.current_terminal_window.current_tab.current_session
        await session.async_send_text('cd\n')
        await session.async_send_text('cd MyCompanyName/MyProjectName/MyWorkingServiceName\n')
        await session.async_send_text('ss1\n') #YourAlias called here
    else:
        print("No current window")
iterm2.run_until_complete(main)
  • After saved, try to launch with Shift + ⌘ + O
  • Select your script filename to run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment