Skip to content

Commit

Permalink
fix: Fix issues with emoji in prompt
Browse files Browse the repository at this point in the history
Once the color escape sequences caused no issues anymore, there were sometimes still small issues.
'🌊' is a 4-byte character, but only takes up width of 2 characters, which caused those remaining issues with readline.
The solution is to use hexcode representation of '🌊' to be able to mark 2 out of the 4 bytes as invisible characters for readline.

I found out about this workaround here: https://stackoverflow.com/a/56688167/24880406
  • Loading branch information
itislu committed Sep 24, 2024
1 parent d86bee1 commit 0f07b8f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion include/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@
# define PROMPT "🌊rash$ "
# define HEREDOC_PROMPT "> "
# else
# define PROMPT "\1\e[3;34m\2🌊\1\e[0m\2\1\e[1;34m\2rash$\1\e[0m\2 "
// '🌊' is a 4-byte character, but only takes up width of 2 characters ->
// use hexcode of '🌊' to mark 2 bytes as invisible characters
# define PROMPT \
"\1\e[3;34m\2\xf0\x9f\1\x8c\x8a\2\1\e[0m\2\1\e[1;34m\2rash$\1\e[0m\2 "
# define HEREDOC_PROMPT "\e[1;37m> \e[0m"
# endif

Expand Down

0 comments on commit 0f07b8f

Please sign in to comment.