Last active
November 8, 2018 21:18
-
-
Save gonzula/ee464c5e3c42628dd1c26ba50dc7f288 to your computer and use it in GitHub Desktop.
vimscript to set proxy icon in iTerm2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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