-
Notifications
You must be signed in to change notification settings - Fork 407
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FR: Add \x01
and \x02
to the color formats to support $PS1
#3155
Comments
I'm not familiar with |
sorry i should have shared more info. yes, i'm suggesting printing they help https://superuser.com/a/301355 provides a quote and links to a wikipedia page which links to a (very old) message format manual. it looks like this is not supported everywhere: i found this issue for MS Terminal and it looks like dash doesn't support this because it doesn't support line editting...? i haven't used any shell other than bash and zsh. |
Appears that % printf '\x01' | less -FRX
^A Another way around is to make templater parse |
actually this is a non-issue. i wasn't thinking straight. apparently i can just generate the
and with jj's support on custom functions, creating these templates is very neat: echo -e "$(jj --ignore-working-copy --color never log -l1 -r @ --no-graph --config-toml "
[template-aliases]
'colored(color, txt)' = '''
surround('\x01\e[' ++ color ++ 'm\x02', '\x01\e[0m\x02', txt)
'''
'red(txt)' = '''colored('31', txt)'''
'green(txt)' = '''colored('32', txt)'''
'yellow(txt)' = '''colored('33', txt)'''
'blue(txt)' = '''colored('34', txt)'''
'magenta(txt)' = '''colored('35', txt)'''
'cyan(txt)' = '''colored('36', txt)'''
'white(txt)' = '''colored('37', txt)'''
" -T '
green(change_id.shortest())
' sorry for the noise and feel free to close this ticket. |
Is your feature request related to a problem? Please describe.
i was trying to use
jj --ignore-working-copy log --no-graph -l1 -r @ -T '...'
to build a$PS1
prompt. however, the coloring confuses the readline length calculation because of lack of\x01
/\x02
(or\[
/\]
) control characters.Describe the solution you'd like
always wrap color control codes with
\x01
/\x02
--- unless that would cause any problem?Describe alternatives you've considered
create a dedicated
$PS1
-generator like how Git has__git_ps1
.The text was updated successfully, but these errors were encountered: