From e7b6b7eabcf585a92aaaa1c8da7f694b7a49f3ab Mon Sep 17 00:00:00 2001 From: esc Date: Sun, 8 Feb 2009 04:13:46 +0100 Subject: [PATCH] adding -f (force) switch to xtrename xtrename checks if $DISPLAY is set before printing the escape sequence that changes the xterm title. However, in certain circumstances this may not be an optimal check. For example: if the shell is running on a remote server which is headless, but an xterm is being used locally. In this case you can now use the -f switch to force the escape sequence to be issued regardless of the state of $DISPLAY. --- etc/zsh/zshrc | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/etc/zsh/zshrc b/etc/zsh/zshrc index 67fc640..681d1d4 100644 --- a/etc/zsh/zshrc +++ b/etc/zsh/zshrc @@ -3840,16 +3840,21 @@ mkmaildir() { mkdir -p ${root}/${subdir}/{cur,new,tmp} } -# xtrename() rename xterm from within GNU-screen +#f5# Change the xterm title from within GNU-screen xtrename() { - if [[ -z ${DISPLAY} ]] ; then - printf 'xtrename only makes sense in X11.\n' - return 1 + if [[ ${1} != "-f" ]] ; then + if [[ -z ${DISPLAY} ]] ; then + printf 'xtrename only makes sense in X11.\n' + return 1 + fi + else + shift fi if [[ -z ${1} ]] ; then - printf 'usage: xtrename() "title for xterm"\n' + printf 'usage: xtrename [-f] "title for xterm"\n' printf ' renames the title of xterm from _within_ screen.\n' - printf ' Also works without screen.\n' + printf ' also works without screen.\n' + printf ' will not work if DISPLAY is unset, use -f to override.\n' return 0 fi print -n "\eP\e]0;${1}\C-G\e\\" -- 2.1.4