Hide keyboard shortcuts

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

1""" 

2### `bash` 

3 

4Runs the given statements within a bash shell. 

5 

6This is the default evaluation mode. 

7 

8When you supply a session parameter, we will send the statements over into tmux and run 

9them there. 

10 

11""" 

12 

13 

14from lcdoc import lp lp|features/lp/examples.md

15from lcdoc.lp_session import srun, tmux_kill_session lp|features/lp/examples.md

16 

17multi_line_to_list = True lp|features/lp/examples.md

18 

19 

20class Session(lp.SessionNS): lp|features/lp/examples.md

21 @classmethod lp|features/lp/examples.md

22 def delete(cls, ns, kw): 

23 tmux_kill_session(ns) lp|features/lp/examples.mdlp|features/lp/parameters.mdlp|features/lp/sessions.mdlp|features/lp/syntax.md

24 

25 @classmethod lp|features/lp/examples.md

26 def pre(cls, session_name, kw): 

27 # otherwise we handle this within our tmux session: 

28 if session_name: lp|features/lp/bash/index.mdlp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.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/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/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/plugs/make_file/index.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/syntax.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.mdlp|features/lp/xterm.md

29 lp.SessionNS.pre(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

30 

31 @classmethod lp|features/lp/examples.md

32 def post(cls, session_name, kw): 

33 if session_name: lp|features/lp/bash/index.mdlp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.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/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/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/plugs/make_file/index.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/syntax.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.mdlp|features/lp/xterm.md

34 return lp.SessionNS.post(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

35 

36 

37def run(cmd, kw): lp|features/lp/examples.md

38 session_name = kw['session_name'] lp|features/lp/bash/index.mdlp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.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/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/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/plugs/make_file/index.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/syntax.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.mdlp|features/lp/xterm.md

39 

40 if session_name: lp|features/lp/bash/index.mdlp|features/lp/bash/sessions.mdlp|features/lp/examples.mdlp|features/lp/examples.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/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/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/plugs/make_file/index.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/syntax.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/tips.mdlp|features/lp/xterm.md

41 return srun(cmd, **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

42 

43 # os.system style: 

44 if not isinstance(cmd, list): 44 ↛ 45line 44 didn't jump to line 45, because the condition on line 44 was never truelp|features/lp/bash/index.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/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/plugs/make_file/index.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/xterm.md

45 cmd = [cmd] 

46 

47 res = [] lp|features/lp/bash/index.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/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/plugs/make_file/index.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/xterm.md

48 for c in cmd: lp|features/lp/bash/index.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/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/plugs/make_file/index.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/xterm.md

49 silent = False lp|features/lp/bash/index.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/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/plugs/make_file/index.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/xterm.md

50 lp.os_system_if_param_present(c, 'pre') lp|features/lp/bash/index.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/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/plugs/make_file/index.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/xterm.md

51 c1 = c['cmd'] if isinstance(c, dict) else c lp|features/lp/bash/index.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/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/plugs/make_file/index.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/xterm.md

52 rcmd = c1 lp|features/lp/bash/index.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/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/plugs/make_file/index.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/xterm.md

53 prompt = kw.get('prompt', '$') lp|features/lp/bash/index.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/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/plugs/make_file/index.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/xterm.md

54 if kw.get('root'): 54 ↛ 55line 54 didn't jump to line 55, because the condition on line 54 was never truelp|features/lp/bash/index.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/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/plugs/make_file/index.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/xterm.md

55 rcmd = 'sudo %s' % rcmd 

56 rcmd = rcmd.replace(' && ', ' && sudo ') 

57 prompt = kw.get('prompt', '#') 

58 # for k, v in aliases.items(): rcmd = rcmd.replace(k, v) 

59 # return sp.check_output(['sudo podman ps -a'], shell=True) 

60 r = lp.sprun(rcmd) lp|features/lp/bash/index.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/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/plugs/make_file/index.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/xterm.md

61 r = r.decode('utf-8').rstrip() lp|features/lp/bash/index.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/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/plugs/make_file/index.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/xterm.md

62 if isinstance(c, dict): 62 ↛ 65line 62 didn't jump to line 65, because the condition on line 62 was never falselp|features/lp/bash/index.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/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/plugs/make_file/index.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/xterm.md

63 lp.check_assert(c.get('assert', c.get('asserts')), r) lp|features/lp/bash/index.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/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/plugs/make_file/index.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/xterm.md

64 silent = c.get('silent') lp|features/lp/bash/index.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/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/plugs/make_file/index.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/xterm.md

65 if not kw.get('hide_cmd'): lp|features/lp/bash/index.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/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/plugs/make_file/index.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/xterm.md

66 r = ''.join([prompt, ' ', c1, '\n', r]) lp|features/lp/bash/index.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/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/plugs/make_file/index.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/xterm.md

67 lp.os_system_if_param_present(c, 'post') lp|features/lp/bash/index.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/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/plugs/make_file/index.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/xterm.md

68 # res = '%s %s\n' % (prompt, cmd) + res 

69 if not silent: lp|features/lp/bash/index.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/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/plugs/make_file/index.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/xterm.md

70 res.append({'cmd': c1, 'res': r}) lp|features/lp/bash/index.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/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/plugs/make_file/index.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/xterm.md

71 return res lp|features/lp/bash/index.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/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/parameters.mdlp|features/lp/plugs/make_file/index.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/syntax.mdlp|features/lp/xterm.md