Coder Social home page Coder Social logo

sloria / doitlive Goto Github PK

View Code? Open in Web Editor NEW
3.4K 38.0 98.0 479 KB

Because sometimes you need to do it live

Home Page: https://doitlive.readthedocs.io/

License: MIT License

Python 98.24% Shell 1.76%
command-line presentations python live-coding cli click bash zsh ipython script

doitlive's People

Contributors

asmacdo avatar axocomm avatar dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar dvirb10 avatar jmcarp avatar jordigh avatar matan129 avatar metti avatar pandawhocodes avatar pre-commit-ci[bot] avatar pyup-bot avatar sloria avatar stefan-code avatar timgates42 avatar tleguern avatar zigarn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

doitlive's Issues

Support "pasted" text

Sometimes I'll be running a demo where paste some text (e.g. a JSON blob or a URL). Is there any way to simulate this with doitlive? Typing that text out would be very conspicuous.

Re-design the keyboard module

Hi! After adding the support of ctrl-L keyboard shortcut, I've noticed the keyboard strokes are managed in a one big if...else, and that some of the keystrokes being handled are the same for both magictype and regulartype. ( Like ctrl-L :) )

I think it will be better to manage the keystrokes for both magictype and regulartype together, at least some of them to avoid code duplication. Also, both of them are getting the same parameters but text, which also cause a little bit of code duplication.

Any suggestions or disagreements will be happily received.
I hope it's ok 😟 It's my first time trying to help an open-source project :)

Thanks!

setup.py records the full python path

In Homebrew we install doitlive with:

python3 setup.py install --prefix=/usr/local/Cellar/doitlive/4.3.0_5/libexec

where python3 in PATH is /usr/local/bin/python3, which is a symlink to /usr/local/Cellar/python/3.7.6/bin/python3. However, when we do this, the doitlive in /usr/local/Cellar/doitlive/4.3.0_5/libexec/bin contains this as a shebang:

#!/usr/local/Cellar/python/3.7.6/bin/python3

which is not desirable at all for us. Other python packages don't do that, so I think it's an issue specific to doitlive. It would be nice if setup.py could simply use the python path that is given to it, rather than try to guess.

Unable to activate a conda environment during recording

I am noticing a few issues that suggests that you are a different shell (and configuration) inside the recording session.
Any idea?

(REC) omry@debian:demo $ conda activate hydra-demo

CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
To initialize your shell, run

    $ conda init <SHELL_NAME>

Currently supported shells are:
  - bash
  - fish
  - tcsh
  - xonsh
  - zsh
  - powershell

See 'conda init --help' for more information and options.

IMPORTANT: You may need to close and restart your shell after running 'conda init'.


(REC) omry@debian:demo $ source activate hydra-demo
/tmp/tmp5d9ws7: line 4: activate: No such file or directory

function not found in dotilive playbback session

When registering a function like:

# Recorded with the doitlive recorder
#doitlive shell: /bin/zsh
#doitlive prompt: default

db_set () { echo "$1,$2" >> database }
db_set 123456 '{"name":"Vienna","attractions":["Prater","TU Vienna"]}'

cat database

When playing back the session it fails with:

/var/folders/lz/vlbj1rj12dzbvbmj16jbp0k80000gn/T/tmp077ulken:3: command not found: db_set

but the database file still contains some values:

cat database
,

How can I get doitlive to recognize the function?

NOTE originally, the function was written on a multiline string:

db_set () {
    echo "$1,$2" >> database
}

but this failed to enter the command due to the newline commande.

Xonsh support?

Hey,

Great project!

It would be super cool if xonsh scripts were fully supported, e.g.

a = 1
print(a)
echo @(a)

Seems not too disimilar from the interactive python console...

Any ideas on this?

Cheers

how to source zsh functions

I have a function in a zsh script.

i use the doitlive play session.sh --shell /usr/bin/zsh

inside it i source it manually via

   source ~/..../custom_script.zsh
   # call function from script here <<>>
   custom_script_function

However all the commands in the custom script are not found.

Actually typing comments?

I would like to have doitlive actually type non-magic comments in some way (maybe a second kind of magic comments that do get typed out, vs comments which are intended for the reader of session.sh?). Would that be something you'd merge, if I provided a PR?

Question: Windows compability

Just a quick question regarding the fix of #6 : Is this program windows compatible? I don't have a windows box to test around and the README doesn't say anything about it either.

doitlive doesn't run on stock CentOS 7

doitlive successfully installs on CentOS 7 after pip upgrade'ing pip and setuptools, but will not execute a shell script. I have this script:

#!/bin/bash

echo $RANDOM
date +%s
curl https://www.usno.navy.mil/USNO/time | grep "Master Clock"

When I try to play it with doitlive, I get a stack trace:

$ doitlive play ./test.sh 
We'll do it live!
STARTING SESSION: Press Ctrl-C at any time to exit.
Press any key to continue ...



Traceback (most recent call last):
  File "/home/kensey/.local/bin/doitlive", line 8, in <module>
    sys.exit(cli())
  File "/home/kensey/.local/lib/python2.7/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/kensey/.local/lib/python2.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/kensey/.local/lib/python2.7/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/kensey/.local/lib/python2.7/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/kensey/.local/lib/python2.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/kensey/.local/lib/python2.7/site-packages/doitlive/cli.py", line 428, in play
    commentecho=commentecho,
  File "/home/kensey/.local/lib/python2.7/site-packages/doitlive/cli.py", line 245, in run
    goto_stealthmode = magicrun(command, **state)
  File "/home/kensey/.local/lib/python2.7/site-packages/doitlive/keyboard.py", line 216, in magicrun
    goto_regulartype = magictype(text, prompt_template, speed)
  File "/home/kensey/.local/lib/python2.7/site-packages/doitlive/keyboard.py", line 40, in magictype
    echo_prompt(prompt_template)
  File "/home/kensey/.local/lib/python2.7/site-packages/doitlive/styling.py", line 222, in echo_prompt
    prompt = make_prompt_formatter(template)()
  File "/home/kensey/.local/lib/python2.7/site-packages/doitlive/styling.py", line 218, in <lambda>
    return lambda: format_prompt(tpl)
  File "/home/kensey/.local/lib/python2.7/site-packages/doitlive/styling.py", line 196, in format_prompt
    return prompt.format(**get_prompt_state())
  File "/home/kensey/.local/lib/python2.7/site-packages/doitlive/styling.py", line 236, in get_prompt_state
    "git_branch": _branch_to_term_string(get_current_git_branch()),
  File "/home/kensey/.local/lib/python2.7/site-packages/doitlive/version_control.py", line 12, in get_current_git_branch
    proc = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  File "/usr/lib64/python2.7/subprocess.py", line 711, in __init__
    errread, errwrite)
  File "/usr/lib64/python2.7/subprocess.py", line 1327, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

Installation info:

$ python --version
Python 2.7.5
$ pip show pip setuptools doitlive click click-completion click-didyoumean
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Name: pip
Version: 20.0.1
Summary: The PyPA recommended tool for installing Python packages.
Home-page: https://pip.pypa.io/
Author: The pip developers
Author-email: [email protected]
License: MIT
Location: /usr/lib/python2.7/site-packages
Requires: 
Required-by: 
---
Name: setuptools
Version: 44.0.0
Summary: Easily download, build, install, upgrade, and uninstall Python packages
Home-page: https://github.com/pypa/setuptools
Author: Python Packaging Authority
Author-email: [email protected]
License: UNKNOWN
Location: /home/kensey/.local/lib/python2.7/site-packages
Requires: 
Required-by: 
---
Name: doitlive
Version: 4.3.0
Summary: Because sometimes you need to do it live.
Home-page: https://github.com/sloria/doitlive
Author: Steven Loria
Author-email: [email protected]
License: MIT
Location: /home/kensey/.local/lib/python2.7/site-packages
Requires: click, click-completion, click-didyoumean
Required-by: 
---
Name: Click
Version: 7.0
Summary: Composable command line interface toolkit
Home-page: https://palletsprojects.com/p/click/
Author: Armin Ronacher
Author-email: [email protected]
License: BSD
Location: /home/kensey/.local/lib/python2.7/site-packages
Requires: 
Required-by: doitlive, click-didyoumean, click-completion
---
Name: click-completion
Version: 0.5.2
Summary: Fish, Bash, Zsh and PowerShell completion for Click
Home-page: https://github.com/click-contrib/click-completion
Author: Gaëtan Lehmann
Author-email: [email protected]
License: MIT
Location: /home/kensey/.local/lib/python2.7/site-packages
Requires: click, jinja2, six, shellingham, enum34
Required-by: doitlive
---
Name: click-didyoumean
Version: 0.0.3
Summary: Enable git-like did-you-mean feature in click.
Home-page: https://github.com/timofurrer/click-didyoumean
Author: Timo Furrer
Author-email: [email protected]
License: UNKNOWN
Location: /home/kensey/.local/lib/python2.7/site-packages
Requires: click
Required-by: doitlive

How to use with Windows ?

I'm using Windows 7. I've tried the session in examples, but it failed. I tried also with Git Bash it failed also. Could you tell me how to test on Windows ?
Thank you.

Current dev branch does not pass for python2.7 (click warnings)

For me the current dev branch without modifications does not pass the tests for python 2.7. They do pass for python3 though.
Tox tells me the following:

tests/test_doitlive.py::test_themes_list FAILED
tests/test_doitlive.py::test_themes_preview FAILED
tests/test_doitlive.py::test_version FAILED

and

runner = <click.testing.CliRunner object at 0x7fe8148c5d50>

    def test_themes_list(runner):
        result1 = runner.invoke(cli, ['themes'])
        assert result1.exit_code == 0
        result2 = runner.invoke(cli, ['themes', '--list'])
        result3 = runner.invoke(cli, ['themes', '-l'])
>       assert result1.output == result2.output == result3.output
E       assert '/home/sk/Pro...ssell giddie\n' == '/home/sk/Prog...ssell giddie\n'
E         - /home/sk/Programming/doitlive-tox/tests/test_doitlive.py:165: Warning: Click detected the use of the unicode_literals __future__ import.  This is heavily discouraged because it can introduce subtle bugs in your code.  You should instead use explicit u"" literals for your unicode strings.  For more information see http://click.pocoo.org/python3/
E         ?                                                            ^
E         + /home/sk/Programming/doitlive-tox/tests/test_doitlive.py:167: Warning: Click detected the use of the unicode_literals __future__ import.  This is heavily discouraged because it can introduce subtle bugs in your code.  You should instead use explicit u"" literals for your unicode strings.  For more information see http://click.pocoo.org/python3/
E         ?                                                            ^
E         -   result1 = runner.invoke(cli, ['themes'])
E         ?         ^
E         +   result2 = runner.invoke(cli, ['themes', '--list'])
E         ?         ^                               ++++++++++
E           Available themes:
E         Detailed information truncated (1 more lines), use "-vv" to show

Programming/doitlive-tox/tests/test_doitlive.py:169: AssertionError
_________________________________________________________________________ test_themes_preview __________________________________________________________________________

runner = <click.testing.CliRunner object at 0x7fe8148c5d50>

    def test_themes_preview(runner):
        result1 = runner.invoke(cli, ['themes', '--preview'])
        assert result1.exit_code == 0
        result2 = runner.invoke(cli, ['themes', '-p'])
        assert result2.exit_code == 0
>       assert result1.output == result2.output
E       assert '/home/sk/Pro...g2 ... argn\n\n' == '/home/sk/Prog...g2 ... argn\n\n'
E         - /home/sk/Programming/doitlive-tox/tests/test_doitlive.py:173: Warning: Click detected the use of the unicode_literals __future__ import.  This is heavily discouraged because it can introduce subtle bugs in your code.  You should instead use explicit u"" literals for your unicode strings.  For more information see http://click.pocoo.org/python3/
E         ?                                                            ^
E         + /home/sk/Programming/doitlive-tox/tests/test_doitlive.py:175: Warning: Click detected the use of the unicode_literals __future__ import.  This is heavily discouraged because it can introduce subtle bugs in your code.  You should instead use explicit u"" literals for your unicode strings.  For more information see http://click.pocoo.org/python3/
E         ?                                                            ^
E         -   result1 = runner.invoke(cli, ['themes', '--preview'])
E         ?         ^                                   - ------
E         +   result2 = runner.invoke(cli, ['themes', '-p'])
E         ?         ^
E           Theme previews:
E         Detailed information truncated (48 more lines), use "-vv" to show

Programming/doitlive-tox/tests/test_doitlive.py:177: AssertionError
_____________________________________________________________________________ test_version _____________________________________________________________________________

runner = <click.testing.CliRunner object at 0x7fe8148c5d50>

    def test_version(runner):
        result = runner.invoke(cli, ['--version'])
        print("huhuhu", result.output, "haha")
        assert doitlive.__version__ in result.output
        result2 = runner.invoke(cli, ['-v'])
>       assert result.output == result2.output
E       assert '/home/sk/Pro...ersion 2.3.1\n' == '/home/sk/Prog...ersion 2.3.1\n'
E         - /home/sk/Programming/doitlive-tox/tests/test_doitlive.py:181: Warning: Click detected the use of the unicode_literals __future__ import.  This is heavily discouraged because it can introduce subtle bugs in your code.  You should instead use explicit u"" literals for your unicode strings.  For more information see http://click.pocoo.org/python3/
E         ?                                                            ^
E         + /home/sk/Programming/doitlive-tox/tests/test_doitlive.py:184: Warning: Click detected the use of the unicode_literals __future__ import.  This is heavily discouraged because it can introduce subtle bugs in your code.  You should instead use explicit u"" literals for your unicode strings.  For more information see http://click.pocoo.org/python3/
E         ?                                                            ^
E         -   result = runner.invoke(cli, ['--version'])
E         ?                                  - ------
E         +   result2 = runner.invoke(cli, ['-v'])
E         ?         +
E           cli, version 2.3.1
E         Detailed information truncated (0 more lines), use "-vv" to show

Programming/doitlive-tox/tests/test_doitlive.py:185: AssertionError

As far as I can see there's a lot of Click warnings regarding Unicode. Maybe this warning was added recently, thus the tests fail for new versions of click?
I suspect this is what's making my pull request build fail
EDIT:
Also a lot of ugly click warnings are appearing during normal usage:

(doitlive-2)sk@sk2 ~/Programming/doitlive-2 $ python2 doitlive.py play test.sh
doitlive.py:598: Warning: Click detected the use of the unicode_literals __future__ import.  This is heavily discouraged because it can introduce subtle bugs in your code.  You should instead use explicit u"" literals for your unicode strings.  For more information see http://click.pocoo.org/python3/
  @click.group(context_settings={'help_option_names': ('-h', '--help')})
doitlive.py:637: Warning: Click detected the use of the unicode_literals __future__ import.  This is heavily discouraged because it can introduce subtle bugs in your code.  You should instead use explicit u"" literals for your unicode strings.  For more information see http://click.pocoo.org/python3/
  @cli.command()
doitlive.py:686: Warning: Click detected the use of the unicode_literals __future__ import.  This is heavily discouraged because it can introduce subtle bugs in your code.  You should instead use explicit u"" literals for your unicode strings.  For more information see http://click.pocoo.org/python3/
  @cli.command()
doitlive.py:706: Warning: Click detected the use of the unicode_literals __future__ import.  This is heavily discouraged because it can introduce subtle bugs in your code.  You should instead use explicit u"" literals for your unicode strings.  For more information see http://click.pocoo.org/python3/
  @cli.command()
doitlive.py:784: Warning: Click detected the use of the unicode_literals __future__ import.  This is heavily discouraged because it can introduce subtle bugs in your code.  You should instead use explicit u"" literals for your unicode strings.  For more information see http://click.pocoo.org/python3/
  @cli.command()
doitlive.py:827: Warning: Click detected the use of the unicode_literals __future__ import.  This is heavily discouraged because it can introduce subtle bugs in your code.  You should instead use explicit u"" literals for your unicode strings.  For more information see http://click.pocoo.org/python3/
  cli()
We'll do it live!
STARTING SESSION: Press Ctrl-C at any time to exit.
Press any key to continue ...

Don't end at the end

I wish there was a way to not end automatically at the end of the session. This tool is like magic and seeing FINISHED SESSION breaks the illusion when up on stage.

Handle Ctrl-L so we don't have to use `clear` all the time

In a terminal, Ctrl-L works the same as entering clear: It scrolls down until only the current line is visable.

It would be cool if doitlive could handle Ctrl-L the same way, as it is less distracting than an additional command (clear) after command that produces much output.

Start/End of script

It would be good to be able to define in a long shell script a start and end, and have the “playback” be only between those 2 points

Essential in my view to help test long scripts without having to copy-paste between files

Dependabot couldn't fetch all your path-based dependencies

Dependabot couldn't fetch one or more of your project's path-based Python dependencies. The affected dependencies were '.'/setup.py.

To use path-based dependancies with Dependabot the paths must be relative and resolve to a directory in this project's source code.

You can mention @dependabot in the comments below to contact the Dependabot team.

bugs in <tab> editing mode

(1) When I copy-paste with mouse (ie: paste more than 30 characters), only first bytes go to the console. Only top 10-20 characters are ingested.

(2) up-arrow doesn't work with

/tmp/tmpt_i6n40m: line 4: $'\E[A': command not found
prompt $ 

Fix documentation for default value of --shell

The default for the --shell option uses the get_default_shell function to get the user's default shell. The help text is incorrect:

doitlive play --help
Usage: doitlive play [OPTIONS] SESSION_FILE

  Play a session file.

Options:
  -e, --commentecho            Echo non-magic comments.
  -p, --prompt <prompt_theme>  Prompt theme.  [default: default]
  -s, --speed <int>            Typing speed.  [default: 1]
  -S, --shell <shell>          The shell to use.  [default: <function
                               get_default_shell at 0x1033fc6a8>]
  -q, --quiet                  Suppress startup and ending message.
  -h, --help                   Show this message and exit.

The repr for get_default_shell is used. We should find a way to override the docs for the default value so that we can document it to say [default: $SHELL].

Echo command on windows 10

Hello. On windows 10 the echo command (that I use to write files) doesn't work. The programm crashes with the error No such file or directory when I use the record parameter to record the session.

Handle multi-line commands

Nice package. Having a problem using it when there are single or double-quotes in either command or the comments (using commentecho: true). For instance, the following line:

vault write -format=yaml pki_root/root/generate/internal \                                                                                                                                                                           
      common_name='somefakeorg.example Root CA' \                                                                                                                                                                                                                                                                                                                                                                                      
      ttl=8760h                                                                                                                                                                                                                                                                                                                                                                               

cause the following backtrace:

Traceback (most recent call last):                                                                                                                                                                                                                                                                                                                                                                                                       
  File "/home/redacted/.anyenv/envs/pyenv/versions/3.6.4/bin/doitlive", line 11, in <module>                                                                                                                                                                                                                                                                                                                                             
    sys.exit(cli())                                                                                                                                                                                                                                                                                                                                                                                                                      
  File "/home/redacted/.anyenv/envs/pyenv/versions/3.6.4/lib/python3.6/site-packages/click/core.py", line 722, in __call__                                                                                                                                                                                                                                                                                                               
    return self.main(*args, **kwargs)                                                                                                                                                                                                                                                                                                                                                                                                    
  File "/home/redacted/.anyenv/envs/pyenv/versions/3.6.4/lib/python3.6/site-packages/click/core.py", line 697, in main                                                                                                                                                                                                                                                                                                                   
    rv = self.invoke(ctx)                                                                                                                                                                                                                                                                                                                                                                                                                
  File "/home/redacted/.anyenv/envs/pyenv/versions/3.6.4/lib/python3.6/site-packages/click/core.py", line 1066, in invoke                                                                                                                                                                                                                                                                                                                
    return _process_result(sub_ctx.command.invoke(sub_ctx))                                                                                                                                                                                                                                                                                                                                                                              
  File "/home/redacted/.anyenv/envs/pyenv/versions/3.6.4/lib/python3.6/site-packages/click/core.py", line 895, in invoke                                                                                                                                                                                                                                                                                                                 
    return ctx.invoke(self.callback, **ctx.params)                                                                                                                                                                                                                                                                                                                                                                                       
  File "/home/redacted/.anyenv/envs/pyenv/versions/3.6.4/lib/python3.6/site-packages/click/core.py", line 535, in invoke                                                                                                                                                                                                                                                                                                                 
    return callback(*args, **kwargs)                                                                                                                                                                                                                                                                                                                                                                                                     
  File "/home/redacted/.anyenv/envs/pyenv/versions/3.6.4/lib/python3.6/site-packages/doitlive/cli.py", line 322, in play                                                                                                                                                                                                                                                                                                                 
    commentecho=commentecho)                                                                                                                                                                                                                                                                                                                                                                                                             
  File "/home/redacted/.anyenv/envs/pyenv/versions/3.6.4/lib/python3.6/site-packages/doitlive/cli.py", line 129, in run                                                                                                                                                                                                                                                                                                                  
    command_as_list = shlex.split(ensure_utf8(command))                                                                                                                                                                                                                                                                                                                                                                                  
  File "/home/redacted/.anyenv/envs/pyenv/versions/3.6.4/lib/python3.6/shlex.py", line 305, in split                                                                                                                                                                                                                                                                                                                                     
    return list(lex)                                                                                                                                                                                                                                                                                                                                                                                                                     
  File "/home/redacted/.anyenv/envs/pyenv/versions/3.6.4/lib/python3.6/shlex.py", line 295, in __next__                                                                                                                                                                                                                                                                                                                                  
    token = self.get_token()                                                                                                                                                                                                                                                                                                                                                                                                             
  File "/home/redacted/.anyenv/envs/pyenv/versions/3.6.4/lib/python3.6/shlex.py", line 105, in get_token                                                                                                                                                                                                                                                                                                                                 
    raw = self.read_token()                                                                                                                                                                                                                                                                                                                                                                                                              
  File "/home/redacted/.anyenv/envs/pyenv/versions/3.6.4/lib/python3.6/shlex.py", line 206, in read_token                                                                                                                                                                                                                                                                                                                                
    raise ValueError("No escaped character")                                                                                                                                                                                                                                                                                                                                                                                             
ValueError: No escaped character                                                                                                                                                                                                                                                                                                                                                                                                         

At least in the case of comments you can avoid the backtrace by escaping the single or double quotes but then the escaping also shows up in the commentecho output.

Ideas?

doitlive handling of shell meta-metacharacters

Hi - love the product. I am a professor using it to teach Linux shell to a class of undergrads - makes demos so much smoother. I have attached a session-test.sh file, I noticed that doitlive doesn't handle shell meta-characters, for instance ~- and the backtick example of DT=date; echo $DT will be blank. Using Fedora 22 on Gnome-Terminal

What is your opinion?

session.sh

cd ~/Documents
pwd
cd ~/Downloads
pwd
cd ~-
pwd
clear
DT=`date`
echo $DT
date
DT=date
echo $DT
DT=5
echo $DT

Ctrl-Z doesn't suspend doitlive

I'd like to be able to pause/resume doitlive at arbitrary points during my presentation in case I happen to field a question that would best be answered or supplemented by an ad-hoc invocation of command. I was simply thinking that using Ctrl-Z to suspend doitlive and later fg to resume it would be the best way to get there, but Ctrl-Z appears to be treated as a regular keypress.

I'm using the Homebrew version of doitlive

> doitlive --version
doitlive, version 4.0.0
> uname -a
Darwin ehouse-mbp 17.5.0 Darwin Kernel Version 17.5.0: Mon Mar  5 22:24:32 PST 2018; root:xnu-4570.51.1~1/RELEASE_X86_64 x86_64
> which doitlive
/usr/local/bin/doitlive

get a Warning from python-click 5.1

/usr/lib/python2.7/site-packages/doitlive-2.3.1-py2.7.egg/doitlive.py:598: Warning: Click detected the use of the unicode_literals future import. This is heavily discouraged because it can introduce subtle bugs in your code. You should instead use explicit u"" literals for your unicode strings. For more information see http://click.pocoo.org/python3/

this fixed it:

diff --git a/doitlive.py b/doitlive.py
index 377f102..3aa6408 100755
--- a/doitlive.py
+++ b/doitlive.py
@@ -10,7 +10,7 @@
   :license: MIT, see LICENSE for more details.
 """

-from __future__ import unicode_literals
+#from __future__ import unicode_literals
 import datetime as dt
 import functools
 import os
@@ -252,11 +252,11 @@ def get_current_vcs_branch():


 # Some common symbols used in prompts
-R_ANGLE = TermString('❯')
-R_ANGLE_DOUBLE = TermString('»')
-R_ARROW = TermString('➔')
-DOLLAR = TermString('$')
-PERCENT = TermString('%')
+R_ANGLE = TermString(u'❯')
+R_ANGLE_DOUBLE = TermString(u'»')
+R_ARROW = TermString(u'➔')
+DOLLAR = TermString(u'$')
+PERCENT = TermString(u'%')

Some keystrokes escape and get echoed

I am working on Debian GNU/Linux, and I'm having trouble with some keystrokes getting echoed instead of getting swallowed. This is probably going to be difficult to debug, since it's obviously a timing problem, and I assume it must be dependent on something on my system.

I'll attempt to fix this myself, but I'm recording the problem here for posterity.

Pausing/typing whole lines

I have two features I think would make doitlive better, but I see something similar is supported, though not documented.

The first feature is typing out a whole line with a key combination. Basically, if I'm at the start of a long line, I can press some combination and have the entire line typed out. I don't think this is currently possible, but also I'm not sure about this feature. I want it for showing presentation "topics" as comments which are too cumbersome to type out, but maybe echoed comments will do.

The second feature is being able to pause and resume the stream. I see that pressing tab will pause, but I get erratic behavior where it will skip the entire line, press enter mid-type and odd things like that? I need it in case I'm in a Python shell and the audience asks me to make changes or so I can take control if something goes wrong, while being able to resume afterwards.

This isn't documented, so I had to discover it in the code. Tab and Ctrl-Z do different things in the code, but in my testing, Ctrl-Z doesn't work (the process just gets backgrounded).

Can you explain a bit about how these are supposed to work, maybe document them, and discuss whether a pausing feature would be acceptable?

Issue with python 3.9 and ipython shell

Script file example :

```ipython
print("Hi!")
```

When ipython starts :

...
from prompt_toolkit.interface import CommandLineInterface, _InterfaceEventLoopCallbacks
ModuleNotFoundError: No module named 'prompt_toolkit.interface'
...

It seems that interface disappeared from prompt_toolkit a long time ago

Python 3.9.0 (default, Oct 7 2020, 23:09:01)
prompt-toolkit==3.0.8
doitlive==4.3.0

Everything works well with

```python
print("Hi")
```

Add option to not exit with esc

I sometimes press Escape while typing as a reflex, and it would be very inconvenient if this exits the presentation while I'm presenting. Could we have an option to disable this key?

Staircase on background commands

Thanks for such an awesome tool. There are a couple of bugs in the terminal handling.

First, we see staircase when running background command

(for i in `seq 10`; do echo hello; sleep 0.1; done) &

Got:

prompt $ hello
                                    hello
                                         hello
                                              hello
                                                   hello
                                                        hello
                                                             hello
                                                                  hello
                                                                       hello

While in normal bash it is not staircased.

Ctrl-C (and other Ctrl chars like Ctrl-Z) treated as any other keypress

I'm unable to exit early due to this.

§ python --version
Python 2.7.12
§ lsb_release -a
No LSB modules are available.
Distributor ID: elementary
Description:    elementary OS 0.4.1 Loki
Release:        0.4.1
Codename:       loki
§ uname -a
Linux [redacted] 4.4.0-93-generic #116-Ubuntu SMP Fri Aug 11 21:17:51 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

Execute commands in a nested process

Thank you for your job, the project is awesome and useful.
but I wanted to execute some commands to pdb and use asciinema and replay the scenario with your tool and asciinema.

There are the python and ipython modes, but how do you think I can work with python -m pdb myscript.py ? because in the code, you check (with regex) if you will select python or ipython mode.

Again, how will you handle the case where you can show a debugging session with gdb ?

Here is a small example with pdb

python -m pdb script.py
break
break main
continue
quit

Have you an idea?

Have a nice day and thank you.

Document Ctrl-C and Ctrl-Z behavior and prompt themes

It would be cool if we could have some more documentation in the help text.

  • Explain how to use Ctrl-C and Ctrl-Z in a presentation (this is self explanatory for CLI veterans, but many users might not be so experienced. Ctrl-C and Crtl-Z are really a great part of how to use the programm in a presentation)
  • Explain how <prompt_themes> work: How can I create my own? Where can I find premade ones?

directory movement doesn't work

Standard directory movement commands and aliases don't appear to work when played back.

$ cat test.sh
echo "hahaha"
ls -la
cd /tmp
cd -
cd $HOME
cd -
echo "Done"

$ doitlive play test.sh
...
[email protected]:206833 $ cd /tmp
[email protected]:tmp $ cd -
No such file or directory: -
[email protected]:tmp $ cd $HOME
No such file or directory: $HOME
[email protected]:tmp $ cd -
No such file or directory: -
[email protected]:tmp $ echo "Done"
Done
[email protected]:tmp $
FINISHED SESSION

Using \ for line-break exits doitlive

Hi,
I cannot use \ to enter a line-break when using a lengthy command, e.g.

$ vmcreate --project=lve \
> --user=test \
> --password=secret

Can you please advise how to fix this?

THX

support setting variables in a script

Variables cannot be set within a live script:

$ cat variables.sh

export SET_VAR="Please add support for variables"
echo $SET_VAR

$ doitlive play variables.sh

We'll do it live!
STARTING SESSION: Press Ctrl-C at any time to exit.
Press any key to continue ...
[email protected]:devel $ export SET_VAR="Please add support for variables"
[email protected]:devel $ echo $SET_VAR

[email protected]:devel $ 
FINISHED SESSION

Just as a sanity check...
bash variables.sh

Please add support for variables

ipython mode captures the key presses

Not sure, whether this is just me, but whenever I try to use an ipython mode,
the interpreter starts to capture my random key presses, instead of the scripted commands.

python-ipython.noarch 3.2.1-7.fc24

 cat doitlive-demo.sh 
# in session.sh
```ipython
def foo():
	print('bar')

foo()
$ doitlive play doitlive-demo.sh 
We'll do it live!
STARTING SESSION: Press Ctrl-C at any time to exit.
Press any key to continue ...

[email protected]:playground $ ipython
Python 2.7.13 (default, May 10 2017, 20:04:36) 
Type "copyright", "credits" or "license" for more information.

IPython 5.3.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: sadasdasdasdasdasfasfa
------------------------------------------------------------------------
NameError                              Traceback (most recent call last)
<ipython-input-1-0048448acb26> in <module>()
----> 1 sadasdasdasdasdasfasfa

NameError: name 'sadasdasdasdasdasfasfa' is not defined

In [2]: quit
[email protected]:playground $ 
FINISHED SESSION

The basic python mode works well though.

The mindset behind doitlive?

Hey!

I stumbled upon this tool, but I don't really know why or when I would want to use it.
I feel like I wouldn't quite feel fine using it, instead of really doing it live.

Could you share the mindset behind this project? I have a hard time understanding it.

As a vocalist I imagine how I'd feel performing a concert with a pre-recorded vocal track (instead of me singing) where the playback is gated with my mic, so it'll trigger the recorded singing, but it's not really me doing it live. It's played back.

Same is here - it's a pre-recorded terminal session that is triggered with my typing. but it's not really me typing what you see on the screen.

What say though?
Maybe you'd want to add a position to your FAQ titled "Isn't this cheating?"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.