0

This works:

ghost=$'\U1F47B'
PROMPT='time: %T $ghost > '

But is there a way to inline the hexadecimal version of the Unicode character?

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
KevinO
  • 970
  • 2
  • 13
  • 31
  • 1
    Here is one solution that I found: `PROMPT="time: %T "$'\U1F47B'" > "` – KevinO Jun 30 '18 at 21:04
  • You can put anything you want inside `$'...'`; they are just like single quotes, but they recognize some escape sequences: `PROMPT='time: %T \U1F47B > '`. – chepner Jun 30 '18 at 21:46
  • @chepner: I think you meant `PROMPT=$'time: %T \U1F47B > '`. But unfortunately comments can't be edited. I reopened the question so you can answer; the dupe is useful but not precise. – rici Jul 01 '18 at 14:18
  • 1
    Also: `bash` and `zsh` are two different shells; I can tell from your use of `PROMPT` that you are actually using `zsh`. Although my answer applies to both shells, it's rarely useful to tag a question with both, as it's possible that you would need separate answers to address each shell. – chepner Jul 01 '18 at 14:23

1 Answers1

4

The contents of $'...' are not restricted to its special escape sequences. Such sequences are simply recognized when inside $'...'; you can include other text as well, since they are otherwise identical to single quotes (i.e., no parameter expansion).

PROMPT=$'time: %T \U1F47B > '
rici
  • 234,347
  • 28
  • 237
  • 341
chepner
  • 497,756
  • 71
  • 530
  • 681