Skip to content
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

Support for the terminal title as part of the prompt string #504

Open
grawity opened this issue Apr 29, 2024 · 0 comments
Open

Support for the terminal title as part of the prompt string #504

grawity opened this issue Apr 29, 2024 · 0 comments

Comments

@grawity
Copy link

grawity commented Apr 29, 2024

Up to less v590, I used to (ab)use $MANLESS – which the man tool injects into $LESS as the -P option, for customizing the prompt – to additionally set the terminal title to the name of the manual page being shown. (This was a convenient way to do it because man automatically fills in the actual name(section) it's currently showing, which isn't known upfront so doing it from a shell alias would be troublesome.).

It wasn't a very good method (as it caused less to think that the prompt was twice as long as it was, leading to it getting prematurely truncated), but it worked well enough.

Basically I had an \e]0;$MAN_PN\a (ESC ] 0 ... BEL) as part of $MANLESS:

# approximately the default value of 'man -r'
export MANLESS="?ltline %lt?L/%L.:byte %bB?s/%s..?pB (%pB\\%). "

# put "manpage(section)" in the terminal title for xterm, in the less prompt otherwise
case $TERM in
	xterm*)	export MANLESS="${MANLESS}$(printf '\e]0;$MAN_PN\a')";;
	tmux*)	export MANLESS="${MANLESS}$(printf '\ek$MAN_PN\e\\\\')";;
	*)	export MANLESS="\$MAN_PN ${MANLESS}";;
esac

This stopped working in less v591, which enabled ANSI formatting in the prompt, but as a consequence the whole ESC ]0; now gets thrown away and the rest remains visible in the prompt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants