I have a little banner that I display at login
fignow() { figlet -w $(tput cols) $(date +"%b %d, Week %V"); figlet -w $(tput cols) -f univers $(date +"%H:%M"); }
This works fine if the additional fonts are installed to get univers
, but that's not part of the default installation, so I can do the following:
fignow() { figlet -w $(tput cols) $(date +"%b %d, Week %V"); if [ -f /usr/share/figlet/univers.flf ]; then figlet -w $(tput cols) -f univers $(date +"%H:%M"); else figlet -w $(tput cols) $(date +"%H:%M"); fi; }
This also works fine, but I was curious if the if/else/fi
could be removed and the logic could be done inside the command itself, i.e. something like:
fignow() { figlet -w $(tput cols) $(date +"%b %d, Week %V"); figlet -w $(tput cols) -f $(use-univers-or-failback-to-standard.flf-if-univers.flf-is-not-available) $(date +"%H:%M"); }
Is something like that possible?
I suggest to use figlist
to avoid hardcoding the themes path:
figlet -w "$(tput cols)" -f "$((figlist | /bin/grep -hw universe) || echo "standard")" "foo"