Closed ThSGM closed 1 year ago
Hello @ThSGM 👋
I explored the idea of having the location of .tmux.conf
and .tmux.conf.local
configurable in the gh200-gh221
branch.
To use it you would need to somewhat launch tmux the following way
$ TMUX_CONF=/foo/bar/tmux.conf TMUX_CONF_LOCAL=/foo/bar/tmux.conf.local tmux -f /foo/bar/tmux.conf
or
$ TMUX_CONF=/foo/bar/tmux.conf TMUX_CONF_LOCAL=/foo/bar/tmux.conf.local sh -c 'tmux -f $TMUX_CONF'
The branch is way behind master
.
I wasn't sure I would ever merge it but I see tmux 3.2
is going to try $XDG_CONFIG_HOME/tmux/tmux.conf
as well as ~/.config/tmux/tmux.conf
.
I'm still not sure how I'll handle this.
In the meantime, your best bet is to symlink ~/.tmux.conf
.
By no mean an ideal solution but why not put the files where you prefer and create symlinks where this repo expects them?
@elisiano indeed the current solution is to clone the repository anywhere you want provided you:
~/.tmux.conf
symlink exists~/.tmux.conf.local
copy (or a symlink to a valid copy)By no mean an ideal solution but why not put the files where you prefer and create symlinks where this repo expects them?
@elisiano and @gpakosz
Indeed this is what I currently do. It is just an effort to try to clean up the number of files in my home directory. With the XDG Specifications, it makes sense to shuffle everything into .config/tmux though.
With the XDG Specifications, it makes sense to shuffle everything into .config/tmux though.
Well yes and no. Only tmux 3.2
understand XDG and it's a Linux thing only
@gpakosz Are you sure about that? I'm on tmux 3.1c and on a Mac, and my config is at ~/.config/tmux/tmux.conf
. Everything is working as expected.
@wren You're right it's in 3.1c
@gpakosz Ah, that makes sense. There's also a bunch of terminal apps that I use that support XDG even though I'm on a Mac.
Anyway, I have a hastily modified version of your script in my dotfiles (in order to have a custom location). I've been thinking about sending over a proper PR to add the functionality. If that's something you might be open to, I'm happy to talk through implementation details to iron something out. Do you think that's something you'd be interested in?
By no mean an ideal solution but why not put the files where you prefer and create symlinks where this repo expects them?
@elisiano I believe the overall impetus is to keep a clean home directory.
Hey @wren 👋
I have multiple branches in the work so PR not really welcome as it's going to create more merge burden than anything else. Thanks anyway
Hey @wren 👋
I have multiple branches in the work so PR not really welcome as it's going to create more merge burden than anything else. Thanks anyway
Ok, makes sense. Thanks for the response.
I'd really like to see this happen as well. Happy to do a PR or whatever is appropriate to help.
@gpakosz i am on 3.3a and i think tmux.conf.local
is only referenced from tmux.conf so if all the hard links to tmux.conf.local
in tmux.conf
are changed than it should work no? This is how it is working for me. as per the man page
Also Using simple variables to hold file paths would be convenient.
from the man page :
-f file Specify an alternative configuration file. By default, tmux loads the system configuration file
from /etc/tmux.conf, if present, then looks for a user configuration file at ~/.tmux.conf,
$XDG_CONFIG_HOME/tmux/tmux.conf or ~/.config/tmux/tmux.conf.
The configuration file is a set of tmux commands which are executed in sequence when the server
is first started. tmux loads configuration files once when the server process has started. The
source-file command may be used to load a file later.
So tmux can see configuration files under $XDG_CONFIG_HOME/tmux
or
~/.config/tmux
Once that's detected source-file
can be used to source the tmux.conf.local
from
tmux.conf
.
Can you please try the gh-200+221+439+586
branch?
I have tried, but it's not picked all my local config. Keybindings and some UI is picked. Tried with default tmux.conf.local
is also still broken.
sed
hack = sed -i 's#\.tmux\.conf#.config/tmux/tmux.conf#g' ~/.local/share/oh-my-tmux/.tmux.conf
Default local config with sed
hack:
Default local config with that branch:
My local config with sed
hack:
My local config with that branch:
Hello @latipun7
Can you please tell me
After having switched to the gh-200+221+439+586
branch (commit 1591e944012c7883f186c26e2ef846a177d96867
) and made sure .tmux.conf
is unmodified, can you please make sure all tmux processes are killed, then launch tmux, and then paste the result of
$ env | grep TMUX
Thank you
~/.local/share/oh-my-tmux
is just git clone https://github.com/gpakosz/.tmux.git ~/.local/share/oh-my-tmux
then I checked out the gh-200+221+439+586
branch (commit 1591e944
)ln -s -f ~/.local/share/oh-my-tmux/.tmux.conf ~/.config/tmux/tmux.conf
cp ~/.local/share/oh-my-tmux/.tmux.conf.local ~/.config/tmux/tmux.conf.local
.tmux.conf
is unmodified.
❯ env | rg TMUX
TMUX=/tmp/tmux-1000/default,9781,0
TMUX_CONF=/home/latipun/.config/tmux/tmux.conf
TMUX_CONF_LOCAL=/home/latipun/.config/tmux/tmux.conf.local
TMUX_PANE=%0
TMUX_PLUGIN_MANAGER_PATH=/home/latipun/.local/share/tmux/plugins
ZSH_TMUX_CONFIG=/home/latipun/.config/tmux/tmux.conf
ZSH_TMUX_TERM=screen-256color
_ZSH_TMUX_FIXED_CONFIG=/home/latipun/.local/share/oh-my-zsh/plugins/tmux/tmux.extra.conf
🤔 You should see a TMUX_EXECUTABLE
environment variable
I pushed commit 9149b2e89f718cbc019ece9526416e7d628f8c3b
, can you please update and after having launched tmux, can you please paste the output of the following command?
$ cut -c3- "$TMUX_CONF" | sh -sx _apply_configuration
I didn't set TMUX_EXECUTABLE
, my tmux bin is at default /usr/bin/tmux
❯ cut -c3- "$TMUX_CONF" | sh -sx _apply_configuration
+ :
+ set -e
+ unset GREP_OPTIONS
+ export LC_NUMERIC=C
+ LC_NUMERIC=C
+ set +H
+ set +H
+ printf ''
+ sed -E s///
+ '[' -z /tmp/tmux-1000/default,12645,0 ']'
++ printf %s /tmp/tmux-1000/default,12645,0
++ cut -d, -f1
+ TMUX_SOCKET=/tmp/tmux-1000/default
+ '[' -z '' ']'
++ lsof -a -U -Fp /tmp/tmux-1000/default
++ perl -n -e 'print if s/^p//g'
+ TMUX_PID=
++ lsof -b -w -a -d txt -p '' -Fn
++ perl -n -e 'do {print; last } if s/^n((?:.(?!dylib$|so$))+)$/\1/g'
+ TMUX_EXECUTABLE=
++ uname -s
+ _uname_s=Linux
++ tmux -V
++ '' -S /tmp/tmux-1000/default -V
++ awk '{gsub(/[^0-9.]/, "", $2); print ($2+0) * 100}'
main: line 184: : command not found
+ _tmux_version=
+ command -v pkill
+ _apply_configuration
++ tmux display -p '#{window_active}'
++ true
+ window_active=
+ '[' -z '' ']'
+ command -v perl
+ command -v sed
+ command -v awk
+ '[' -lt 240 ']'
main: line 1481: [: -lt: unary operator expected
+ command -v reattach-to-user-namespace
+ case "$_uname_s" in
+ _apply_24b
+ tmux_conf_theme_24b_colour=auto
+ _apply_theme
+ tmux_conf_24b_colour=true
+ '[' xtrue = xauto ']'
+ _is_true true
+ '[' xtrue = xtrue ']'
+ wait
+ apply_24b=true
+ '[' xtrue = xtrue ']'
+ case "$TERM" in
+ _apply_bindings
+ rm -f /tmp/log.txt
++ mktemp
+ exec
+ cfg=/tmp/tmp.4nQXu0kdKK
+ trap 'rm -f $cfg*' EXIT
+ tmux list-keys
+ '' -S /tmp/tmux-1000/default list-keys
+ grep -vF tmux.conf.local
+ grep -E 'new-window|split(-|_)window|new-session|copy-selection|copy-pipe'
main: line 184: : command not found
+ rm -f /tmp/tmp.4nQXu0kdKK
+ _apply_plugins
+ tmux_conf_update_plugins_on_launch=true
+ tmux_conf_update_plugins_on_reload=true
+ tmux_conf_uninstall_plugins_on_reload=true
+ tmux run -b 'cut -c3- "/home/latipun/.config/tmux/tmux.conf" | sh -s __apply_plugins "" "true" "true" "true"'
+ '' -S /tmp/tmux-1000/default run -b 'cut -c3- "/home/latipun/.config/tmux/tmux.conf" | sh -s __apply_plugins "" "true" "true" "true"'
main: line 184: : command not found
I see, it's TMUX_EXECUTABLE
detection that doesnt' work
Do you have lsof
?
yes I do have lsof
, installed just now if it is needed for debug or something
If you installed it just now then that explains why it was not working before. I need to figure out what to do when lsof
is not available. I'll keep you posted
I'm sorry, I didn't notice your full comments.
I didn't update to the 9149b2e89f718cbc019ece9526416e7d628f8c3b
commit yet.
After updating it, now it is works even without TMUX_EXECUTABLE
set. Thank you :pray:
It now works because you installed lsof
🙂
Oh my... lol, so that's required for the config to run properly. I thought it was for debugging.
Dem right, after uninstalling lsof
, the config back to broken state.
Can you please
lsof
a7c917744309cf522b4cbf5eb191f8d82014f261
?TMUX_EXECUTABLE
should be set to /usr/bin/tmux
. If detection fails, at least the variable should contain tmux
.
It that doesn't work, I'll debug more later
lsof
TMUX_EXECUTABLE
after launching tmux, the TMUX_EXECUTABLE
is properly detected and set.
But I noticed that the weather widget is not updated, always empty string.
My weather widget at tmux.conf.local
:
# weather() {
# curl -fsm3 'wttr.in/Godean?format=%l:+%c%t+%w+(%m+%M)\n' || printf '\n'
# sleep 9 # 9s elapsed... still not updating
# }
Commit a75fdbb2da446f827a04392a767991b7d5accefc
should fix custom variables.
Thank you, @gpakosz :tada: Now it works! I didn't notice any problem.
Thanks @latipun7 for the tests, appreciated 👍
I'll do more testing myself and wait for the dust to settle before merging
What's TMUX_EXECUTABLE
for you btw?
Yeah, thank you. I'll wait for this to be merged :rocket:
Here's the complete env now (ZSH_TMUX*
is from oh-my-zsh
plugin):
❯ env | rg TMUX
TMUX=/tmp/tmux-1000/default,44186,0
TMUX_CONF=/home/latipun/.config/tmux/tmux.conf
TMUX_CONF_LOCAL=/home/latipun/.config/tmux/tmux.conf.local
TMUX_EXECUTABLE=/usr/bin/tmux
TMUX_PANE=%0
TMUX_PLUGIN_MANAGER_PATH=/home/latipun/.local/share/tmux/plugins
ZSH_TMUX_CONFIG=/home/latipun/.config/tmux/tmux.conf
ZSH_TMUX_TERM=screen-256color
_ZSH_TMUX_FIXED_CONFIG=/home/latipun/.local/share/oh-my-zsh/plugins/tmux/tmux.extra.conf
also, the only environment I set myself (as I remember) is only TMUX_PLUGIN_MANAGER_PATH
which is I set it from tmux.conf.local
I prefer to keep my tmux configuration files in .config/tmux according to the XDG Directory Specifications. Is there an easy way to do this?
I suppose that we could go and replace all the hardcoded ~/.tmux.conf references in the .tmux.conf file but I was hoping for a more elegant way.