Add flexible tmux configuration load function.
Add function `_get_user_tmux_conf` to helper script `plugin_functions`. Function is searching for the users tmux configuration on multiple places by a prioritized order. The response is used within`_tmux_conf_contents` to read in the content as normally. Add new environment variable `TMUX_PLUGIN_MANAGER_CONFIG_LOCATION` which is optional to be defined. If so it has the highest priority to be loaded, despite if the file exist or not. XDG directory support has been added as well by the second priority location at `$XDG_CONFIG_HOME/tmux/tmux.conf`.
This commit is contained in:
parent
95f78336c3
commit
2c4a2dfd65
1 changed files with 23 additions and 1 deletions
|
@ -15,8 +15,30 @@ _tpm_path() {
|
|||
|
||||
_CACHED_TPM_PATH="$(_tpm_path)"
|
||||
|
||||
# Get the absolute path to the users configuration file of TMux.
|
||||
# This includes a prioritized search on different locations.
|
||||
#
|
||||
_get_user_tmux_conf() {
|
||||
# Define the different possible locations.
|
||||
custom_location="$TMUX_PLUGIN_MANAGER_CONFIG_LOCATION"
|
||||
xdg_location="$XDG_CONFIG_HOME/tmux/tmux.conf"
|
||||
default_location="$HOME/.tmux.conf"
|
||||
|
||||
# Search for the correct configuration file by priority.
|
||||
if [ -n "$custom_location" ]; then
|
||||
echo "$custom_location"
|
||||
|
||||
elif [ -f "$xdg_location" ]; then
|
||||
echo "$xdg_location"
|
||||
|
||||
else
|
||||
echo "$default_location"
|
||||
fi
|
||||
}
|
||||
|
||||
_tmux_conf_contents() {
|
||||
cat /etc/tmux.conf ~/.tmux.conf 2>/dev/null
|
||||
user_config=$(_get_user_tmux_conf)
|
||||
cat /etc/tmux.conf "$user_config" 2>/dev/null
|
||||
if [ "$1" == "full" ]; then # also output content from sourced files
|
||||
local file
|
||||
for file in $(_sourced_files); do
|
||||
|
|
Loading…
Reference in a new issue