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