Add font detection for iTerm2

This commit is contained in:
Dominik Ritter 2017-03-02 01:45:46 +01:00
parent 1af650eaf1
commit e9c8e6c2a3

View file

@ -1644,6 +1644,25 @@ get_term_font() {
term_font="$(osascript -e 'tell application "Terminal" to font name of window frontmost')"
;;
"iTerm2")
local currentProfileName=$(osascript -e 'tell application "iTerm2" to profile name of current session of current window')
# Count Guids in "New Bookmarks"; they should be unique
local profilesCount=$(/usr/libexec/PlistBuddy -c "Print :New\ Bookmarks:" ~/Library/Preferences/com.googlecode.iterm2.plist | grep "Guid" | wc -l)
for idx in $(seq 0 ${profilesCount}); do
local profileName=$(/usr/libexec/PlistBuddy -c "Print :New\ Bookmarks:${idx}:Name:" ~/Library/Preferences/com.googlecode.iterm2.plist)
if [[ "${profileName}" == "${currentProfileName}" ]]; then
# "Normal Font"
term_font=$(/usr/libexec/PlistBuddy -c "Print :New\ Bookmarks:${idx}:Normal\ Font:" ~/Library/Preferences/com.googlecode.iterm2.plist)
# Font for non-ascii characters
local nonAsciiFont=$(/usr/libexec/PlistBuddy -c "Print :New\ Bookmarks:${idx}:Non\ Ascii\ Font:" ~/Library/Preferences/com.googlecode.iterm2.plist)
if [[ "$term_font" -ne "$nonAsciiFont" ]]; then
term_font="$term_font (normal) / $nonAsciiFont (non-ascii)"
fi
fi
done
;;
"deepin-terminal"*)
term_font="$(awk -F '=' '/font=/ {a=$2} /font_size/ {b=$2} END{print a " " b}' "${XDG_CONFIG_HOME}/deepin/deepin-terminal/config.conf")"
;;