OSX - How to auto Close Terminal window after the “exit” command executed.

前端 未结 14 1175
孤独总比滥情好
孤独总比滥情好 2020-12-12 16:02

When I\'m done with Terminal, I want to exit it. Right now, I have three options:

  1. killall Terminal. It will end the process, but rather abruptly. I don\'t t

14条回答
  •  北海茫月
    2020-12-12 16:32

    Create a script:

    cat ~/exit.scpt

    like this:

    • Note: If there is only one window, just quit the application, else simulate command + w to close the tab)

    tell application "Terminal" set WindowNum to get window count if WindowNum = 1 then quit else tell application "System Events" to keystroke "w" using command down end if end tell

    Then add a alias in your *shrc

    just like vi ~/.bashrc or zshrc (anything else?)

    add it: alias exit="osascript ~/exit.scpt"

    And source the ~/.bashrc or reopen your terminal.app

提交回复
热议问题