tmux-python / tmux-python/tmuxp

passing options to tmux command: libtmux.exc.UnknownOption

Open
#867 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
4.6k
Forks
248
Avg merge
2h 13m
Merged PRs (30d)
1

Description

Step 1: Provide a summary of your problem

I thought we could specify tmux options like tmux -L socketname -f .config/custom.conf by doing something like:

session_name: name-of-session
options:
 ' -L': socketname
  '-f': .config/custom.conf

…but either I'm mistaken about that or doing it wrong.

Step 2: Provide tmuxp details

Output of tmuxp debug-info:

-------------------------
environment:
	dist: Linux-5.19.0-76051900-generic-x86_64-with-glibc2.35
	arch: x86_64
	uname: Linux; pop-os; 5.19.0-76051900-generic
	version: #202207312230~1660780566~22.04~9d60db1 SMP PREEMPT_DYNAMIC Thu A
-------------------------
python version: 3.10.6 (main, Nov  2 2022, 18:53:38) [GCC 11.3.0]
system PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/m/.local/bin:/home/m/code/bin:/usr/local/go/bin:/home/m/.local/lib/go/bin:/home/m/.local/lib/lua/bin:/home/m/code/software_projects/luarocks-3.8.0/lua_modules/bin:/home/m/.local/lib/rust/cargo/bin
tmux version: 3.2
libtmux version: 0.14.2
tmuxp version: 1.13.1
tmux path: /usr/bin/tmux
tmuxp path: /home/m/.local/lib/python3.10/site-packages/tmuxp
shell: /usr/bin/zsh
-------------------------
tmux sessions:
	Diary: 2 windows (created Fri Feb 10 20:52:46 2023)
	Email: 1 windows (created Fri Feb 10 20:52:46 2023) (attached)
	PM: 1 windows (created Fri Feb 10 20:52:47 2023)
	Projects: 4 windows (created Fri Feb 10 20:52:48 2023) (attached)
	docs: 1 windows (created Fri Feb 10 20:52:46 2023) (attached)
	lrn_parsing-text-files_python: 1 windows (created Sat Feb 11 18:19:15 2023)

tmux windows:
	0: docs* (1 panes) [83x51] [layout ade2,83x51,0,0,5] @3 (active)

tmux panes:
	0: [83x50] [history 0/2000, 22863 bytes] %5 (active)

tmux global options:
	@plugin tmux-plugins/vim-tmux-focus-events
	activity-action other
	assume-paste-time 1
	base-index 0
	bell-action any
	default-command ''
	default-shell /usr/bin/zsh
	default-size 80x24
	destroy-unattached off
	detach-on-destroy on
	display-panes-active-colour red
	display-panes-colour blue
	display-panes-time 1000
	display-time 750
	history-limit 2000
	key-table root
	lock-after-time 0
	lock-command "lock -np"
	message-command-style bg=black,fg=yellow
	message-style bg=yellow,fg=black
	mouse on
	prefix C-a
	prefix2 None
	renumber-windows off
	repeat-time 500
	set-titles off
	set-titles-string "#S:#I:#W - \"#T\" #{session_alerts}"
	silence-action other
	status on
	status-bg colour234
	status-fg colour137
	status-format[0] "#[align=left range=left #{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} #{window-status-style}#{?#{&&:#{window_last_flag},#{!=:#{window-status-last-style},default}}, #{window-status-last-style},}#{?#{&&:#{window_bell_flag},#{!=:#{window-status-bell-style},default}}, #{window-status-bell-style},#{?#{&&:#{||:#{window_activity_flag},#{window_silence_flag}},#{!=:#{window-status-activity-style},default}}, #{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 #{?#{!=:#{window-status-current-style},default},#{window-status-current-style},#{window-status-style}}#{?#{&&:#{window_last_flag},#{!=:#{window-status-last-style},default}}, #{window-status-last-style},}#{?#{&&:#{window_bell_flag},#{!=:#{window-status-bell-style},default}}, #{window-status-bell-style},#{?#{&&:#{||:#{window_activity_flag},#{window_silence_flag}},#{!=:#{window-status-activity-style},default}}, #{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 #{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 15
	status-justify left
	status-keys vi
	status-left "#[fg=white,bg=black] Do Ctrl+S to save and run the script"
	status-left-length 40
	status-left-style default
	status-position bottom
	status-right "#[fg=colour233,bg=colour241,bold]#(grep 'Course_Name: ' .lesson.yml | sed 's/Course_Name:/ /') #[fg=colour233,bg=colour245,bold]#(grep TODO .lesson.yml | head -n 1 | grep -oe '[0-9]*' | sed 's/^/ Step /') "
	status-right-length 95
	status-right-style default
	status-style bg=green,fg=black
	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:
	aggressive-resize off
	allow-rename off
	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=magenta,fg=black
	copy-mode-mark-style bg=red,fg=black
	main-pane-height 24
	main-pane-width 80
	mode-keys vi
	mode-style bg=yellow,fg=black
	monitor-activity off
	monitor-bell on
	monitor-silence 0
	other-pane-height 0
	other-pane-width 0
	pane-active-border-style "bg=colour236 fg=colour245"
	pane-base-index 0
	pane-border-format " [#{pane_index}] #{pane_title} "
	pane-border-lines single
	pane-border-status top
	pane-border-style "bg=default fg=colour239"
	remain-on-exit off
	synchronize-panes off
	window-active-style fg=colour15,bg=colour235
	window-size latest
	window-style fg=colour245,bg=colour236
	window-status-activity-style reverse
	window-status-bell-style reverse
	window-status-current-format ''
	window-status-current-style default
	window-status-format ''
	window-status-last-style default
	window-status-separator " "
	window-status-style default
	wrap-search on
	xterm-keys on
Step 3: Describe the problem:

Options do not get passed to tmux command. Error is produced instead.

Steps to reproduce:

Use the config:

session_name: name-of-session
options:
  -L: socketname
  -f: .config/custom.conf
Observed Results:
❯ tmuxp load .
[Loading] /home/m/code/lrn/parsing_text_files__python/.tmuxp.yaml
[step-1 39c8f8f] Update instructions for step 1.
 1 file changed, 3 deletions(-)
Traceback (most recent call last):
  File "/home/m/.local/bin/tmuxp", line 8, in <module>
    sys.exit(cli.cli())
  File "/home/m/.local/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/home/m/.local/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/home/m/.local/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/m/.local/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/m/.local/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/m/.local/lib/python3.10/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/m/.local/lib/python3.10/site-packages/tmuxp/cli/load.py", line 573, in command_load
    load_workspace(config[-1], **tmux_options)
  File "/home/m/.local/lib/python3.10/site-packages/tmuxp/cli/load.py", line 418, in load_workspace
    _load_attached(builder, detached)
  File "/home/m/.local/lib/python3.10/site-packages/tmuxp/cli/load.py", line 159, in _load_attached
    builder.build()
  File "/home/m/.local/lib/python3.10/site-packages/tmuxp/workspacebuilder.py", line 253, in build
    self.session.set_option(option, value)
  File "/home/m/.local/lib/python3.10/site-packages/libtmux/session.py", line 451, in set_option
    handle_option_error(proc.stderr[0])
  File "/home/m/.local/lib/python3.10/site-packages/libtmux/common.py", line 750, in handle_option_error
    raise exc.UnknownOption(error)
libtmux.exc.UnknownOption: tmux: unknown option -- f
↵ Error. Exit status 1.   
Expected Results:

I thought options: would be provided as options to the tmux command.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Trace option handling from tmuxp/cli/load.py through workspacebuilder.py and libtmux/session.py, starting with how the YAML options mapping is passed to tmux. Confirm whether command-level flags such as -L and -f can be represented without treating them as session options, then add coverage for the configuration shown and verify that tmux receives both flags before loading the workspace.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, yaml
Domain
cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.