2

I want to use an American flag emoji in my bash prompt (i.e. PS1 environment variable). However, the American flag emoji causes the terminal cursor to offset an extra character to the right.

🇺🇸 is comprised of two unicode characters, 🇺 and 🇸. I believe terminal is converting this to a mono-spaced emoji character (the flag), yet still allocating space for two characters. How can I achieve my expected cursor position?

I want:
🇺🇸 Desktop user 🗽 ls|

I get:
🇺🇸 Desktop user 🗽 ls | <-weird space offset of cursor

My ~/.bash_profile is:
export PS1='🇺🇸 \W \u 🗽 '

  • 1
    Related: stackoverflow.com/q/7112774/39223 – RJHunter Jan 31 at 2:41
  • If you don't type a space after typing "ls", how do you get that space? And how is the space related to PS1 variable? Shouldn't that be a result of auto completion? – 炸鱼薯条德里克 Jan 31 at 2:42
  • I’m not typing a space after ls. bash starts with a space between my input and the cursor. – Andrew Kirna Jan 31 at 3:48
  • I also see a trailing space in your PS1 – 炸鱼薯条德里克 Jan 31 at 11:38
  • @ 炸鱼薯条德里克, that's because I want my commands spaced away from the Statue of Liberty. – Andrew Kirna Jan 31 at 15:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.