Skip to content

Instantly share code, notes, and snippets.

@gonzula
Last active November 8, 2018 21:18
Show Gist options
  • Save gonzula/ee464c5e3c42628dd1c26ba50dc7f288 to your computer and use it in GitHub Desktop.
Save gonzula/ee464c5e3c42628dd1c26ba50dc7f288 to your computer and use it in GitHub Desktop.
vimscript to set proxy icon in iTerm2
function! ITerm2ProxyIconTitle(wait) abort
if a:wait
sleep 10m // when resuming to foreground it only works if waits some time (don't ask me why)
endif
let arg = "\e]1337;SetProxyIcon=" . expand('%:p') . "\<c-G>"
if has('nvim')
call chansend(2, arg)
else
let cmd = 'silent !printf "' . arg . '"'
execute cmd
redraw!
redraw!
endif
endfunction
if $TERM_PROGRAM =~ "iTerm"
augroup proxy_icon
autocmd BufEnter,FocusGained * call ITerm2ProxyIconTitle(0)
if has('nvim')
autocmd VimResume * call ITerm2ProxyIconTitle(1)
endif
augroup END
endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment