Skip to content

Commit 0128e36

Browse files
authored
Merge pull request #143 from weilbith/xdg-support
Flexible TMux Configuration Load
2 parents 9be9fd1 + 0e46b92 commit 0128e36

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

scripts/helpers/plugin_functions.sh

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,26 @@ _tpm_path() {
1515

1616
_CACHED_TPM_PATH="$(_tpm_path)"
1717

18+
# Get the absolute path to the users configuration file of TMux.
19+
# This includes a prioritized search on different locations.
20+
#
21+
_get_user_tmux_conf() {
22+
# Define the different possible locations.
23+
xdg_location="$XDG_CONFIG_HOME/tmux/tmux.conf"
24+
default_location="$HOME/.tmux.conf"
25+
26+
# Search for the correct configuration file by priority.
27+
if [ -f "$xdg_location" ]; then
28+
echo "$xdg_location"
29+
30+
else
31+
echo "$default_location"
32+
fi
33+
}
34+
1835
_tmux_conf_contents() {
19-
cat /etc/tmux.conf ~/.tmux.conf 2>/dev/null
36+
user_config=$(_get_user_tmux_conf)
37+
cat /etc/tmux.conf "$user_config" 2>/dev/null
2038
if [ "$1" == "full" ]; then # also output content from sourced files
2139
local file
2240
for file in $(_sourced_files); do

0 commit comments

Comments
 (0)