Skip to content

Commit 621c2c8

Browse files
committed
fix: use | instead of \t for format sepatator
- for some reason on my arch install tmux does not print back tabs I'm not sure if it affects other but just puttin this out there
1 parent fccac42 commit 621c2c8

File tree

4 files changed

+65
-12
lines changed

4 files changed

+65
-12
lines changed

libtmux/formats.py

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
88
"""
99

10+
from __future__ import absolute_import, unicode_literals, with_statement
11+
12+
FORMAT_SEPERATOR = "|"
13+
1014
SESSION_FORMATS = [
1115
'session_name',
1216
'session_windows',

libtmux/server.py

+45-8
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,9 @@ def _list_sessions(self):
142142
sformats = formats.SESSION_FORMATS
143143
tmux_formats = ['#{%s}' % f for f in sformats]
144144

145-
tmux_args = ('-F%s' % '\t'.join(tmux_formats),) # output
145+
tmux_args = (
146+
'-F%s' % formats.FORMAT_SEPERATOR.join(tmux_formats),
147+
) # output
146148

147149
proc = self.cmd('list-sessions', *tmux_args)
148150

@@ -154,7 +156,17 @@ def _list_sessions(self):
154156
sessions = proc.stdout
155157

156158
# combine format keys with values returned from ``tmux list-sessions``
157-
sessions = [dict(zip(sformats, session.split('\t'))) for session in sessions]
159+
sessions = [
160+
dict(
161+
zip(
162+
sformats,
163+
session.split(
164+
formats.FORMAT_SEPERATOR
165+
)
166+
)
167+
)
168+
for session in sessions
169+
]
158170

159171
# clear up empty dict
160172
sessions = [
@@ -207,7 +219,9 @@ def _list_windows(self):
207219
proc = self.cmd(
208220
'list-windows', # ``tmux list-windows``
209221
'-a',
210-
'-F%s' % '\t'.join(tmux_formats), # output
222+
'-F%s' % formats.FORMAT_SEPERATOR.join(
223+
tmux_formats
224+
), # output
211225
)
212226

213227
if proc.stderr:
@@ -218,7 +232,17 @@ def _list_windows(self):
218232
wformats = ['session_name', 'session_id'] + formats.WINDOW_FORMATS
219233

220234
# combine format keys with values returned from ``tmux list-windows``
221-
windows = [dict(zip(wformats, window.split('\t'))) for window in windows]
235+
windows = [
236+
dict(
237+
zip(
238+
wformats,
239+
window.split(
240+
formats.FORMAT_SEPERATOR
241+
)
242+
)
243+
)
244+
for window in windows
245+
]
222246

223247
# clear up empty dict
224248
windows = [dict((k, v) for k, v in window.items() if v) for window in windows]
@@ -267,7 +291,10 @@ def _list_panes(self):
267291
'window_id',
268292
'window_name',
269293
] + formats.PANE_FORMATS
270-
tmux_formats = ['#{%s}\t' % f for f in pformats]
294+
tmux_formats = [
295+
('#{%%s}%s' % formats.FORMAT_SEPERATOR) % f
296+
for f in pformats
297+
]
271298

272299
proc = self.cmd('list-panes', '-a', '-F%s' % ''.join(tmux_formats)) # output
273300

@@ -285,7 +312,17 @@ def _list_panes(self):
285312
] + formats.PANE_FORMATS
286313

287314
# combine format keys with values returned from ``tmux list-panes``
288-
panes = [dict(zip(pformats, window.split('\t'))) for window in panes]
315+
panes = [
316+
dict(
317+
zip(
318+
pformats,
319+
window.split(
320+
formats.FORMAT_SEPERATOR
321+
)
322+
)
323+
)
324+
for window in panes
325+
]
289326

290327
# clear up empty dict
291328
panes = [
@@ -526,7 +563,7 @@ def new_session(
526563
tmux_args = (
527564
'-s%s' % session_name,
528565
'-P',
529-
'-F%s' % '\t'.join(tmux_formats), # output
566+
'-F%s' % formats.FORMAT_SEPERATOR.join(tmux_formats), # output
530567
)
531568

532569
if not attach:
@@ -557,7 +594,7 @@ def new_session(
557594
os.environ['TMUX'] = env
558595

559596
# combine format keys with values returned from ``tmux list-windows``
560-
session = dict(zip(sformats, session.split('\t')))
597+
session = dict(zip(sformats, session.split(formats.FORMAT_SEPERATOR)))
561598

562599
# clear up empty dict
563600
session = dict((k, v) for k, v in session.items() if v)

libtmux/session.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,9 @@ def new_window(
217217
start_directory = os.path.expanduser(start_directory)
218218
window_args += ('-c%s' % start_directory,)
219219

220-
window_args += ('-F"%s"' % '\t'.join(tmux_formats),) # output
220+
window_args += (
221+
'-F"%s"' % formats.FORMAT_SEPERATOR.join(tmux_formats),
222+
) # output
221223
if window_name:
222224
window_args += ('-n%s' % window_name,)
223225

@@ -237,7 +239,14 @@ def new_window(
237239

238240
window = proc.stdout[0]
239241

240-
window = dict(zip(wformats, window.split('\t')))
242+
window = dict(
243+
zip(
244+
wformats,
245+
window.split(
246+
formats.FORMAT_SEPERATOR
247+
)
248+
)
249+
)
241250

242251
# clear up empty dict
243252
window = dict((k, v) for k, v in window.items() if v)

libtmux/window.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,10 @@ def split_window(
434434
'window_index',
435435
'window_id',
436436
] + formats.PANE_FORMATS
437-
tmux_formats = ['#{%s}\t' % f for f in pformats]
437+
tmux_formats = [
438+
('#{%%s}%s' % formats.FORMAT_SEPERATOR) % f
439+
for f in pformats
440+
]
438441

439442
# '-t%s' % self.attached_pane.get('pane_id'),
440443
# 2013-10-18 LOOK AT THIS, rm'd it..
@@ -478,7 +481,7 @@ def split_window(
478481
else:
479482
pane = pane.stdout[0]
480483

481-
pane = dict(zip(pformats, pane.split('\t')))
484+
pane = dict(zip(pformats, pane.split(formats.FORMAT_SEPERATOR)))
482485

483486
# clear up empty dict
484487
pane = dict((k, v) for k, v in pane.items() if v)

0 commit comments

Comments
 (0)