1
0
Fork 0
mirror of https://github.com/romkatv/powerlevel10k.git synced 2024-11-13 08:30:08 +00:00

iTerm2 debugger: changed error code, added Source Code Pro to fontcheck

This commit is contained in:
Ben Hilburn 2017-03-20 21:29:15 -04:00
parent 1ac59158ed
commit c9c0bb940d

View file

@ -3,12 +3,13 @@
if [[ "$TERM_PROGRAM" != "iTerm.app" ]]; then if [[ "$TERM_PROGRAM" != "iTerm.app" ]]; then
print "Your Terminal Emulator does not appear to be iTerm2!" print "Your Terminal Emulator does not appear to be iTerm2!"
print "This debug script is intended only for iTerm2 terminals."
exit 1 exit 1
fi fi
if [[ ! -x "/usr/libexec/PlistBuddy" ]]; then if [[ ! -x "/usr/libexec/PlistBuddy" ]]; then
print "To use this debug script, you need to install XCode!" print "To use this debug script, you need to install XCode!"
exit 1 exit 2
fi fi
local normalFont local normalFont
@ -18,17 +19,17 @@ local ambiguousDoubleWidth
local minimumContrast local minimumContrast
local useDifferentFont local useDifferentFont
# Unfortunately the profile name is not unique, but it seems to be the only thing # Unfortunately the profile name is not unique, but it seems to be the only
# that identifies an active profile. There is the "id of current session of current window" # thing that identifies an active profile. There is the "ID of current session
# thou, but that does not match to a guid in the plist. # of current window" though, but that does not match to a `guid` in the plist.
# So, be warned! Collisions may occur! # So, be warned - collisions may occur!
# See: https://groups.google.com/forum/#!topic/iterm2-discuss/0tO3xZ4Zlwg # See: https://groups.google.com/forum/#!topic/iterm2-discuss/0tO3xZ4Zlwg
local currentProfileName=$(osascript -e 'tell application "iTerm2" to profile name of current session of current window') local currentProfileName=$(osascript -e 'tell application "iTerm2" to profile name of current session of current window')
# Warning: Dynamic profiles are not taken into account here! # Warning: Dynamic profiles are not taken into account here!
# https://www.iterm2.com/documentation-dynamic-profiles.html # https://www.iterm2.com/documentation-dynamic-profiles.html
# Count Guids in "New Bookmarks"; they should be unique # Count `guids` in "New Bookmarks"; they should be unique
local profilesCount=$(/usr/libexec/PlistBuddy -c "Print :New\ Bookmarks:" ~/Library/Preferences/com.googlecode.iterm2.plist 2>/dev/null | grep -c "Guid") local profilesCount=$(/usr/libexec/PlistBuddy -c "Print :New\ Bookmarks:" ~/Library/Preferences/com.googlecode.iterm2.plist 2>/dev/null | grep -c "Guid")
for idx in $(seq 0 "${profilesCount}"); do for idx in $(seq 0 "${profilesCount}"); do
local profileName=$(/usr/libexec/PlistBuddy -c "Print :New\ Bookmarks:${idx}:Name:" ~/Library/Preferences/com.googlecode.iterm2.plist 2>/dev/null) local profileName=$(/usr/libexec/PlistBuddy -c "Print :New\ Bookmarks:${idx}:Name:" ~/Library/Preferences/com.googlecode.iterm2.plist 2>/dev/null)
@ -41,7 +42,7 @@ for idx in $(seq 0 "${profilesCount}"); do
minimumContrast=$(/usr/libexec/PlistBuddy -c "Print :New\ Bookmarks:${idx}:Minimum\ Contrast:" ~/Library/Preferences/com.googlecode.iterm2.plist) minimumContrast=$(/usr/libexec/PlistBuddy -c "Print :New\ Bookmarks:${idx}:Minimum\ Contrast:" ~/Library/Preferences/com.googlecode.iterm2.plist)
# Font for non-ascii characters # Font for non-ascii characters
# Only check for a different non-ascii font, if the user checked # Only check for a different non-ASCII font, if the user checked
# the "use a different font for non-ascii text" switch. # the "use a different font for non-ascii text" switch.
useDifferentFont=$(/usr/libexec/PlistBuddy -c "Print :New\ Bookmarks:${idx}:Use\ Non-ASCII\ Font:" ~/Library/Preferences/com.googlecode.iterm2.plist) useDifferentFont=$(/usr/libexec/PlistBuddy -c "Print :New\ Bookmarks:${idx}:Use\ Non-ASCII\ Font:" ~/Library/Preferences/com.googlecode.iterm2.plist)
if [[ "$useDifferentFont" == "true" ]]; then if [[ "$useDifferentFont" == "true" ]]; then
@ -69,7 +70,7 @@ fi
if (( minimumContrast > 0 )); then if (( minimumContrast > 0 )); then
problemsFound="${problemsFound}\n * Please set minimum contrast to zero." problemsFound="${problemsFound}\n * Please set minimum contrast to zero."
fi fi
if [[ $(echo "${normalFont}" | grep -c -E "Powerline|Awesome|Nerd") -eq 0 ]]; then if [[ $(echo "${normalFont}" | grep -c -E "Powerline|Awesome|Nerd|Source Code Pro") -eq 0 ]]; then
problemsFound="${problemsFound}\n * It does not seem like you use an Powerline-enabled or Awesome Terminal Font!" problemsFound="${problemsFound}\n * It does not seem like you use an Powerline-enabled or Awesome Terminal Font!"
fi fi
@ -82,4 +83,4 @@ if [[ -n "${problemsFound}" ]]; then
print -P "${problemsFound}" print -P "${problemsFound}"
else else
print -P "%F{green}No Problems found%f. Yay!" print -P "%F{green}No Problems found%f. Yay!"
fi fi