ttab – Terminal.appの新規ウィンドウやタブをコマンドで開く –


A macOS (OS X) CLI for programmatically opening a new terminal tab/window in the standard terminal application, Terminal, or in popular alternative iTerm2, optionally with a command to execute and/or a specific title and specific display settings.



npm install -g ttab

Important: Irrespective of installation method, Terminal / iTerm2 ( needs to be granted access for assistive devices in order for ttab to function properly, which is a one-time operation that requires administrative privileges.
If you’re not prompted on first run and get an error message instead, go to System Preferences > Security & Privacy, tab Privacy, select Accessibility, unlock, and make sure / is in the list on the right and has a checkmark.
For more information, see Apple’s support article on the subject

と言うことで、インストール後、システム環境設定 > セキュリティとプライバシー > アクセシビリティ で、ターミナルにチェックを入れる。


でもって、Terminal.appで”ttab”と打つと、新規タブで開かれる 😀💡

$ ttab --help

Opens a new terminal tab or window in OS X's Terminal application or iTerm2.

    ttab [-w] [-s <settings>] [-t <title>] [-q] [-g|-G] [-d <dir>] [<cmd> ...]

    -w                  open new tab in new terminal window
    -s <settings>       assign a settings set (profile)
    -t <title>          specify title for new tab
    -q                  clear the new tab's screen
    -g                  create tab in background (don't activate Terminal/iTerm)
    -G                  create tab in background and don't activate new tab
    -d <dir>            specify working directory
    -a Terminal|iTerm2  open tab or window in / iTerm2  
    <cmd> ...           command to execute in the new tab
    "<cmd> ...; ..."    multi-command command line (passed as single operand)

Standard options: --help, --man, --version, --home

wp-cliコマンドのwp scaffold _sと組み合わせたかった

wp scaffold _s | WordPress Developer Resources

これは、_sベースのテーマをサクッと作ってくれる便利なコマンドです 😀

このコマンドでテーマを作った後、オレオレpackage.json作ってテーマ作成の準備を全て完了させたかったんですよね 😀


↑↑このやり方ですっかり定着してきたのはいいんだけど、theme作った後、毎度browser-sync –proxy打ち替えるのも面倒だし、/disディレクトリ作るのも面倒になってしまって、scaffold _sした後新規タブでwatch, 更に新規タブでvagrant ssh下状態にしたいなと 😀


# Open a new tab in the current terminal window. 
# Open a new tab in a new terminal window. 
ttab -w 
# Open a new tab and execute the specified command before showing the prompt. 
ttab ls -l "$HOME/Library/Application Support"
# Open a new tab and execute *multiple* commands in it - note how the entire 
# command line is specified as *single, quoted string*. 
ttab 'git branch; git status'
# Open a new tab, switch to the specified dir., then execute the specified  
# command before showing the prompt. 
ttab -d ~/Library/Application\ Support ls -1 
# Open a new tab with title 'How Green Was My Valley' and settings 'Grass'. 
ttab -t 'How Green Was My Valley' -s Grass
# Open a new tab and execute the specified script before showing the prompt. 
ttab /path/to/someScript 
# Open a new tab, execute the specified script, and exit. 
ttab exec /path/to/someScript
# Open a new tab, execute a command, wait for a keypress, and exit. 
ttab 'ls "$HOME/Library/Application Support"; echo Press a key to exit.; read -rsn 1; exit'
# Open a new tab in iTerm2 (if installed). 
ttab -a iTerm2 echo 'Hi from iTerm2.'



メールアドレスが公開されることはありません。 * が付いている欄は必須項目です