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?
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'