term_font: cleanup

This commit is contained in:
Dylan Araps 2018-06-04 08:33:24 +10:00
parent 05b0d1055b
commit b119a154b0

View file

@ -2758,18 +2758,13 @@ get_term_font() {
case "$term" in case "$term" in
"alacritty"*) "alacritty"*)
if [[ -f "${XDG_CONFIG_HOME}/alacritty.yml" ]]; then shopt -s nullglob
alacritty_file="${XDG_CONFIG_HOME}/alacritty.yml" confs=({$XDG_CONFIG_HOME,$HOME}/{alacritty,}/{.,}alacritty.ym?)
shopt -u nullglob
elif [[ -f "${XDG_CONFIG_HOME}/alacritty/alacritty.yml" ]]; then [[ -f "${confs[0]}" ]] || return
alacritty_file="${XDG_CONFIG_HOME}/alacritty/alacritty.yml"
elif [[ -f "${HOME}/.alacritty.yml" ]]; then term_font="$(awk -F ':|#' '/normal:/ {getline; print}' "${confs[0]}")"
alacritty_file="${HOME}/.alacritty.yml"
fi
term_font="$(awk -F ':|#' '/normal:/ {getline; print}' \
"$alacritty_file")"
term_font="${term_font/*family:}" term_font="${term_font/*family:}"
term_font="${term_font/$'\n'*}" term_font="${term_font/$'\n'*}"
term_font="${term_font/\#*}" term_font="${term_font/\#*}"
@ -2846,19 +2841,11 @@ END
;; ;;
"kitty"*) "kitty"*)
if [[ -f "${KITTY_CONFIG_DIRECTORY}/kitty/kitty.conf" ]]; then shopt -s nullglob
kitty_file="${KITTY_CONFIG_DIRECTORY}/kitty/kitty.conf" confs=({$KITTY_CONFIG_DIRECTORY,$XDG_CONFIG_HOME,~/Library/Preferences}/kitty/kitty.con?)
shopt -u nullglob
elif [[ -f "${XDG_CONFIG_HOME}/kitty/kitty.conf" ]]; then [[ -f "${confs[0]}" ]] || return
kitty_file="${XDG_CONFIG_HOME}/kitty/kitty.conf"
elif [[ -f "${HOME}/.config/kitty/kitty.conf" ]]; then
kitty_file="${HOME}/.config/kitty/kitty.conf"
elif [[ -f "${HOME}/Library/Preferences/kitty/kitty.conf" ]]; then
kitty_file="${HOME}/Library/Preferences/kitty/kitty.conf"
fi
term_font="$(awk '/^([[:space:]]*|[^#_])font_family[[:space:]]+/ { term_font="$(awk '/^([[:space:]]*|[^#_])font_family[[:space:]]+/ {
$1 = ""; $1 = "";
@ -2868,7 +2855,7 @@ END
/^([[:space:]]*|[^#_])font_size[[:space:]]+/ { /^([[:space:]]*|[^#_])font_size[[:space:]]+/ {
size = $2 size = $2
} }
END { print font " " size}' "${kitty_file}")" END { print font " " size}' "${confs[0]}")"
;; ;;
"konsole"*) "konsole"*)