Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

tmux and XDG_CONFIG_HOME #654

Answered by tony
jfindlay asked this question in Q&A
Discussion options

Is it possible for tmuxp to work with a tmux config in a "nonstandard" location? I like to keep my configs in XDG_CONFIG_HOME, which tmux does not seem to support (srsly). Aliasing tmux to tmux -f $XDG_CONFIG_HOME/tmux/config in the shell means that tmuxp does not read the tmux config. Also, creating a wrapper script called tmux that basically does the same thing as the alias,

#!/bin/bash
tmux -f "${XDG_CONFIG_HOME}"/tmux/config "${@}"

causes tmuxp to infinitely recurse tmux subprocesses, whereas tmux itself works fine with this mechanism.

I spent about 15 minutes reading through the source code and I couldn't find where to make any changes for this issue/feature. With a suggestion, I am willing to implement this myself.

You must be logged in to vote

@jfindlay This is a really good catch. As of 1.6 / 1.7 master:

  • tmuxp commands (e.g. tmuxp load) don't pass through the -f (tmux config file) to tmux. tmuxp already passes through -2 (256 colors), -8, -L (socket_name), -S (socket_path) to tmux

I spent about 15 minutes reading through the source code and I couldn't find where to make any changes for this issue/feature. With a suggestion, I am willing to implement this myself.

We'd do it in cli.py in command_load (CLI entrypoint) and load_workspace.

We can accept an -f / --file as an arg. We'd need to do this at t = Server so the libtmux client used refers to the tmux config file:

tmuxp/tmuxp/cli.py

Lines 918 to 950 in 0d6a0eb

@

Replies: 1 comment 8 replies

Comment options

@jfindlay This is a really good catch. As of 1.6 / 1.7 master:

  • tmuxp commands (e.g. tmuxp load) don't pass through the -f (tmux config file) to tmux. tmuxp already passes through -2 (256 colors), -8, -L (socket_name), -S (socket_path) to tmux

I spent about 15 minutes reading through the source code and I couldn't find where to make any changes for this issue/feature. With a suggestion, I am willing to implement this myself.

We'd do it in cli.py in command_load (CLI entrypoint) and load_workspace.

We can accept an -f / --file as an arg. We'd need to do this at t = Server so the libtmux client used refers to the tmux config file:

tmuxp/tmuxp/cli.py

Lines 918 to 950 in 0d6a0eb

@click.argument('config', type=ConfigPath(exists=True), nargs=-1)
@click.option('-S', 'socket_path', help='pass-through for tmux -S')
@click.option('-L', 'socket_name', help='pass-through for tmux -L')
@click.option('-s', 'new_session_name', help='start new session with new session name')
@click.option('--yes', '-y', 'answer_yes', help='yes', is_flag=True)
@click.option(
'-d', 'detached', help='Load the session without attaching it', is_flag=True
)
@click.option(
'colors',
'-2',
flag_value=256,
default=True,
help='Force tmux to assume the terminal supports 256 colours.',
)
@click.option(
'colors',
'-8',
flag_value=88,
help='Like -2, but indicates that the terminal supports 88 colours.',
)
@click.option('--log-file', help='File to log errors/output to')
def command_load(
ctx,
config,
socket_name,
socket_path,
new_session_name,
answer_yes,
detached,
colors,
log_file,
):

tmuxp/tmuxp/cli.py

Lines 979 to 994 in 0d6a0eb

tmux_options = {
'socket_name': socket_name,
'socket_path': socket_path,
'new_session_name': new_session_name,
'answer_yes': answer_yes,
'colors': colors,
'detached': detached,
}
if not config:
tmuxp_echo("Enter at least one CONFIG")
tmuxp_echo(ctx.get_help(), color=ctx.color)
ctx.exit()
if isinstance(config, string_types):
load_workspace(config, **tmux_options)

tmuxp/tmuxp/cli.py

Lines 575 to 584 in 0d6a0eb

sconfig = config.expand(sconfig, os.path.dirname(config_file))
# Overwrite session name
if new_session_name:
sconfig['session_name'] = new_session_name
# propagate config inheritance (e.g. session -> window, window -> pane)
sconfig = config.trickle(sconfig)
t = Server( # create tmux server object
socket_name=socket_name, socket_path=socket_path, colors=colors
)

The good news is, Server() accepts a config_file: https://github.com/tmux-python/libtmux/blob/6c7c08e718a654f653e0c4388df32e048aa3e445/libtmux/server.py#L79-L94

Do you want to give this a shot @jfindlay? It may be a good first issue

You must be logged in to vote
8 replies
Comment options

Token credit: #665. The real win here though, is getting me to think about tmuxp code which increases the probability I will contribute again in the future.

Comment options

tony Feb 3, 2021
Maintainer

Comment options

tony Feb 4, 2021
Maintainer

The real win here though, is getting me to think about tmuxp code which increases the probability I will contribute again in the future.

And that's good with me!

Comment options

@jfindlay

* https://pypi.python.org/pypi/tmuxp/1.6.5
* https://pypi.python.org/pypi/tmuxp/1.7.1

If you try one of these, how's that?

I have verified the new flag works with both versions.

Comment options

tony Feb 4, 2021
Maintainer

Excellent

Answer selected by jfindlay
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #654 on December 29, 2020 15:05.

AltStyle によって変換されたページ (->オリジナル) /