gpakosz / .tmux

🇫🇷 Oh my tmux! My self-contained, pretty & versatile tmux configuration made with ❤️
MIT License
21.73k stars 3.34k forks source link

Tmux e binding to open local conf file not have syntax #667

Closed yash-fn closed 9 months ago

yash-fn commented 1 year ago

$EDITOR is set to vim for me. when .tmux.conf.local opens in vim it does not treat it like .tmux.conf and does not have proper syntax highlighting. Must use :set syntax=tmux to get proper highlighting.

Changing (within .tmux.conf -> the file we should not modify)

# edit configuration
bind e new-window -n "#{TMUX_CONF_LOCAL}" sh -c '${EDITOR:-vim} "$TMUX_CONF_LOCAL" && "$TMUX_PROGRAM" ${TMUX_SOCKET:+-S "$TMUX_SOCKET"} source "$TMUX_CONF" \; display "$TMUX_CONF_LOCAL sourced"'

change it to:

# edit configuration
bind e new-window -n "#{TMUX_CONF_LOCAL}" sh -c '${EDITOR:-vim} -c ":set syntax=tmux" "$TMUX_CONF_LOCAL" && "$TMUX_PROGRAM" ${TMUX_SOCKET:+-S "$TMUX_SOCKET"} source "$TMUX_CONF" \; display "$TMUX_CONF_LOCAL sourced"'

fixes problem, but not sure if this is canonical way to do this (what if other editor is used ...?)

gpakosz commented 1 year ago

Hello @yash-fn 👋

Thanks for the `-c ":set syntax=tmux" idea. I'll have a look.

In the meantime you can add the line you came up with in your .local customization file copy

bind e new-window -n "#{TMUX_CONF_LOCAL}" sh -c '${EDITOR:-vim} -c ":set syntax=tmux" "$TMUX_CONF_LOCAL" && "$TMUX_PROGRAM" ${TMUX_SOCKET:+-S "$TMUX_SOCKET"} source "$TMUX_CONF" \; display "$TMUX_CONF_LOCAL sourced"'
yash-fn commented 1 year ago

oh great thanks! Will add to my local file instead of main tmux file.

gpakosz commented 9 months ago

Hello @yash-fn 👋

I finally pushed the gh-667 branch with your suggestion.

yash-fn commented 9 months ago

Very cool! Thanks for all your hard work! Works great!