2

I would like to make vim screen tabs name more useful. I've turned on the screen plugin, and tried several approachs. One that I would enjoy most was to make the screen name fixed using another load screen file, i.e.:

screen -S sectionName -c .screenTest

and screenTest file would have something like:

source $HOME/.screenrc
chdir $HOME/place
# Screen 0
screen
stuff "something^M"
# Screen 1
screen
stuff "something^M"
stuff "cd place^M"                                                                                                 
stuff "vim -p `find -type f -not -path \"*/\.*\" -not -path \"*x86*\" \( -name \"*.py\" -o -name \"*.cxx\" -o -name \"*.h\" \)`^M"
title "Screen1"

The problem is that the title command is read before the stuff commands run. If someone knows how to make the title command runs afterwards the stuff commands are finished, it would be perfect. I tried:

stuff "^A:title TitleValue ^M"

but it doesn't write on the screen command insertion, it writes on the terminal (the ^A and ^M is written in vim using ^V^A).

Then I tried editing the screen.plugin.zsh file.

I tried changing the prexec and precmd zsh methods when the input command has vim to display the place instead. But I couldn't do that.

I am sorry to post it here, but if someone could help me do that, it sounds quite simple, but I am stuck at that even if I change the $cmd, it doesnt change the TAB syntax, that is, if I do:

if [[ "$cmd" == "vim*" ]]; then
  # How do I check if variable $cmd has string "vim" in it using zsh?
  echo "changing for vim!"
  cmd=''
fi

it changes the terminal title, but not the screen window title. Any ideas? This question is also here, but I think this question is more appropriated here, since it is not an oh-my-zsh issue exactly.

Another thing that would help, is that if I could set some windows not to change automatically their titles, whereas other would change.

4
  • I don't understand what you mean by "I tried changing the prexec and precmd to when the cmd have vim to display the place instead." You can change the screen title with the shell command print -n "\033kTITEL\033\134" if this helps in any way.
    – mpy
    Dec 16, 2014 at 20:18
  • @mpy the print -n was exactly what I wanted. You may post it as an answer: using stuff "print -n "\\033kTITEL\\033\\134\" " solved my issue instead of title. There are many other questions, but with time to study zsh I may learn it.
    – Werner
    Dec 16, 2014 at 20:38
  • As I don't fully understand what you want to achieve I hesitate to write a one-line-answer. Perhaps it's better if you write an answer yourself elaborating on your specific solution.
    – mpy
    Dec 17, 2014 at 20:31
  • @mpy but you deserve the reputation and so on. You can answer, and I may edit it so that it fills the purpose. I wanted to set the screen window title afterwards the stuff commands run, and with the title command it was changed before the stuff commands were run. By using stuff "print -n "\\033kTITEL\\033\\134\" " my screen titles are set as I wanted.
    – Werner
    Dec 18, 2014 at 12:34

2 Answers 2

2

The Screen User's Manual states:

To change the name after the window has been created you can use the title-string escape-sequence (<ESC> k name <ESC> \) (...)

So (without having digged into oh-my-zsh's modules, plugins etc.) you can use

print -n "\033kTITLE\033\134"

on the zsh command line to change the name of the current screen window to TITLE.

\033 represents an escape character in octal notation (ESC = 27 (decimal) = 0x1b (hex) = 033 (octal)) and \134 a backslash character.

According to your command, the following command works in the screen config file:

stuff "print -n "\\033kTITLE\\033\\134\" "
1

According to console_codes(4), the portable way of setting the title is to use the VT100 sequence OSC 0 ; title ST. OSC (operating system command) is defined in ECMA-48 to be \x9d or ESC ]. ST (string terminator) is defined in ECMA-48 to be \x9c or ESC \; VT100 & xterm also allow BEL to be used. So all that to say:

printf '\x1b]0;%s\x07' "$your_title"

Or if you love inferior octals for some reason:

printf '\033]0;%s\007' "$your_title"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .