How do you echo a 4-digit Unicode character in Bash?

后端 未结 18 2063
醉梦人生
醉梦人生 2020-11-29 14:38

I\'d like to add the Unicode skull and crossbones to my shell prompt (specifically the \'SKULL AND CROSSBONES\' (U+2620)), but I can\'t figure out the magic incantation to m

18条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-29 15:06

    You may need to encode the code point as octal in order for prompt expansion to correctly decode it.

    U+2620 encoded as UTF-8 is E2 98 A0.

    So in Bash,

    export PS1="\342\230\240"
    

    will make your shell prompt into skull and bones.

提交回复
热议问题