Programmatically know if the current font has the powerline patch

Viewed 1587

I use vim with vim-airline that can use patched fonts for additional awesomeness.

vim-airline

I also use fish shell (if you want read zsh here since it is equivalent for the analysis) with a theme that also uses patched fonts.

I save my dotfiles online and I use them in different systems. But in some of them I don't have a patched font. I would really love to have generic dotfiles that for example do not use a theme that needs patched font if the current font is not patched. Also in my vimrc I disabled the use of patched characters for vim-airline because of this.

Is there a way to programmatically know if the font that is currently in use is a patched one so that is possible to write generic dotfiles that fit perfectly in all the situations?

2 Answers

You can do this the other way around and only enable Powerline fonts for known machines in your .vimrc e.g.

let hostname = substitute(system('hostname'), '\n', '', '')
let patched_font_hosts = ['host1', 'host2', 'host3']   " List of know patched hosts
if(index(patched_font_hosts, hostname) >= 0)
  let g:airline_powerline_fonts = 1
endif

It's easier to know which hosts you have patched and it's not a really a problem if the list is not up to date.

Related