Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command <prefix> e is not opening .tmux.conf.local #744

Closed
Nicholas-Autio-Mitchell opened this issue May 16, 2024 · 7 comments
Closed

Command <prefix> e is not opening .tmux.conf.local #744

Nicholas-Autio-Mitchell opened this issue May 16, 2024 · 7 comments

Comments

@Nicholas-Autio-Mitchell

Using <prefix> e is not opening ~/.tmux.conf.local as usual. The prefix key is working, and all other bindings that I use are working fine. I have the latest commit, and the line in .tmux.conf the creates the bind e is there.

I found this issue reporting the same problem, and followed similar debug steps there, all info below.

I cannot think of anything else I may've changed to break this. MY bash configs were last touched long before this occured.

Debugging info

  1. EDITOR='emacs -nw --no-splash' (nw means no window). I can open the file using emacs with this command. `~/.tmux.conf.local

  2. Running sh -cx '${EDITOR:-vim} ~/.tmux.conf.local && tmux source ~/.tmux.conf && tmux display "~/.tmux.conf sourced"' works without any issues:

    + emacs -nw --no-splash /home/myuser/.tmux.conf.local
    + tmux source /home/myuser/.tmux.conf
    + tmux display ~/.tmux.conf sourced
  3. In ~/.tmux.conf replace cfg=$(mktemp) && trap 'rm -f $cfg*' EXIT with cfg=/tmp/tmux.conf -- then run cut -c3- ~/.tmux.conf | sh -sx _apply_bindings.

    Output of that command:

    π ▶ cut -c3- ~/.tmux.conf | sh -sx _apply_bindings
    + :
    + set -e
    + unset GREP_OPTIONS
    + export LC_NUMERIC=C
    + set +H
    + printf
    + sed -E s///
    + uname -s
    + _uname_s=Linux
    + [ -z /tmp/tmux-1000/default,15771,1 ]
    + [ -z /tmp/tmux-1000/default ]
    + [ -z /home/linuxbrew/.linuxbrew/bin/tmux ]
    + [ /home/linuxbrew/.linuxbrew/bin/tmux = tmux ]
    + tmux -V
    + /home/linuxbrew/.linuxbrew/bin/tmux -S /tmp/tmux-1000/default -V
    + awk {gsub(/[^0-9.]/, "", $2); print ($2+0) * 100}
    + _tmux_version=340
    + command -v pkill
    + _apply_bindings
    + cfg=/tmp/tmux.conf
    + tmux_conf_preserve_stock_bindings=false
    + tmux list-keys
    + /home/linuxbrew/.linuxbrew/bin/tmux -S /tmp/tmux-1000/default list-keys
    + grep -vF TMUX_CONF_LOCAL
    + grep -E new-window|split(-|_)window|new-session|copy-selection|copy-pipe
    + _is_true false
    + [ false = true ]
    + [ false = yes ]
    + [ false = 1 ]
    + perl -p -i -e s/'#\{\?window_zoomed_flag,Unzoom,Zoom\}' 'z' \{resize-pane -$/'#{?window_zoomed_flag,Unzoom,Zoom}' 'z' {resize-pane -Z}"/g /tmp/tmux.conf
    + tmux_conf_new_window_retain_current_path=true
    + _is_disabled true
    + [ true = disabled ]
    + perl -p -i -e
    s/\brun-shell\b\s+("|')cut\s+-c3-\s+(.+?)\s+\|\s+sh\s+-s\s+_new_window\s+#\{pane_pid\}\s+#\{b:pane_tty\}([^\n\1]*?)(?:\s+-c\s+((?:\\{1,3}")?|"?|'?)#\{pane_current_path\}\4)([^\n\1]*?)\1/run-shell \1cut -c3- \2 | sh -s _new_window #\{pane_pid\} #\{b:pane_tty\}\3\5\1/g
    ;
    s/\brun-shell\b\s+("|')cut\s+-c3-\s+.+?\s+\|\s+sh\s+-s\s+_new_window\s+#\{pane_pid\}\s+#\{b:pane_tty\}(\s+.+?)?\1/new-window\2/g
    ;
    s/\bnew-window\b([^;}\n]*?)(?:\s+-c\s+((?:\\")?|"?|'?)#\{pane_current_path\}\2)/new-window\1/g /tmp/tmux.conf
    + perl -p -i -e
    s,\bnew-window\b((?:(?:[ \t]+-[bdfhIvP])|(?:[ \t]+-[celtF][ \t]+(?!\bssh\b)[^\s]+))*)?(?:\s+(\bssh\b))((?:(?:[ \t]+-[bdfhIvP])|(?:[ \t]+-[celtF][ \t]+(?!\bssh\b)[^\s]+))*)?,run-shell 'cut -c3- "/home/myuser/.tmux.conf" | sh -s _new_window_ssh #\{pane_pid\} #\{b:pane_tty\}\1',g if /\bnew-window\b((?:(?:[ \t]+-[bdfhIvP])|(?:[ \t]+-[celtF][ \t]+(?!ssh)[^\s]+))*)?(?:\s+(ssh))((?:(?:[ \t]+-[bdfhIvP])|(?:[ \t]+-[celtF][ \t]+(?!ssh)[^\s]+))*)?/ /tmp/tmux.conf
    + tmux_conf_new_window_reconnect_ssh=false
    + _is_disabled false
    + [ false = disabled ]
    + _is_true false
    + [ false = true ]
    + [ false = yes ]
    + [ false = 1 ]
    + tmux_conf_new_window_retain_current_path=true
    + _is_disabled true
    + [ true = disabled ]
    + _is_true true
    + [ true = true ]
    + perl -p -i -e
    s/\bnew-window\b(?!\s+(?:-|}))/{$&}/g if /\bdisplay-menu\b/
    ;
    s/\bnew-window\b/new-window -c '#{pane_current_path}'/g
    ;
    s/\brun-shell\b\s+'cut\s+-c3-\s+(.+?)\s+\|\s+sh\s+-s\s+_new_window(_ssh)?\s+#\{pane_pid\}\s+#\{b:pane_tty\}([^}\n']*)'/run-shell 'cut -c3- \1 | sh -s _new_window\2 #\{pane_pid\} #\{b:pane_tty\} -c \\"#\{pane_current_path\}\\"\3'/g if /\bdisplay-menu\b/
    ;
    s/\brun-shell\b\s+'cut\s+-c3-\s+(.+?)\s+\|\s+sh\s+-s\s+_new_window(_ssh)?\s+#\{pane_pid\}\s+#\{b:pane_tty\}([^}\n']*)'/run-shell 'cut -c3- \1 | sh -s _new_window\2 #\{pane_pid\} #\{b:pane_tty\} -c "#\{pane_current_path\}"\3'/g /tmp/tmux.conf
    + tmux_conf_new_pane_retain_current_path=true
    + _is_disabled true
    + [ true = disabled ]
    + perl -p -i -e
    s/\brun-shell\b\s+("|')cut\s+-c3-\s+(.+?)\s+\|\s+sh\s+-s\s+_split_window\s+#\{pane_pid\}\s+#\{b:pane_tty\}([^\n\1]*?)(?:\s+-c\s+((?:\\{1,3}")?|"?|'?)#\{pane_current_path\}\4)([^\n\1]*?)\1/run-shell \1cut -c3- \2 | sh -s _split_window #\{pane_pid\} #\{b:pane_tty\}\3\5\1/g
    ;
    s/\brun-shell\b\s+("|')cut\s+-c3-\s+.+?\s+\|\s+sh\s+-s\s+_split_window\s+#\{pane_pid\}\s+#\{b:pane_tty\}(\s+.+?)?\1/split-window\2/g
    ;
    s/\bsplit-window\b([^;}\n]*?)(?:\s+-c\s+((?:\\")?|"?|'?)#\{pane_current_path\}\2)/split-window\1/g /tmp/tmux.conf
    + perl -p -i -e
    s,\bsplit-window\b((?:(?:[ \t]+-[bdfhIvP])|(?:[ \t]+-[celtF][ \t]+(?!\bssh\b)[^\s]+))*)?(?:\s+(\bssh\b))((?:(?:[ \t]+-[bdfhIvP])|(?:[ \t]+-[celtF][ \t]+(?!\bssh\b)[^\s]+))*)?,run-shell 'cut -c3- "/home/myuser/.tmux.conf" | sh -s _split_window_ssh #\{pane_pid\} #\{b:pane_tty\}\1',g if /\bsplit-window\b((?:(?:[ \t]+-[bdfhIvP])|(?:[ \t]+-[celtF][ \t]+(?!ssh)[^\s]+))*)?(?:\s+(ssh))((?:(?:[ \t]+-[bdfhIvP])|(?:[ \t]+-[celtF][ \t]+(?!ssh)[^\s]+))*)?/ /tmp/tmux.conf
    + tmux_conf_new_pane_reconnect_ssh=false
    + _is_disabled false
    + [ false = disabled ]
    + _is_true false
    + [ false = true ]
    + [ false = yes ]
    + [ false = 1 ]
    + _is_disabled true
    + [ true = disabled ]
    + _is_true true
    + [ true = true ]
    + perl -p -i -e
    s/\bsplit-window\b(?!\s+(?:-|}))/{$&}/g if /\bdisplay-menu\b/
    ;
    s/\bsplit-window\b/split-window -c '#{pane_current_path}'\1/g
    ;
    s/\brun-shell\b\s+'cut\s+-c3-\s+(.+?)\s+\|\s+sh\s+-s\s+_split_window(_ssh)?\s+#\{pane_pid\}\s+#\{b:pane_tty\}([^}\n']*)'/run-shell 'cut -c3- \1 | sh -s _split_window\2 #\{pane_pid\} #\{b:pane_tty\} -c \\"#\{pane_current_path\}\\"\3'/g if /\bdisplay-menu\b/
    ;
    s/\brun-shell\b\s+'cut\s+-c3-\s+(.+?)\s+\|\s+sh\s+-s\s+_split_window(_ssh)?\s+#\{pane_pid\}\s+#\{b:pane_tty\}([^}\n']*)'/run-shell 'cut -c3- \1 | sh -s _split_window\2 #\{pane_pid\} #\{b:pane_tty\} -c "#\{pane_current_path\}"\3'/g /tmp/tmux.conf
    + tmux_conf_new_session_prompt=false
    + _is_disabled false
    + [ false = disabled ]
    + _is_true false
    + [ false = true ]
    + [ false = yes ]
    + [ false = 1 ]
    + perl -p -i -e s/\bcommand-prompt\s+-p\s+new-session\s+"new-session\s+-s\s+'%%'"/new-session/g /tmp/tmux.conf
    + tmux_conf_new_session_retain_current_path=false
    + _is_disabled false
    + [ false = disabled ]
    + _is_true false
    + [ false = true ]
    + [ false = yes ]
    + [ false = 1 ]
    + perl -p -i -e
    s/\bnew-session\b([^;}\n]*?)(?:\s+-c\s+((?:\\")?|"?|'?)#\{pane_current_path\}\2)/new-session\1/g /tmp/tmux.conf
    + tmux_conf_copy_to_os_clipboard=false
    + command -v xsel
    + command -v xsel
    + command -v xclip
    + [ tty = wayland ]
    + command -v pbcopy
    + command -v clip.exe
    + [ -c /dev/clipboard ]
    + [ -n  ]
    + awk {i = $2 == "-T" ? 4 : 5; gsub(/^[;]$/, "\\\\&", $i); gsub(/^[$"#~]$/, "'&'", $i); gsub(/^[']$/, "\"&\"", $i); print}
    + tmux source-file /tmp/tmux.conf.in
    + /home/linuxbrew/.linuxbrew/bin/tmux -S /tmp/tmux-1000/default source-file /tmp/tmux.conf.in

    Contents of /tmp/tmux.conf.in:

       1 bind-key    -T copy-mode    C-k                    run-shell "tmux     send-keys -X copy-pipe-end-of-line-and-cancel; /home/myuser/.tmux/plugins/tmux-copycat/scripts/copycat_mode_quit.sh; true"
       2 bind-key    -T copy-mode    C-w                    run-shell "tmux     send-keys -X copy-pipe-and-cancel; /home/myuser/.tmux/plugins/tmux-copycat/scripts/copycat_mode_quit.sh; true"
       3 bind-key    -T copy-mode    MouseDragEnd1Pane      run-shell "tmux     send-keys -X copy-pipe-and-cancel; /home/myuser/.tmux/plugins/tmux-copycat/scripts/copycat_mode_quit.sh; true"
       4 bind-key    -T copy-mode    DoubleClick1Pane       run-shell "tmux     select-pane \\; send-keys -X select-word \\; run-shell -d 0.3 \\; send-keys -X copy-pipe-and-cancel; /home/myuser/.tmux/plugins/tmux-copycat/scripts/copycat_mode_quit.sh; true"
       5 bind-key    -T copy-mode    TripleClick1Pane       run-shell "tmux     select-pane \\; send-keys -X select-line \\; run-shell -d 0.3 \\; send-keys -X copy-pipe-and-cancel; /home/myuser/.tmux/plugins/tmux-copycat/scripts/copycat_mode_quit.sh; true"
       6 bind-key    -T copy-mode    M-w                    run-shell "tmux     send-keys -X copy-pipe-and-cancel; /home/myuser/.tmux/plugins/tmux-copycat/scripts/copycat_mode_quit.sh; true"
       7 bind-key    -T copy-mode-vi C-j                    send-keys -X copy-pipe-and-cancel
       8 bind-key    -T copy-mode-vi Enter                  send-keys -X copy-pipe-and-cancel
       9 bind-key    -T copy-mode-vi D                      send-keys -X copy-pipe-end-of-line-and-cancel
      10 bind-key    -T copy-mode-vi y                      send-keys -X copy-selection-and-cancel
      11 bind-key    -T copy-mode-vi MouseDragEnd1Pane      send-keys -X copy-pipe-and-cancel
      12 bind-key    -T copy-mode-vi DoubleClick1Pane       select-pane \; send-keys -X select-word \; run-shell -d 0.3 \; send-keys -X copy-pipe-and-cancel
      13 bind-key    -T copy-mode-vi TripleClick1Pane       select-pane \; send-keys -X select-line \; run-shell -d 0.3 \; send-keys -X copy-pipe-and-cancel
      14 bind-key    -T prefix       C-c                    new-session
      15 bind-key    -T prefix       \"                     split-window -c '#{pane_current_path}'
      16 bind-key    -T prefix       \%                     split-window -c '#{pane_current_path}' -h
      17 bind-key    -T prefix       -                      split-window -c '#{pane_current_path}' -v
      18 bind-key    -T prefix       2                      split-window -c '#{pane_current_path}' -v
      19 bind-key    -T prefix       3                      split-window -c '#{pane_current_path}' -h
      20 bind-key    -T prefix       _                      split-window -c '#{pane_current_path}' -h
      21 bind-key    -T prefix       c                      new-window -c '#{pane_current_path}'
      22 bind-key    -T root         MouseDown3Pane         if-shell -F -t = "#{||:#{mouse_any_flag},#{&&:#{pane_in_mode},#{?#{m/r:(copy|view)-mode,#{pane_mode}},0,1}}}" { select-pane -t = ; send-keys -M } { display-menu -T "#[align=centre]#{pane_index} (#{pane_id})" -t = -x M -y M "#{?#{m/r:(copy|view)-mode,#{pane_mode}},Go To Top,}" < { send-keys -X history-top } "#{?#{m/r:(copy|view)-mode,#{pane_mode}},Go To Bottom,}" > { send-keys -X history-bottom } '' "#{?mouse_word,Search For #[underscore]#{=/9/...:mouse_word},}" C-r { if-shell -F "#{?#{m/r:(copy|view)-mode,#{pane_mode}},0,1}" "copy-mode -t=" ; send-keys -X -t = search-backward "#{q:mouse_word}" } "#{?mouse_word,Type #[underscore]#{=/9/...:mouse_word},}" C-y { copy-mode -q ; send-keys -l "#{q:mouse_word}" } "#{?mouse_word,Copy #[underscore]#{=/9/...:mouse_word},}" c { copy-mode -q ; set-buffer "#{q:mouse_word}" } "#{?mouse_line,Copy Line,}" l { copy-mode -q ; set-buffer "#{q:mouse_line}" } '' "#{?mouse_hyperlink,Type #[underscore]#{=/9/...:mouse_hyperlink},}" C-h { copy-mode -q ; send-keys -l "#{q:mouse_hyperlink}" } "#{?mouse_hyperlink,Copy #[underscore]#{=/9/...:mouse_hyperlink},}" h { copy-mode -q ; set-buffer "#{q:mouse_hyperlink}" } '' "Horizontal Split" h { split-window -c '#{pane_current_path}' -h } "Vertical Split" v { split-window -c '#{pane_current_path}' -v } '' "#{?#{>:#{window_panes},1},,-}Swap Up" u { swap-pane -U } "#{?#{>:#{window_panes},1},,-}Swap Down" d { swap-pane -D } "#{?pane_marked_set,,-}Swap Marked" s { swap-pane } '' Kill X { kill-pane } Respawn R { respawn-pane -k } "#{?pane_marked,Unmark,Mark}" m { select-pane -m } "#{?#{>:#{window_panes},1},,-}#{?window_zoomed_flag,Unzoom,Zoom}" z { resize-pane -Z } }
      23 bind-key    -T root         MouseDown3Status       display-menu -T "#[align=centre]#{window_index}:#{window_name}" -t = -x W -y W "#{?#{>:#{session_windows},1},,-}Swap Left" l { swap-window -t :-1 } "#{?#{>:#{session_windows},1},,-}Swap Right" r { swap-window -t :+1 } "#{?pane_marked_set,,-}Swap Marked" s { swap-window } '' Kill X { kill-window } Respawn R { respawn-window -k } "#{?pane_marked,Unmark,Mark}" m { select-pane -m } Rename n { command-prompt -F -I "#W" { rename-window -t "#{window_id}" "%%" } } '' "New After" w { new-window -c '#{pane_current_path}' -a } "New At End" W { new-window -c '#{pane_current_path}' }
      24 bind-key    -T root         MouseDown3StatusLeft   display-menu -T "#[align=centre]#{session_name}" -t = -x M -y W Next n { switch-client -n } Previous p { switch-client -p } '' Renumber N { move-window -r } Rename n { command-prompt -I "#S" { rename-session "%%" } } '' "New Session" s { new-session } "New Window" w { new-window -c '#{pane_current_path}' }
      25 bind-key    -T root         DoubleClick1Pane       select-pane -t = \; if-shell -F "#{||:#{pane_in_mode},#{mouse_any_flag}}" { send-keys -M } { copy-mode -H ; send-keys -X select-word ; run-shell -d 0.3 ; send-keys -X copy-pipe-and-cancel }
      26 bind-key    -T root         TripleClick1Pane       select-pane -t = \; if-shell -F "#{||:#{pane_in_mode},#{mouse_any_flag}}" { send-keys -M } { copy-mode -H ; send-keys -X select-line ; run-shell -d 0.3 ; send-keys -X copy-pipe-and-cancel }
      27 bind-key    -T root         M-MouseDown3Pane       display-menu -T "#[align=centre]#{pane_index} (#{pane_id})" -t = -x M -y M "#{?#{m/r:(copy|view)-mode,#{pane_mode}},Go To Top,}" < { send-keys -X history-top } "#{?#{m/r:(copy|view)-mode,#{pane_mode}},Go To Bottom,}" > { send-keys -X history-bottom } '' "#{?mouse_word,Search For #[underscore]#{=/9/...:mouse_word},}" C-r { if-shell -F "#{?#{m/r:(copy|view)-mode,#{pane_mode}},0,1}" "copy-mode -t=" ; send-keys -X -t = search-backward "#{q:mouse_word}" } "#{?mouse_word,Type #[underscore]#{=/9/...:mouse_word},}" C-y { copy-mode -q ; send-keys -l "#{q:mouse_word}" } "#{?mouse_word,Copy #[underscore]#{=/9/...:mouse_word},}" c { copy-mode -q ; set-buffer "#{q:mouse_word}" } "#{?mouse_line,Copy Line,}" l { copy-mode -q ; set-buffer "#{q:mouse_line}" } '' "#{?mouse_hyperlink,Type #[underscore]#{=/9/...:mouse_hyperlink},}" C-h { copy-mode -q ; send-keys -l "#{q:mouse_hyperlink}" } "#{?mouse_hyperlink,Copy #[underscore]#{=/9/...:mouse_hyperlink},}" h { copy-mode -q ; set-buffer "#{q:mouse_hyperlink}" } '' "Horizontal Split" h { split-window -c '#{pane_current_path}' -h } "Vertical Split" v { split-window -c '#{pane_current_path}' -v } '' "#{?#{>:#{window_panes},1},,-}Swap Up" u { swap-pane -U } "#{?#{>:#{window_panes},1},,-}Swap Down" d { swap-pane -D } "#{?pane_marked_set,,-}Swap Marked" s { swap-pane } '' Kill X { kill-pane } Respawn R { respawn-pane -k } "#{?pane_marked,Unmark,Mark}" m { select-pane -m } "#{?#{>:#{window_panes},1},,-}#{?window_zoomed_flag,Unzoom,Zoom}" z { resize-pane -Z }
      28 bind-key    -T root         M-MouseDown3Status     display-menu -T "#[align=centre]#{window_index}:#{window_name}" -t = -x W -y W "#{?#{>:#{session_windows},1},,-}Swap Left" l { swap-window -t :-1 } "#{?#{>:#{session_windows},1},,-}Swap Right" r { swap-window -t :+1 } "#{?pane_marked_set,,-}Swap Marked" s { swap-window } '' Kill X { kill-window } Respawn R { respawn-window -k } "#{?pane_marked,Unmark,Mark}" m { select-pane -m } Rename n { command-prompt -F -I "#W" { rename-window -t "#{window_id}" "%%" } } '' "New After" w { new-window -c '#{pane_current_path}' -a } "New At End" W { new-window -c '#{pane_current_path}' }
      29 bind-key    -T root         M-MouseDown3StatusLeft display-menu -T "#[align=centre]#{session_name}" -t = -x M -y W Next n { switch-client -n } Previous p { switch-client -p } '' Renumber N { move-window -r } Rename n { command-prompt -I "#S" { rename-session "%%" } } '' "New Session" s { new-session } "New Window" w { new-window -c '#{pane_current_path}' }
  4. I ran tmux -vvv -- looking through the (huge) log files, but could not find anything related to this failure. The only failure was the client failing to connect to the server while it was getting itself set up.

Versions

@gpakosz
Copy link
Owner

gpakosz commented May 17, 2024

Hello @Nicholas-Autio-Mitchell,

While in a tmux pane, can you execute this command?

$ tmux lsk | grep -E 'prefix\s+e\s+'

Can you also try to set EDITOR to only emacs?

@Nicholas-Autio-Mitchell
Copy link
Author

Hi @gpakosz , here is the unedited output

 π ▶ tmux lsk | grep -E 'prefix\s+e\s+'
bind-key    -T prefix       e                      new-window -e "EDITOR=emacs -nw --no-splash" -n "#{TMUX_CONF_LOCAL}" sh -c "case \"\\${EDITOR:-vim}\" in *vim) \\${EDITOR:-vim} -c \":set syntax=tmux\" \"\\$TMUX_CONF_LOCAL\";; *) \"\\$EDITOR\" \"\\$TMUX_CONF_LOCAL\";; esac && \"\\$TMUX_PROGRAM\" \\${TMUX_SOCKET:+-S \"\\$TMUX_SOCKET\"} source \"\\$TMUX_CONF\" \\; display \"\\$TMUX_CONF_LOCAL sourced\""

Here is me trying EDITOR=emacs:

 π ▶ echo $EDITOR
emacs -nw --no-splash
 π ▶ EDITOR="emacs"
 π ▶ echo $EDITOR
emacs
 π ▶ tmux lsk | grep -E 'prefix\s+e\s+'
bind-key    -T prefix       e                      new-window -e "EDITOR=emacs -nw --no-splash" -n "#{TMUX_CONF_LOCAL}" sh -c "case \"\\${EDITOR:-vim}\" in *vim) \\${EDITOR:-vim} -c \":set syntax=tmux\" \"\\$TMUX_CONF_LOCAL\";; *) \"\\$EDITOR\" \"\\$TMUX_CONF_LOCAL\";; esac && \"\\$TMUX_PROGRAM\" \\${TMUX_SOCKET:+-S \"\\$TMUX_SOCKET\"} source \"\\$TMUX_CONF\" \\; display \"\\$TMUX_CONF_LOCAL sourced\""

Executing <prefix> e still has no effect.

@Nicholas-Autio-Mitchell
Copy link
Author

Nicholas-Autio-Mitchell commented May 17, 2024

I notice in the output of tmux lsk | grep -E 'prefix\s+e\s+' above, after changing to EDITOR=emacs, the command still uses emacs -nw --no-splash. I have killed/restarted the tmux server, and also edited by ~/.bashrc to ensure the change to EDITOR is already there in the new session, but it still records the original EDITOR value.

Ok, realised tmux takes the value of EDITOR from the parent shell, before tmux itself starts up. 🤦 Made the correct change, and it seems to have fixed the issue! 🎉

Just trying a few more things to make sure it is the case...

@Nicholas-Autio-Mitchell
Copy link
Author

It seems adding any argument at all the emacs command in EDITOR causes the issue. Could it be a problem with escaping the command when tmux reads it?

@Nicholas-Autio-Mitchell
Copy link
Author

I tried wrapping emacs -nw --no-splash inside a function emacs_fn and set EDITOR=emacs_fn. It still doesn't work, so not likely an issue with escaping the command etc.

Additionally, I have had EDITOR=emacs -nw --no-splash set for years... I also didn't pull any updates from oh my tmux recently, so perhaps it is coming from elsewhere. My only guess is an emacs or emacs dependency update, but couldn't find a possible reason after a quick search now. Unless you have more ideas, I will assume it isn't an issue to resolve here.

As always, thanks for your help @gpakosz !

@gpakosz
Copy link
Owner

gpakosz commented May 17, 2024

Can you please try setting EDITOR='emacs -nw --no-splash' again with the gh-744 branch?

This implies quitting tmux etc like you noticed above

@Nicholas-Autio-Mitchell
Copy link
Author

The changes to quotes when reading the $EDITOR env var (made in gh-744) do fix the issue.

I had an older config on a different machine, where I still used EDITOR='emacs -nw --no-splash', so could compare three versions. Here is a summary:

# Works: an old tmux.conf (unknown commit)
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"'

# Fails: current master
bind e new-window -n "#{TMUX_CONF_LOCAL}" -e "EDITOR=$EDITOR" sh -c 'case "${EDITOR:-vim}" in *vim) ${EDITOR:-vim} -c ":set syntax=tmux" "$TMUX_CONF_LOCAL";; *) "$EDITOR" "$TMUX_CONF_LOCAL";; esac && "$TMUX_PROGRAM" ${TMUX_SOCKET:+-S "$TMUX_SOCKET"} source "$TMUX_CONF" \; display "$TMUX_CONF_LOCAL sourced"'

# Works: gh-744
bind e new-window -n "#{TMUX_CONF_LOCAL}" -e EDITOR="$EDITOR" sh -c 'case "${EDITOR:-vim}" in *vim) ${EDITOR:-vim} -c ":set syntax=tmux" "$TMUX_CONF_LOCAL";; *) $EDITOR "$TMUX_CONF_LOCAL";; esac && "$TMUX_PROGRAM" ${TMUX_SOCKET:+-S "$TMUX_SOCKET"} source "$TMUX_CONF" \; display "$TMUX_CONF_LOCAL sourced"'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants