In general, it's not a problem to have multiple autocmd
for the same event. Moreover, they are guaranteed to execute in the very same order. So you can write it this way:
augroup tmux | au!
autocmd BufEnter * call system("tmux rename-window " . expand("%:t"))
autocmd BufEnter * !tmux set -a window-status-current-style "fg=\#{@vimfile}"
augroup end
- the first command has to use
expand()
(and so system()
) not to fail on empty file/buffer name;
- the second command has an extra backslash
\#
because of the Vim's command-line parser;
Note however that in this case you spawn tmux process twice (as well as shell process) per each BufEnter which is suboptimal.
Instead of this, you can use a semicolon to pass multiple tmux commands per a single invocation. It's also possible to take care of an empty file name like this:
augroup tmux | au!
autocmd BufEnter * call system(printf('tmux rename-window %s\;
\ set -a window-status-current-style "fg=#{@vimfile}"',
\ empty(@%) ? 'Noname' : fnamemodify(@%, ':t')))
augroup end
(Yet another backslash \;
is needed for the shell's parser).