在bash脚本中,我需要知道当前的OS X终端主题是什么。怎么办呢?
我检查了env命令的输出,但没有找到任何内容。
答案 0 :(得分:1)
在每个shell的基础上,你不能。您可以获得默认设置:
defaults read com.apple.Terminal "Default Window Settings"
或新窗口设置:
defaults read com.apple.Terminal "Startup Window Settings"
答案 1 :(得分:0)
我们可以使用AppleScript从bash shell中检索最重要的“终端”窗口的配置文件名称:
echo 'tell application "Terminal" to return name of current settings of first window' | osascript
我们可以类似地设置配置文件:
echo 'tell application "Terminal" to set current settings of first window to settings set "Basic"' | osascript
用您要采用的配置文件名称替换“基本”。
这些命令将应用于Terminal.app的当前/最前的选项卡或窗口
我还编写了一个脚本,该脚本将根据是否提供配置文件名称来获取/设置配置文件:https://github.com/starbase527/dotfiles/blob/master/local/bin/term-profile。用法示例:
# Gets profile name
> term-profile
Basic
# Sets profile to Basic
> term-profile Basic
>
答案 2 :(得分:0)
直接在zsh中,你可以像这样获取当前的Terminal.app主题:
CURRENT_THEME=$(osascript -e 'tell application "Terminal" to return name of current settings of first window')
echo $CURRENT_THEME
从中,并结合一些 AppleScript 知识,您可以获得 Terminal.app 的一些详细信息
快乐编码?