Skip to content

Add support for renaming session during load #208

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

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions tmuxp/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def resolve_config(config, config_dir=None):


def load_workspace(
config_file, socket_name=None, socket_path=None, colors=None,
config_file, session_name=None, socket_name=None, socket_path=None, colors=None,
attached=None, detached=None, answer_yes=False
):
"""Build config workspace.
Expand Down Expand Up @@ -243,7 +243,13 @@ def reattach(session):
else:
session.attach_session()

session_name = sconfig['session_name']
if session_name is None:
# get existing session name from config
session_name = sconfig['session_name']
else:
# use the new session name
sconfig['session_name'] = session_name

if builder.session_exists(session_name):
if not detached and (
answer_yes or click.confirm(
Expand Down Expand Up @@ -446,6 +452,7 @@ def command_freeze(session_name, socket_name, socket_path):
@click.pass_context
@click.argument('config', click.Path(exists=True), nargs=-1,
callback=resolve_config_argument)
@click.option('-s', 'session_name', help='pass-through for tmux -s')
@click.option('-S', 'socket_path', help='pass-through for tmux -L')
@click.option('-L', 'socket_name', help='pass-through for tmux -L')
@click.option('--yes', '-y', 'answer_yes', help='yes', is_flag=True)
Expand All @@ -457,7 +464,7 @@ def command_freeze(session_name, socket_name, socket_path):
@click.option(
'-8', 'colors', flag_value=88,
help='Like -2, but indicates that the terminal supports 88 colours.')
def command_load(ctx, config, socket_name, socket_path, answer_yes,
def command_load(ctx, config, session_name, socket_name, socket_path, answer_yes,
detached, colors):
"""Load a tmux workspace from each CONFIG.

Expand All @@ -484,6 +491,7 @@ def command_load(ctx, config, socket_name, socket_path, answer_yes,
util.oh_my_zsh_auto_title()

tmux_options = {
'session_name': session_name,
'socket_name': socket_name,
'socket_path': socket_path,
'answer_yes': answer_yes,
Expand Down