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

passing options to tmux command: libtmux.exc.UnknownOption #867

Open
m-faith opened this issue Feb 12, 2023 · 4 comments
Open

passing options to tmux command: libtmux.exc.UnknownOption #867

m-faith opened this issue Feb 12, 2023 · 4 comments

Comments

@m-faith
Copy link

m-faith commented Feb 12, 2023

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.

@m-faith
Copy link
Author

m-faith commented Feb 12, 2023

tmuxinator allows for passing options to tmux like this:

tmux_options: -L lrn -f .config/tmux.conf

I just tried that with tmuxp.

No errors, and it launches the tmux session. BUT...

tmux -L lrn ls yields error connecting to /tmp/tmux-1000/lrn (No such file or directory) and /tmp/tmux-100/default appears to still be the only socket/server/thing running. Whereas if I run the command tmux -L lrn new-session then /tmp/tmux-1000/lrn gets created.

@m-faith
Copy link
Author

m-faith commented Feb 12, 2023

Oh, tmuxinator has socket_name: lrn for doing tmux -L lrn .... Socket name gets its own thing rather than using the tmux_options: for the socket option. But that's tmuxinator. How does Tmuxp handle this?

@m-faith
Copy link
Author

m-faith commented Feb 12, 2023

Thought I found the solution at https://tmuxp.git-pull.com/about.html which at the bottom under Minor tweaks heaeding says:

$ tmuxp -L, $ tmuxp -S for sockets and $ tmuxp -f for config file.

But no, neither:

  • tmuxp -S /tmp/tmux-1000/lrn load .
  • tmuxp -L lrn load .

...neither works. I tried both with and without the space following the -S/-L. Either way it errors:

Usage: tmuxp [OPTIONS] COMMAND [ARGS]...
Try 'tmuxp -h' for help.

Error: No such option: -S
↵ Error. Exit status 2.

@m-faith
Copy link
Author

m-faith commented Feb 12, 2023

❯ tmuxp -V
tmuxp 1.13.1, libtmux 0.14.2
❯ tmux -V
tmux 3.2a

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

1 participant