Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1import os lp|features/lp/examples.md
2import sys lp|features/lp/examples.md
3import time lp|features/lp/examples.md
4from functools import partial as p lp|features/lp/examples.md
6from lcdoc import lp lp|features/lp/examples.md
7from lcdoc.tools import write_file lp|features/lp/examples.md
9env = os.environ lp|features/lp/examples.md
10wait = time.sleep lp|features/lp/examples.md
11now = time.time lp|features/lp/examples.md
12exists = lp.exists lp|features/lp/examples.md
13I = lp.I lp|features/lp/examples.md
14L = lp.L lp|features/lp/examples.md
16dbg = lp.dbg lp|features/lp/examples.md
19def init_prompt(n, kw): lp|features/lp/examples.md
20 """run before each command"""
21 # -R reset terminal state:
22 lp.sprun('tmux send-keys -R -t %s:1' % n) lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
23 lp.sprun('tmux clear-history -t %s:1' % n) lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
24 lp.sprun("tmux send-keys -t %s:1 '' Enter" % n) lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
25 t0 = now() lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
26 p = prompt(kw) lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
27 while now() - t0 < 2: 27 ↛ 34line 27 didn't jump to line 34, because the condition on line 27 was never falselp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
28 res = lp.sprun('tmux capture-pane -epJS -1000000 -t %s:1' % n) lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
29 r = res.decode('utf-8').rstrip() lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
30 if r and (r.endswith(p) or r[-1] in {'#', '$'}): 30 ↛ 32line 30 didn't jump to line 32, because the condition on line 30 was never falselp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
31 return lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
32 dbg('waiting for prompt...', have=r, want=p)
33 wait(0.1)
34 raise Exception('No Prompt; Have so far: %s' % r)
37def get_cwd(session_name): lp|features/lp/examples.md
38 res = srun_in_tmux('echo "::$(pwd)::"', session_name=session_name)
39 res = res.rsplit('::')[-2]
40 assert os.path.exists(res)
41 return res
44def get(session_name, **kw): lp|features/lp/examples.md
45 """
46 Starts tmux if not running and delivers a srun_in_tmux function,
47 parametrized for that session.
48 """
49 s = '\n' + os.popen('tmux ls').read() lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
50 if not '\n%s:' % session_name in s: lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
51 create(session_name, kw) lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.md
53 res = p(srun_in_tmux, session_name=session_name) lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
54 return res lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
57# :docs:configure_tmux_base_index_1
58def configure_tmux_base_index_1(session_name): lp|features/lp/examples.md
59 """
60 Seems everybody really using it has 1 (on normal keyboards 0 is far away)
61 and its a hard to detect or change, especially when the messed with it outside of
62 our control.
64 On clean systems it will be just missing or: the user / runner does not care.
66 => Lets create it - when it is NOT present, so that we can have automatic CI/CD.
67 While for a normal user (who is using it) we fail if not configured correctly.
68 """
69 fn = env.get('HOME', '') + '/.tmux.conf'
70 if exists(fn):
71 return
73 lp.app.warning('!!! Writing %s to set base index to 1 !!' % fn)
74 r = [
75 'set-option -g base-index 1',
76 'set-window-option -g pane-base-index 1',
77 '',
78 ]
79 write_file(fn, '\n'.join(r))
80 lp.sprun('tmux source-file "%s"' % fn)
81 wait(0.5)
82 tmux_kill_session(session_name)
83 wait(0.5)
84 tmux_start(session_name)
85 wait(0.5)
88# :docs:configure_tmux_base_index_1
91def prompt(kw): lp|features/lp/examples.md
92 return kw.get('prompt', '$') lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
95def tmux_start(session_name): lp|features/lp/examples.md
96 # path is set new. bash (if executing user's shell is fish we'd be screwed)
97 s = session_name lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.md
98 lp.sprun('export SHELL=/bin/bash; export p="$PATH"; tmux new -s %s -d' % s) lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.md
101def create(session_name, kw): lp|features/lp/examples.md
102 # new session:
103 s = session_name lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.md
104 tmux_start(s) lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.md
105 # all lp vars into the session, maybe of use:
106 lp_env = ['%s="%s"' % (i, env[i]) for i in env if i[:3] in ('LP_', 'lp_')] lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.md
107 lp_env = ' '.join(lp_env) lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.md
108 a = 'tmux send-keys -t %(session)s:1 \'export PATH="$p" PS1="%(prompt)s " ' lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.md
109 a += "%(lp_env)s' Enter" lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.md
111 b = {'prompt': prompt(kw), 'session': s, 'lp_env': lp_env} lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.md
112 for try_nr in (1, 2): 112 ↛ 128line 112 didn't jump to line 128, because the loop on line 112 didn't completelp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.md
113 try: lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.md
114 lp.sprun(a % b) lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.md
115 # the reset in init prompt needs thate time before
116 # otherwise you have the command 2 times in
117 time.sleep(0.2) lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.md
118 break lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.md
119 except Exception as ex:
120 if try_nr == 1:
121 configure_tmux_base_index_1(session_name)
122 continue
124 msg = 'tmux session start failed. Do you have tmux, configured with'
125 msg += 'base index 1? 0 is default but will NOT work!!'
126 raise Exception(msg)
128 init_prompt(s, kw) lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.md
129 if kw.get('root'): 129 ↛ 130line 129 didn't jump to line 130, because the condition on line 129 was never truelp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.md
130 lp.sprun('tmux send-keys -t %s "sudo bash" Enter' % s)
131 wait(0.1)
134def handle_cwd_pre_post(cpp_mode, spec, session_name, timeout=1, **kw): lp|features/lp/examples.md
135 t = {'cwd': 'cd "%s"', 'pre': '%s', 'post': '%s'}[cpp_mode] lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
136 cmd = spec.get(cpp_mode) lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
137 if cmd: lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
138 cmd = t % cmd lp|features/lp/parameters.mdlp|features/lp/parameters.md
139 sn = session_name lp|features/lp/parameters.mdlp|features/lp/parameters.md
140 srun_in_tmux(cmd, session_name=sn, timeout=0.1) lp|features/lp/parameters.mdlp|features/lp/parameters.md
143def srun(cmds, session_name, **kw): lp|features/lp/examples.md
144 S = get(session_name, **kw) lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
145 if kw.get('with_paths'): 145 ↛ 146line 145 didn't jump to line 146, because the condition on line 145 was never truelp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
146 for e in 'PATH', 'PYTHONPATH':
147 S('export %s="%s"' % (e, os.environ.get(e, '')), **kw)
148 h = handle_cwd_pre_post lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
149 [h(k, kw, session_name, **kw) for k in ('cwd', 'pre')] lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
150 res = [{'cmd': cmd, 'res': S(cmd, **kw)} for cmd in lp.to_list(cmds)] lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
151 h('post', kw, session_name, **kw) lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
152 res = [i for i in res if not i.get('res') == 'silent'] # sleeps removed lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
153 if kw.get('kill_session'): lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
154 tmux_kill_session(session_name) lp|features/lp/parameters.md
155 return res lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
158def srun_in_tmux(cmd, session_name, expect=None, timeout=1, **kw): lp|features/lp/examples.md
159 n = session_name lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
161 # TODO: clean up
162 assert_ = None lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
163 silent = kw.get('silent') lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
164 # undocumented
165 wait_after = kw.get('wait_after') lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
167 # c = lp.check_inline_lp(cmd, fn_lp=kw.get('fn_doc'))
168 # if c:
169 # cmd = c
170 do_post = None lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
171 if isinstance(cmd, dict): lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
172 h = handle_cwd_pre_post lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
173 [h(k, cmd, session_name, **kw) for k in ('cwd', 'pre')] lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
174 if 'post' in cmd: lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
175 do_post = p(h, 'post', cmd, session_name, **kw) lp|features/lp/parameters.md
177 timeout = cmd.get('timeout', timeout) lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
178 expect = cmd.get('expect', expect) lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
179 assert_ = cmd.get('asserts') or cmd.get('assert', assert_) lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
180 silent = cmd.get('silent', silent) lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
181 wait_after = cmd.get('wait_after', wait_after) lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
182 cmd = cmd.get('cmd') # if not given: only produce output lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
183 if cmd.startswith('wait '): 183 ↛ 184line 183 didn't jump to line 184, because the condition on line 183 was never truelp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
184 time.sleep(float(cmd.split()[1]))
185 return 'silent'
187 sk = 'send-keys:' lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
188 if cmd.startswith('send-keys:'): lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
189 cmd = cmd.split('#', 1)[0] lp|features/lp/parameters.md
190 lp.spresc('tmux send-keys -t %s:1 %s' % (n, cmd.split(sk, 1)[1].strip())) lp|features/lp/parameters.md
191 # at ci seen delays after C-c:
192 wait(0.1) lp|features/lp/parameters.md
193 return 'silent' lp|features/lp/parameters.md
195 expect_echo_out_cmd = '' lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
196 is_multiline = '\n' in cmd lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
197 if expect is None: lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
198 # we do NOT fail on exit codes, just want to know if the command completed,
199 # by scraping the tmux output for a string:
200 # if you want the first send set -e
201 sep = '\n' if (is_multiline or ' # ' in cmd) else ';' lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
202 # here docs can't have ';echo -n... at last line:
203 # not match on the issuing cmd
204 expect_echo_out_cmd = sep + 'echo -n ax_; echo -n done' lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
205 cmd += expect_echo_out_cmd lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
206 expect = 'ax_done' lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
207 if expect is False: lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
208 expectb = b'des soid ned bassian - we want timeout' lp|features/lp/parameters.md
209 else:
210 expectb = expect.encode('utf-8') lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
211 if cmd: 211 ↛ 228line 211 didn't jump to line 228, because the condition on line 211 was never falselp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
212 init_prompt(n, kw) lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
213 # send the sequence as hex (-H):
214 seq = ' '.join([hex(ord(b))[2:] for b in cmd]) lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
215 seq += ' a' lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
216 # if is_multiline:
217 # breakpoint() # FIXME BREAKPOINT
218 # for line in cmd.splitlines():
219 # spresc("tmux send-keys -t %s:1 '%s' Enter" % (n, line))
220 # else:
221 # spresc("tmux send-keys -t %s:1 '%s' Enter" % (n, cmd))
222 _ = expect_echo_out_cmd lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
223 _ = cmd if not _ else cmd.split(_, 1)[0] + L(_) lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
224 symb = '💻' lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
225 lp.nfo(symb, tmux=' ' + _) lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
226 lp.spresc('tmux send-keys -t %s:1 -H %s' % (n, seq)) lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
228 t0 = now() lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
229 wait_dt = 0.1 lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
230 last_msg = 0 lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
231 max_wait = 2 lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
233 while True: lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
234 res = lp.sprun('tmux capture-pane -epJS -1000000 -t %s:1' % n) lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
235 dbg(res) lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
236 if expectb in res: lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
237 break lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
238 dt = now() - t0 lp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.md
239 if dt > timeout: lp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.md
240 if expect is False: 240 ↛ 243line 240 didn't jump to line 243, because the condition on line 240 was never falselp|features/lp/parameters.md
241 # wanted then:
242 break lp|features/lp/parameters.md
243 raise Exception(
244 'Command %s: Timeout (> %s sec) expecting "%s"'
245 % (cmd, timeout, expectb.decode('utf-8'))
246 )
248 if now() - last_msg > 5: 248 ↛ 251line 248 didn't jump to line 251, because the condition on line 248 was never falselp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.md
249 dbg('%ss[%s] Inspect: tmux att -t %s' % (round(dt, 1), timeout, n)) lp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.md
250 lst_msg = now() lp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.md
251 wait(wait_dt) # fast first lp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.md
252 wait_dt = min(timeout / 10.0, max_wait) lp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.md
253 max_wait = min(5, max_wait + 2) lp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.md
255 res = res.decode('utf-8') lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
256 if expect_echo_out_cmd: lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
257 # when expect was given we include it (expect="Ready to accept Connections")
258 # expect_echo_out_cmd is empty then
259 res = res.split(expect, 1)[0].strip() lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
260 a = expect_echo_out_cmd lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
261 a = a[1:] if a.startswith('\n') else a # when \n is the sep we won't see it lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
262 res = res.replace(a, '') lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
263 else:
264 # the tmux window contains a lot of white space after the last output when
265 # short cmd
266 res = res.strip() lp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.md
267 if wait_after: 267 ↛ 268line 267 didn't jump to line 268, because the condition on line 267 was never truelp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
268 time.sleep(float(wait_after))
269 lp.check_assert(assert_, res) lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
270 dbg('Have tmux result:', res='\n' + res) lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
271 if do_post: lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
272 do_post() lp|features/lp/parameters.md
273 return res if not silent else 'silent' lp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/sessions.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.md
276def find_output_range(res, between, ls=b'\n'): lp|features/lp/examples.md
277 """default: parse out last range in res between begin and end of between"""
278 # todo: regex
279 pre, post = res.rsplit(between[0], 1)
280 r = pre.rsplit(ls, 1)[-1] + between[0]
281 body, post = post.split(between[1], 1)
282 r += body
283 r += between[1] + post.split(ls, 1)[0]
284 return r
287def tmux_kill_session(session_name): lp|features/lp/examples.md
288 os.system('tmux kill-session -t %s' % session_name) lp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/syntax.md