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

Make tmuxomatic run on tmux >= 2.5 and phyton 3. Correct pane resize on tmux >= 2.6 #26

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
24 changes: 21 additions & 3 deletions tmuxomatic
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,18 @@ def signal_handler_hup( signal_number, frame ):
_ = repr(signal_number) + repr(frame) # Satisfies pylint
raise KeyboardInterrupt

def support_quiet_option(version):
return float(version) < 2.5

def new_session_dimensions_args(tmux_version, user_w, user_h):
if float(tmux_version) <= 2.5:
return '' # Tmux 2.5 use user screen as default windowsize
if float(tmux_version) < 2.8:
return "-x " + str(user_w) + " -y " + str(user_h) # Tmux 2.6 use 80x24 window for detached sessions

return "-x - -y -" # tmux 2.8 add '-' argument to use users screen as default window size


def satisfies_minimum_version(minimum, version):
"""
Asserts compliance by tmux version. I've since seen a similar version check somewhere that may come with Python
Expand Down Expand Up @@ -774,8 +786,12 @@ class SessionFile(object):
self.Load_Shorthand_SharedCore( bol )
def Load(self):
# Load raw data
if sys.version_info < (3, ):
mode = "rU"
else: # python 3 deprecates mode "U" in favor of "newline" option
mode = "r"
rawfile = ""
f = open(self.filename, "rU")
f = open(self.filename, mode)
while True:
line = f.readline()
if not line: break # EOF
Expand Down Expand Up @@ -2085,12 +2101,14 @@ def tmuxomatic( program_cli, full_cli, user_wh, session_name, session, active_se
# The shell's cwd must be set, the only other way to do this is to discard the
# window that is automatically created when calling "new-session".
cwd_execution = ("cd " + list_panes_dir) if list_panes_dir else ""
list_build.append( "new-session -d -s " + session_name + " -n \"" + window_name + "\"" )
list_build.append( "new-session -d -s " + session_name + " -n \"" + window_name + "\" " + new_session_dimensions_args(USERS_TMUX, user_wh[0], user_wh[1]) )
# Normally, tmux automatically renames windows based on whatever is running in the focused pane.
# There are two ways to fix this. 1) Add "set-option -g allow-rename off" to your ".tmux.conf".
# 2) Add "export DISABLE_AUTO_TITLE=true" to your shell's run commands file (e.g., ".bashrc").
# Here we automatically do method 1 for the user, unless the user requests otherwise.
list_build.append( "set-option -t " + session_name + " quiet on" )

if support_quiet_option(USERS_TMUX):
list_build.append( "set-option -t " + session_name + " quiet on" )
renaming = [ "off", "on" ][ARGS.renaming]
list_build.append( "set-option -t " + session_name + " allow-rename " + renaming )
list_build.append( "set-option -t " + session_name + " automatic-rename " + renaming )
Expand Down