I have a command that allows me to write \terminal in math mode and it print in its bb-bold style, but also allows me to call it in text mode as \terminal (as opposed to \(terminal\) or whatever). The math font I've used is a result of the difficulty of finding nice look bb-bold characters for 0 and 1 as initial and terminal objects (category theory).
However, I think the check breaks down when the command is called in a tikz-cd environment causing me to get a lot of errors (missing delimiters, missing math mode, math font called in text mode, etc.). is there an easy fix that allows me to continue using the same \terminal command in and out of math mode?
\documentclass[a4paper, 12pt]{article}
\usepackage[utf8]{inputenc}
\DeclareMathAlphabet{\mymathbb}{U}{BOONDOX-ds}{m}{n}
\newcommand{\terminal}{\ifmmode\mymathbb{1}\else$\mymathbb{1}$\fi}
\begin{document}
\begin{figure}
\centering
\begin{tikzcd}[column sep=huge, row sep=huge]
F \rar["\eta", squiggly, tail] \dar["!", squiggly] & G \dar["\chi_\eta", squiggly] \\
\terminal \rar["\top", squiggly] & \Omega
\end{tikzcd}
\end{figure}
\end{document}

\terminalso that it works in text mode: you'd need\terminal{}if you use it in text, and$\terminal$is the same number of keys and clearer because it segregates math. Anyway, if you want to roll on your own version of\ensuremath, add\relaxin front of\ifmmode. See https://tex.stackexchange.com/q/34830/4427 – egreg Jan 18 '19 at 18:35\arrow[r,"\eta"]much clearer than the obscure\rar. – egreg Jan 18 '19 at 18:36\terminal\and it prints fine. I know it sounds silly but typing the dollar signs slows me down and the accepted answer provides an easy enough macro to avoid that necessity. Thanks for the feedback though. EDIT: to your second comment, I currently have some 50 commutative diagrams in this document, and the time saving of using shortcuts like\raror\ularis worth the sacrifice in readability (to me). – Ben Jan 19 '19 at 19:03