tmuxp
tmuxp copied to clipboard
`tmuxp edit`: EDITOR variable can't have arguments
Step 1: Provide a summary of your problem
tmuxp edit [session-name]
crashes if the EDITOR
environment variable has arguments (i.e. spaces in the string are not considered).
Step 2: Provide tmuxp details
$ echo "$EDITOR"
subl --new-window --wait
$ tmuxp debug-info
-------------------------
environment:
dist: macOS-12.5.1-arm64-arm-64bit
arch: arm64
uname: Darwin; JP-MBP-2022.local; 21.6.0
version: Darwin Kernel Version 21.6.0: Wed Aug 10 14:28:23 PDT 2022; root:xnu-8020.141.5~2/RELEASE_ARM64_T6000
-------------------------
python version: 3.10.5 (v3.10.5:f377153967, Jun 6 2022, 12:36:10) [Clang 13.0.0 (clang-1300.0.29.30)]
system PATH: /usr/local/bin:/opt/homebrew/bin:/Library/TeX/texbin:/Library/Developer/CommandLineTools/usr/bin:/usr/bin:/bin:/usr/local/sbin:/opt/homebrew/sbin:/usr/sbin:/sbin
tmux version: 3.3
libtmux version: 0.14.2
tmuxp version: 1.13.1
tmux path: /opt/homebrew/bin/tmux
tmuxp path: /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/tmuxp
shell: /opt/homebrew/bin/bash
-------------------------
tmux sessions:
main: 3 windows (created Sat Aug 27 09:33:49 2022) (attached)
tmux windows:
1: wip* (3 panes) [213x62] [layout 4b7a,213x62,0,0{80x62,0,0,1,132x62,81,0[132x31,81,0,2,132x30,81,32,3]}] @1 (active)
2: repos (4 panes) [213x62] [layout a0c1,213x62,0,0[213x30,0,0{106x30,0,0,4,106x30,107,0,5},213x31,0,31{106x31,0,31,6,106x31,107,31,7}]] @2
3: scratch- (2 panes) [213x62] [layout 4659,213x62,0,0{106x62,0,0,8,106x62,107,0,9}] @3
tmux panes:
1: [80x61] [history 0/50000, 6152 bytes] %1
2: [132x30] [history 0/50000, 1125 bytes] %2 (active)
3: [132x30] [history 0/50000, 1125 bytes] %3
tmux global options:
activity-action other
assume-paste-time 1
base-index 1
bell-action any
default-command ''
default-shell /opt/homebrew/bin/bash
default-size 80x24
destroy-unattached off
detach-on-destroy on
display-panes-active-colour cyan
display-panes-colour brightblack
display-panes-time 2000
display-time 2000
history-limit 50000
key-table root
lock-after-time 0
lock-command "lock -np"
message-command-style bg=brightblack,fg=cyan
message-style bg=brightblack,fg=cyan
mouse on
prefix C-b
prefix2 None
renumber-windows on
repeat-time 1500
set-titles on
set-titles-string "[#{session_name}] #{window_index}.#{pane_index} (#{window_name})"
silence-action other
status on
status-bg default
status-fg default
status-format[0] "#[align=left range=left #{E:status-left-style}]#[push-default]#{T;=/#{status-left-length}:status-left}#[pop-default]#[norange default]#[list=on align=#{status-justify}]#[list=left-marker]<#[list=right-marker]>#[list=on]#{W:#[range=window|#{window_index} #{E:window-status-style}#{?#{&&:#{window_last_flag},#{!=:#{E:window-status-last-style},default}}, #{E:window-status-last-style},}#{?#{&&:#{window_bell_flag},#{!=:#{E:window-status-bell-style},default}}, #{E:window-status-bell-style},#{?#{&&:#{||:#{window_activity_flag},#{window_silence_flag}},#{!=:#{E:window-status-activity-style},default}}, #{E:window-status-activity-style},}}]#[push-default]#{T:window-status-format}#[pop-default]#[norange default]#{?window_end_flag,,#{window-status-separator}},#[range=window|#{window_index} list=focus #{?#{!=:#{E:window-status-current-style},default},#{E:window-status-current-style},#{E:window-status-style}}#{?#{&&:#{window_last_flag},#{!=:#{E:window-status-last-style},default}}, #{E:window-status-last-style},}#{?#{&&:#{window_bell_flag},#{!=:#{E:window-status-bell-style},default}}, #{E:window-status-bell-style},#{?#{&&:#{||:#{window_activity_flag},#{window_silence_flag}},#{!=:#{E:window-status-activity-style},default}}, #{E:window-status-activity-style},}}]#[push-default]#{T:window-status-current-format}#[pop-default]#[norange list=on default]#{?window_end_flag,,#{window-status-separator}}}#[nolist align=right range=right #{E:status-right-style}]#[push-default]#{T;=/#{status-right-length}:status-right}#[pop-default]#[norange default]"
status-format[1] "#[align=centre]#{P:#{?pane_active,#[reverse],}#{pane_index}[#{pane_width}x#{pane_height}]#[default] }"
status-interval 1
status-justify left
status-keys emacs
status-left "#[fg=black]#{?client_prefix,#[bg=green],#[bg=blue]} #{session_name} #[default] "
status-left-length 20
status-left-style default
status-position bottom
status-right " #[bg=brightblack] %F %H:%M #[bg=cyan,fg=black] #{user}@#{host_short} "
status-right-length 80
status-right-style default
status-style bg=black,fg=white
update-environment[0] DISPLAY
update-environment[1] KRB5CCNAME
update-environment[2] SSH_ASKPASS
update-environment[3] SSH_AUTH_SOCK
update-environment[4] SSH_AGENT_PID
update-environment[5] SSH_CONNECTION
update-environment[6] WINDOWID
update-environment[7] XAUTHORITY
visual-activity off
visual-bell off
visual-silence off
word-separators "!\"#$%&'()*+,-./:;<=>?@[\\]^`{|}~"
tmux window options:
cursor-colour none
cursor-style default
aggressive-resize on
allow-passthrough off
allow-rename on
alternate-screen on
automatic-rename on
automatic-rename-format "#{?pane_in_mode,[tmux],#{pane_current_command}}#{?pane_dead,[dead],}"
clock-mode-colour blue
clock-mode-style 24
copy-mode-match-style bg=cyan,fg=black
copy-mode-current-match-style bg=red,fg=white
copy-mode-mark-style bg=blue,fg=black
fill-character ''
main-pane-height 24
main-pane-width 80
mode-keys emacs
mode-style bg=cyan,fg=black
monitor-activity off
monitor-bell on
monitor-silence 0
other-pane-height 0
other-pane-width 0
pane-active-border-style "#{?pane_in_mode,fg=cyan,#{?pane_synchronized,fg=red,fg=blue}}"
pane-base-index 1
pane-border-format " #{window_index}.#{pane_index} #{s|^/Users/jp/*|~/:pane_current_path}#{?pane_active,#(gitmux -cfg /Users/jp/.config/tmux/gitmux.conf \"#{pane_current_path}\"),} "
pane-border-indicators colour
pane-border-lines single
pane-border-status top
pane-border-style "#{?pane_in_mode,fg=brightblack,#{?pane_synchronized,fg=red,fg=brightblack}}"
pane-colours
popup-style default
popup-border-style default
popup-border-lines single
remain-on-exit off
remain-on-exit-format "Pane is dead (#{?#{!=:#{pane_dead_status},},status #{pane_dead_status},}#{?#{!=:#{pane_dead_signal},},signal #{pane_dead_signal},}, #{t:pane_dead_time})"
scroll-on-clear on
synchronize-panes off
window-active-style default
window-size latest
window-style default
window-status-activity-style bg=blue,fg=black
window-status-bell-style bg=red,fg=white
window-status-current-format " #{window_index}#{window_flags} #{window_name} "
window-status-current-style bg=cyan,fg=black
window-status-format " #{window_index}#{window_flags} #{window_name} "
window-status-last-style fg=cyan
window-status-separator ''
window-status-style bg=brightblack
wrap-search on
xterm-keys on
Step 3: Describe the problem:
Steps to reproduce:
-
tmuxp edit main
Observed Results:
Traceback (most recent call last):
File "/usr/local/bin/tmuxp", line 8, in <module>
sys.exit(cli.cli())
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
return self.main(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/click/core.py", line 1055, in main
rv = self.invoke(ctx)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/click/core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/tmuxp/cli/edit.py", line 15, in command_edit
subprocess.call([sys_editor, config])
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/subprocess.py", line 345, in call
with Popen(*popenargs, **kwargs) as p:
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/subprocess.py", line 969, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/subprocess.py", line 1845, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'subl --new-window --wait'
Expected Results:
The configuration file should be opened by the editor specified in the EDITOR
environment variable.
Relevant Code:
The issue is fixed by changing lines 14 and 15 of tmuxp/cli/edit.py
to:
sys_editor = os.environ.get("EDITOR", "vim").split()
subprocess.call(sys_editor + [config])
Is there a standard / specification behind EDITOR
where we can see if it's normal or not for it to accept arguments?
This looks fine to me by the way, but would like to be apprised of the best practices.
A crumb I Found: https://unix.stackexchange.com/q/77089/18873, https://unix.stackexchange.com/q/4859/18873
I'm not sure about a standard, but have come across numerous .bashrc
s where EDITOR
was exported with arguments, and I've done so for many years without prior issue. The accepted answer at https://stackoverflow.com/a/60461932 mentions "...since an EDITOR
or VISUAL
setting can include command arguments, so supporting word splitting is required."
Is there any update on this?