@@ -399,6 +399,7 @@ def load_workspace(
399399 config_file ,
400400 socket_name = None ,
401401 socket_path = None ,
402+ new_session_name = None ,
402403 colors = None ,
403404 detached = False ,
404405 answer_yes = False ,
@@ -414,6 +415,8 @@ def load_workspace(
414415 ``tmux -L <socket-name>``
415416 socket_path: str, optional
416417 ``tmux -S <socket-path>``
418+ new_session_name: str, options
419+ ``tmux new -s <new_session_name>``
417420 colors : str, optional
418421 '-2'
419422 Force tmux to support 256 colors
@@ -498,6 +501,9 @@ def load_workspace(
498501 sconfig = sconfig .import_config (config_file ).get ()
499502 # shapes configurations relative to config / profile file location
500503 sconfig = config .expand (sconfig , os .path .dirname (config_file ))
504+ # Overwrite session name
505+ if new_session_name :
506+ sconfig ['session_name' ] = new_session_name
501507 # propagate config inheritance (e.g. session -> window, window -> pane)
502508 sconfig = config .trickle (sconfig )
503509
@@ -746,6 +752,7 @@ def command_freeze(session_name, socket_name, socket_path):
746752@click .argument ('config' , type = ConfigPath (exists = True ), nargs = - 1 )
747753@click .option ('-S' , 'socket_path' , help = 'pass-through for tmux -S' )
748754@click .option ('-L' , 'socket_name' , help = 'pass-through for tmux -L' )
755+ @click .option ('-s' , 'new_session_name' , help = 'start new session with new session name' )
749756@click .option ('--yes' , '-y' , 'answer_yes' , help = 'yes' , is_flag = True )
750757@click .option (
751758 '-d' , 'detached' , help = 'Load the session without attaching it' , is_flag = True
@@ -763,7 +770,16 @@ def command_freeze(session_name, socket_name, socket_path):
763770 flag_value = 88 ,
764771 help = 'Like -2, but indicates that the terminal supports 88 colours.' ,
765772)
766- def command_load (ctx , config , socket_name , socket_path , answer_yes , detached , colors ):
773+ def command_load (
774+ ctx ,
775+ config ,
776+ socket_name ,
777+ socket_path ,
778+ new_session_name ,
779+ answer_yes ,
780+ detached ,
781+ colors ,
782+ ):
767783 """Load a tmux workspace from each CONFIG.
768784
769785 CONFIG is a specifier for a configuration file.
@@ -791,6 +807,7 @@ def command_load(ctx, config, socket_name, socket_path, answer_yes, detached, co
791807 tmux_options = {
792808 'socket_name' : socket_name ,
793809 'socket_path' : socket_path ,
810+ 'new_session_name' : new_session_name ,
794811 'answer_yes' : answer_yes ,
795812 'colors' : colors ,
796813 'detached' : detached ,
@@ -809,7 +826,7 @@ def command_load(ctx, config, socket_name, socket_path, answer_yes, detached, co
809826 # Load each configuration but the last to the background
810827 for cfg in config [:- 1 ]:
811828 opt = tmux_options .copy ()
812- opt .update ({'detached' : True })
829+ opt .update ({'detached' : True , 'new_session_name' : None })
813830 load_workspace (cfg , ** opt )
814831
815832 # todo: obey the -d in the cli args only if user specifies
0 commit comments