yimity
V2EX  ›  macOS

iTerm2 如何保存一组 Tabs 下次打开还打开这些 Tabs

  •  
  •   yimity · Feb 8, 2017 · 6462 views
    This topic created in 3577 days ago, the information mentioned may be changed or developed.

    就是想要打开多个 Tab ,然后关电脑或者重启的时候,再次打开 iTerm2 的时候把保存的这一组 Tabs 重新打开。并设定到特定的目录中。该如何做呢?

    14 replies  •  2017-02-12 09:27:28 +08:00
    gesse
    gesse
    Feb 8, 2017
    1
    不关电脑?🤣
    yimity
    yimity
    OP
    Feb 8, 2017
    2
    @gesse 唉,就是想要关电脑呢,之前 Windows 中的 cmder 可以做到,但是切到 Mac 就不知道咋实现了。
    关键是十多个 Tab 呢。即使很长时间关一次电脑,但是还是很麻烦。
    minamike
    minamike
    Feb 8, 2017
    3
    Applescript 或 automator 建一个 workflow 吧
    sojingle
    sojingle
    Feb 8, 2017❤️2
    4
    系统的 Preferences->General->不要选择 Close windows when quitting an app ,同时 iTerm2 的 Preferences->General->Startup 选择 Use System Window Restoration Settings
    yimity
    yimity
    OP
    Feb 8, 2017
    5
    @minamike 应该怎么写呢,这个没写过。

    @sojingle 这样子我关机重启的话,打开 iTerm2 还是原来的味道?这样子设置,会不会其他 APP 也会被影响?
    AnyISalIn
    AnyISalIn
    Feb 8, 2017
    6
    tmux 大法好
    kenzi
    kenzi
    Feb 8, 2017 via iPad
    7
    Tmux+1
    minamike
    minamike
    Feb 8, 2017
    8
    @yimity

    activate application "Terminal"
    tell application "Terminal" to do script "script1" in window 1
    tell application "System Events" to tell process "Terminal" to keystroke "t" using command down
    tell application "Terminal" to do script "script2" in window 1
    tell application "System Events" to tell process "Terminal" to keystroke "t" using command down
    tell application "Terminal" to do script "script3" in window 1
    tell application "System Events" to tell process "Terminal" to keystroke "t" using command down
    tell application "Terminal" to do script "script4" in window 1
    tell application "System Events" to tell process "Terminal" to keystroke "t" using command down
    tell application "Terminal" to do script "script5" in window 1
    tell application "System Events" to tell process "Terminal" to keystroke "t" using command down
    tell application "Terminal" to do script "script6" in window 1
    tell application "System Events" to tell process "Terminal" to keystroke "t" using command down
    tell application "Terminal" to do script "script7" in window 1
    tell application "System Events" to tell process "Terminal" to keystroke "t" using command down
    tell application "Terminal" to do script "script8" in window 1
    tell application "System Events" to tell process "Terminal" to keystroke "t" using command down
    tell application "Terminal" to do script "script9" in window 1
    tell application "System Events" to tell process "Terminal" to keystroke "t" using command down
    tell application "Terminal" to do script "script10" in window 1

    把 script1 ~ script10 改成你要运行的命令 笨办法😂
    minamike
    minamike
    Feb 8, 2017❤️1
    9
    @yimity 对了 我这个是用于自带的终端的 要用于 iTerm2 的话要把 Terminal 改成 iTerm2 的名称
    wjidea
    wjidea
    Feb 9, 2017
    10
    tmux 大法好
    yimity
    yimity
    OP
    Feb 9, 2017
    11
    @minamike 好的,谢谢,我试一下。
    sojingle
    sojingle
    Feb 9, 2017
    12
    @yimity 是的,其他程序也受影响。

    这个功能是让程序在退出时不关闭窗口(文档),下次程序启动就会自动打开这些窗口。如果你在退出 iTerm 的时候直接 CMD+Q 退出而不是一个个窗口关掉,下次再打开就是这个状态,其他写的比较标准的程序也是一样的行为。

    关电脑时系统给程序发送的就是直接退出的命令。
    Cople
    Cople
    Feb 10, 2017
    13
    Window > Save Window Arrangment
    ychongsaytc
    ychongsaytc
    Feb 12, 2017 via iPhone
    14
    tmux+10086
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4776 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 58ms · UTC 03:02 · PVG 11:02 · LAX 19:02 · JFK 22:02
    ♥ Do have faith in what you're doing.