Alex Balgavy

Just some stuff about me.

Here's my dotfiles repository.

Check out my blog.

My keys: PGP, SSH

My crypto wallets (BTC, XMR)


What links here:

Determine if term/console supports UTF-8

utf8_or_ascii() {
  old_settings=$(stty -g)
  stty -icanon -echo min 0 time 3
  printf ''
  printf '\033[6n' # getcursorpos VT100 escape code
  # response: ^[v;hR  - i.e cursor at row v, col h
  pos=$(dd count=1 2>/dev/null)
  pos=${pos%%R*}
  pos=${pos##*\[}
  col=${pos##*;}
  #row=${pos%%;*}
  stty "$old_settings"
  if [ "$col" -eq 2 ]; then
    printf 'UTF8'
  else
    printf 'ASCII'
  fi
}