重新加载终端首选项。

发布于 2025-02-03 00:11:41 字数 669 浏览 3 评论 0原文

我用plutil编辑了Plist。然后,我将其放置在/user//library/preferences/com.apple.terminal.plist中。我希望它在不重新启动应用程序的情况下更新设置。我该怎么做?使用默认值读取com.apple.terminal似乎不会使更改生效。我在PLIST中添加了一个终端配置文件,并希望更改生效。

我尝试使用AppleScript进行导入配置文件,但长话短说,这不是100%。如果您存储窗口1,则在打开后立即延迟延误相同。

on run argv
    set importScript to first item of argv
    set flag to application "Terminal" is not running
    tell application "Terminal"
        open importScript
        delay 1.0E-5
        activate
        if flag then close back window
        do script "exit" in window 1
        delay 0.5
        close window 1
    end tell
end run

I used plutil to edit the plist. then I placed in under /User/<myUsername>/Library/Preferences/com.apple.Terminal.plist. I want it to update the settings without reboot the application. How do I do this? using defaults read com.apple.Terminal doesn't seem to make the changes take effect. I added a terminal profile to the plist and want the changes to take effect.

I tried making an import profile with AppleScript but long story short it's not 100% possible. if you store window 1 so it's the same var in-between delays right after open it errors more times.

on run argv
    set importScript to first item of argv
    set flag to application "Terminal" is not running
    tell application "Terminal"
        open importScript
        delay 1.0E-5
        activate
        if flag then close back window
        do script "exit" in window 1
        delay 0.5
        close window 1
    end tell
end run

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

半﹌身腐败 2025-02-10 00:11:41

不需要编辑简单的苹果本。此的局限性在于您必须在终端配置文件中_OTI_&lt; yourProfileID&gt;默认标头中的标题,并在运行终端配置文件时更改标题,以防止在已运行的应用程序导入的同一配置文件时,以防止意外关闭

。 applescript

on run argv
    set importScript to first item of argv
    set closeScript to second item of argv
    set profileId to third item of argv
    do shell script "open -a Terminal " & importScript
    do shell script "osascript " & closeScript & " _oti_" & profileId
end run

closeme.applescript

on run argv
    set c to first item in argv
    tell application "Terminal"
        set wList to every window
        repeat with app_window in wList
            set wname to name of app_window
            if wname contains c then
                do script "exit" in app_window
                delay 0.312
                close app_window
            end if
        end repeat
    end tell
end run

,然后您可以使用此applescript调用配置文件

on run argv
    set flag to application "Terminal" is not running
    set scpt to first item in argv
    set n to second item in argv
    set p to third item in argv
    tell application "Terminal"
        set newTab to do script scpt
        set badFlag to back window is equal to window 1
        if p is not equal to "" then set current settings of newTab to settings set p
        set custom title of newTab to n
        activate
        if flag and (not badFlag) then
            do script "exit" in back window
            delay 0.1
            close back window
        end if
    end tell
end run

there is no need for editing plists just a simple AppleScript. the limitations of this are you must have _oti_<yourProfileId> in your terminal profile default header and change the title when running your terminal profile to prevent accidental closures when installing the same profile of an already running app

import.applescript

on run argv
    set importScript to first item of argv
    set closeScript to second item of argv
    set profileId to third item of argv
    do shell script "open -a Terminal " & importScript
    do shell script "osascript " & closeScript & " _oti_" & profileId
end run

closeMe.applescript

on run argv
    set c to first item in argv
    tell application "Terminal"
        set wList to every window
        repeat with app_window in wList
            set wname to name of app_window
            if wname contains c then
                do script "exit" in app_window
                delay 0.312
                close app_window
            end if
        end repeat
    end tell
end run

and then you can call the profile using this AppleScript

on run argv
    set flag to application "Terminal" is not running
    set scpt to first item in argv
    set n to second item in argv
    set p to third item in argv
    tell application "Terminal"
        set newTab to do script scpt
        set badFlag to back window is equal to window 1
        if p is not equal to "" then set current settings of newTab to settings set p
        set custom title of newTab to n
        activate
        if flag and (not badFlag) then
            do script "exit" in back window
            delay 0.1
            close back window
        end if
    end tell
end run
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文