@@ -6,13 +6,18 @@ autocmd BufEnter,BufFilePost * call s:update_document(0)
6
6
" these events might change the nature of the file,
7
7
" so we try to refresh its icon
8
8
autocmd BufWritePost ,FileChangedShellPost ,ShellCmdPost * call s: update_document (1 )
9
- autocmd VimLeave * call s: set_osc6 (' ' )
9
+
10
+ if &term != ' xterm-ghostty'
11
+ " For ghostty setting this to empty results in the path being set to "/"
12
+ " At least before https://github.com/ghostty-org/ghostty/pull/3399
13
+ autocmd VimLeave * call s: set_osc (' ' )
14
+ endif
10
15
11
16
function ! s: update_document (refresh)
12
17
let path = expand (' %:p' )
13
- if empty (path ) || ! filereadable ( path )
18
+ if empty (path )
14
19
" unnamed/unsaved file being edited
15
- call s: set_osc6 (' ' )
20
+ call s: set_osc (' ' )
16
21
else
17
22
let path = s: urlencode (path )
18
23
if a: refresh
@@ -21,14 +26,18 @@ function! s:update_document(refresh)
21
26
" reference to the same file
22
27
" (better than the flickering that happens when we temporarily set
23
28
" to empty)
24
- call s: set_osc6 (' file://' . path )
29
+ call s: set_osc (' file://localhost ' . path )
25
30
endif
26
- call s: set_osc6 (' file://' . hostname () . path )
31
+ call s: set_osc (' file://' . hostname () . path )
27
32
endif
28
33
endfunction
29
34
30
- function ! s: set_osc6 (pt )
31
- call system (' printf "\e]6;%s\a" >/dev/tty ' . shellescape (a: pt ))
35
+ function ! s: set_osc (pt )
36
+ let osc = ' 6'
37
+ if &term == ' xterm-ghostty'
38
+ let osc = ' 7'
39
+ endif
40
+ call system (' printf "\e]' . osc . ' ;%s\a" >/dev/tty ' . shellescape (a: pt ))
32
41
endfunction
33
42
34
43
0 commit comments