If tmux.conf refers other file by source-file command that uses variable, it'll be better to expand variables into actual values.
Background
In XDG style directory, I'd like to use tmux.conf with variables like following example.
# tmux.conf ------------------------------------------------
TMUX_CONF_PATH="~/.config/tmux"
source "${TMUX_CONF_PATH}/general.conf"
source "${TMUX_CONF_PATH}/plugins.conf"
source "${TMUX_CONF_PATH}/pane.conf"
source "${TMUX_CONF_PATH}/status.conf"
# plugins.conf ---------------------------------------------
TMUX_PLUGIN_MANAGER_PATH="~/.local/share/tmux/plugins"
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
run "${TMUX_PLUGIN_MANAGER_PATH}/tpm/tpm"
It works well about tmux configurations, but tpm can't read @plugin entries from plugins.conf.
Current version of tpm expands ~ to $HOME with _manual_expansion() function, but never expands variables.
Solution
In _sourced_files() function, tpm extract parameter of source-file commands from tmux.conf.
We can put these parameters into echo command and process with bash, then get filenames with parameters expanded. Both single and double quotation marks are must be recognized correctly.
# intermediate script, to be processed with bash
echo "${TMUX_CONF_PATH}/general.conf"
echo "${TMUX_CONF_PATH}/plugins.conf"
echo "${TMUX_CONF_PATH}/pane.conf"
echo "${TMUX_CONF_PATH}/status.conf"
If tmux.conf refers other file by source-file command that uses variable, it'll be better to expand variables into actual values.
Background
In XDG style directory, I'd like to use
tmux.conf
with variables like following example.It works well about tmux configurations, but tpm can't read
@plugin
entries fromplugins.conf
.Current version of tpm expands
~
to$HOME
with_manual_expansion()
function, but never expands variables.Solution
In
_sourced_files()
function, tpm extract parameter ofsource-file
commands fromtmux.conf
.We can put these parameters into
echo
command and process withbash
, then get filenames with parameters expanded. Both single and double quotation marks are must be recognized correctly.