Tag: Shell function

  • Silly Tools for The Graphical Terminal: Flag

    If you are using the right kind of terminal that supports graphics inline (such as KiTTY), then you can write simple (or complex) tools that insert images into the terminal.

    Being able to display the flag of a country (if you know its two-letter ISO code) is kind of trivial but useful if you need it.

    And a shell function to do that is remarkably simple :-

    function flag {
        wget -o /dev/null -O /var/tmp/flag.$$ http://flagpedia.net/data/flags/normal/${1}.png
        if [ $? -eq 0 ]
        then
            kitty +kitten icat /var/tmp/flag.$$ && rm /var/tmp/flag.$$
        else
            echo Not found
        fi
    }

    (that’s a Zsh function which may require adaption to Bash).