Skip to content

Commit 248bb78

Browse files
committed
Ghostty support
1 parent 19fb26f commit 248bb78

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

plugin/terminaldocument.vim

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ autocmd BufEnter,BufFilePost * call s:update_document(0)
66
" these events might change the nature of the file,
77
" so we try to refresh its icon
88
autocmd BufWritePost,FileChangedShellPost,ShellCmdPost * call s:update_document(1)
9-
autocmd VimLeave * call s:set_osc6('')
9+
autocmd VimLeave * call s:set_osc('')
1010

1111
function! s:update_document(refresh)
1212
let path = expand('%:p')
1313
if empty(path) || !filereadable(path)
1414
" unnamed/unsaved file being edited
15-
call s:set_osc6('')
15+
call s:set_osc('')
1616
else
1717
let path = s:urlencode(path)
1818
if a:refresh
@@ -21,14 +21,18 @@ function! s:update_document(refresh)
2121
" reference to the same file
2222
" (better than the flickering that happens when we temporarily set
2323
" to empty)
24-
call s:set_osc6('file://' . path)
24+
call s:set_osc('file://localhost' . path)
2525
endif
26-
call s:set_osc6('file://' . hostname() . path)
26+
call s:set_osc('file://' . hostname() . path)
2727
endif
2828
endfunction
2929

30-
function! s:set_osc6(pt)
31-
call system('printf "\e]6;%s\a" >/dev/tty ' . shellescape(a:pt))
30+
function! s:set_osc(pt)
31+
let osc = '6'
32+
if &term == 'xterm-ghostty'
33+
let osc = '7'
34+
endif
35+
call system('printf "\e]' . osc . ';%s\a" >/dev/tty ' . shellescape(a:pt))
3236
endfunction
3337

3438

0 commit comments

Comments
 (0)