]> git.rmz.io Git - dotfiles.git/commitdiff
vim: UpdateTmuxEnv function to import SSH_AUTH_SOCK
authorSamir Benmendil <me@rmz.io>
Fri, 11 Mar 2022 08:43:07 +0000 (08:43 +0000)
committerSamir Benmendil <me@rmz.io>
Fri, 11 Mar 2022 08:43:07 +0000 (08:43 +0000)
When a new ssh session to an existing tmux session is opened the
ssh-agent forwarding will use a new SSH_AUTH_SOCK path. This env
variable is updated within the tmux session, but running applications
will need to update it themselves.

Really this should be done automatically.

vim/plugin/update_tmux_env.vim [new file with mode: 0644]

diff --git a/vim/plugin/update_tmux_env.vim b/vim/plugin/update_tmux_env.vim
new file mode 100644 (file)
index 0000000..01df515
--- /dev/null
@@ -0,0 +1,7 @@
+function! <SID>UpdateTmuxEnv()
+    let env = trim(system("tmux showenv SSH_AUTH_SOCK"))
+    let es = split(env, "=")
+    call setenv(es[0], es[1])
+endfunction
+
+command! -nargs=0 UpdateTmuxEnv call <SID>UpdateTmuxEnv()