2

With vim running on cygwin, I would like to automatically set the window title on the active buffer name.

I wrote this:

function! SetMinttyTitle()
    silent !clear
    execute "!" . "echo -ne '\\e]0;". @% . "\\a' 2>&1 > /dev/null"
endfunction

au BufNewFile,BufEnter,BufRead * call SetMinttyTitle()

Unfortunately It doesn't work as expected. I didn't find the way to get rid of this message

"Press ENTER or type command to continue"

How can I run my command on the background?

nowox
  • 25,978
  • 39
  • 143
  • 293

1 Answers1

4

The usual answer is to use system() instead; it doesn't echo the output, but instead returns it. But that won't work in your case, as you need the output to be printed to your terminal. Temporarily resetting 'shellredir' may work:

set shellredir=
call system("clear; echo -ne '\\e]0;". @% . "\\a' 2>&1 > /dev/null")
set shellredir=>

But Vim actually has that functionality built-in, see :help 'titlestring'

Ingo Karkat
  • 167,457
  • 16
  • 250
  • 324