So recently Apple have included support for displaying the working directory and file in the status bar of Terminal. The escape sequence that must be sent (to set the current file) is this:
ESC ] 6 ; Pt BEL
where Pt
is a file://
url pointing to the file currently being edited. So I figured I could get Vim to send this command as an escape sequence, but I'm having a bit of trouble. I have this so far:
au BufNewFile,BufReadPost,BufFilePost,BufWritePost * echo <escape sequence>
but I have a feeling that it won't quite work like that. Also, I have no idea how to get the current file as a file://
url, although I suspect netrw might be able to help me. Any ideas?
Edit
So far, I have this:
au BufNewFile,BufReadPost,BufFilePost * echo printf('\e]6;file://%s%s\a', $HOSTNAME, expand('%:p'))
but it still isn't working - $HOSTNAME
isn't getting expanded. Anyone have any tips on how to make this expand?
Edit 2
OK, so I've made some changes to the quotes and exported $HOSTNAME
, and now this is printing out fine. But instead of literally echoing the escape sequences, vim is printing them like ^[
, which makes them useless! And so here comes my real question: how do you make vim send literal escape sequences to the shell?
Success!
The final code is as follows:
set title
set t_ts=^[]6;
set t_fs=^G
auto BufEnter * let &titlestring = "file://" . hostname() . expand("%:p")