Merge pull request #670 from dritter/add_iterm2_font_detection
Add iterm2 font detection
This commit is contained in:
commit
7cf891a63b
1 changed files with 40 additions and 0 deletions
40
neofetch
40
neofetch
|
@ -1650,6 +1650,46 @@ get_term_font() {
|
|||
term_font="$(osascript -e 'tell application "Terminal" to font name of window frontmost')"
|
||||
;;
|
||||
|
||||
"iTerm2")
|
||||
# Unfortunately the profile name is not unique, but it seems to be the only thing
|
||||
# that identifies an active profile. There is the "id of current session of current window"
|
||||
# thou, but that does not match to a guid in the plist.
|
||||
# So, be warned! Collisions may occur!
|
||||
# See: https://groups.google.com/forum/#!topic/iterm2-discuss/0tO3xZ4Zlwg
|
||||
local current_profile_name
|
||||
current_profile_name="$(osascript -e 'tell application "iTerm2" to profile name of current session of current window')"
|
||||
|
||||
# Warning: Dynamic profiles are not taken into account here!
|
||||
# https://www.iterm2.com/documentation-dynamic-profiles.html
|
||||
|
||||
# Count Guids in "New Bookmarks"; they should be unique
|
||||
local profiles_count
|
||||
profiles_count="$(/usr/libexec/PlistBuddy -c "Print :New\ Bookmarks:" ~/Library/Preferences/com.googlecode.iterm2.plist 2>/dev/null | grep -c "Guid")"
|
||||
|
||||
for ((i=0; i<=profiles_count; i++)); do
|
||||
local profile_name
|
||||
profile_name="$(/usr/libexec/PlistBuddy -c "Print :New\ Bookmarks:${i}:Name:" ~/Library/Preferences/com.googlecode.iterm2.plist 2>/dev/null)"
|
||||
|
||||
if [[ "$profile_name" == "$current_profile_name" ]]; then
|
||||
# "Normal Font"
|
||||
term_font="$(/usr/libexec/PlistBuddy -c "Print :New\ Bookmarks:${i}:Normal\ Font:" ~/Library/Preferences/com.googlecode.iterm2.plist)"
|
||||
# Font for non-ascii characters
|
||||
# Only check for a different non-ascii font, if the user checked
|
||||
# the "use a different font for non-ascii text" switch.
|
||||
local use_different_font
|
||||
use_different_font="$(/usr/libexec/PlistBuddy -c "Print :New\ Bookmarks:${i}:Use\ Non-ASCII\ Font:" ~/Library/Preferences/com.googlecode.iterm2.plist)"
|
||||
|
||||
if [[ "$use_different_font" == "true" ]]; then
|
||||
local non_ascii_font
|
||||
non_ascii_font="$(/usr/libexec/PlistBuddy -c "Print :New\ Bookmarks:${i}:Non\ Ascii\ Font:" ~/Library/Preferences/com.googlecode.iterm2.plist)"
|
||||
|
||||
[[ "$term_font" != "$non_ascii_font" ]] && \
|
||||
term_font="$term_font (normal) / $non_ascii_font (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")"
|
||||
;;
|
||||
|
|
Loading…
Reference in a new issue