HACKER Q&A
📣 albert_e

Is there a Jupyter Notebook for terminal/shell


When I learn new tools like Docker for example there are a number of new commands and syntax I am picking up along the way.

I want to "SAVE" my work -- the commands I used and the output I got -- as a "Notebook" similar to how we do for Python notebooks using Jupyter. Also add some markdown notes or links to reference material or tutorials I am following.

This allows me to revisit my work of yesterday / last month / last year and quickly review what I already "know" (or relearn quickly following the same path) and then go to next logical step.

Is there such a tool or solution?

Thanks in advance


  👤 raverbashing Accepted Answer ✓
"kids these days huh" :)

You can save what you type with the 'script' command.

    script test_session
Will save everything you type and their output to the test_session file until you exit the shell with Ctrl-D

Look up "man script" for more details (funny it mentions 'typescript' but it is not that typescript)

(and while I joke about 'kids these days' I learned this from the UNIX greybeards so there's that as well)


👤 ThePhysicist
Actually iPython started as a better Python shell, seems most people have forgotten these origins. The Jupyter notebook was born out of the same project and quickly replaced the shell as it obviously had much more possibilities for visualization and interactivity. If you have Jupyter installed you'll also have iPython. To run it, simply type

> ipython

You can use the %save magic command to save your session, there's lots more, check the documentation to discover it.


👤 kagevf
emacs org mode will work in the terminal.

For example, in an org doc you can have something like this:

  * Python
  #+BEGIN_SRC python :results output
  def myTest(a):
   return a + 2
  
  print (myTest(8))
  #+END_SRC
  
  #+RESULTS:
  : 10
  
  #+BEGIN_SRC python :results output
  def check_even(n):
   if n % 2 == 0:
    print("even")
   else:
    print("odd")
  
  check_even(5)
  check_even(2)
  #+END_SRC
  
  #+RESULTS:
  : odd
  : even

👤 isr
A couple of suggestions:

- the xonsh (a full-featured unix shell, in python) kernel with jupyter

- the acme editor, using `win` to give you a dumb terminal access to your shell (or indeed any repl). As well as being a shell/repl, you can also treat that window as a text buffer, manipulating it and saving it as such (very liberating feeling, in practice)


👤 WCSTombs

👤 kindofabigdeal
I would imagine emacs org mode probably has what you need

👤 joouha
Yes! My project, euporie [1], is a TUI application for running and editing Jupyter notebooks in the terminal. It's interface similar to Jupyter Notebooks / Lab.

It sounds like exactly what you are after.

[1] https://github.com/joouha/euporie


👤 mharig
You may also use asciinema.org to record replayable tutorials. For adding notes, you can use a markdown file with the asciicast (the file format of asciinema) embedded.

Edit: But I do not know of an integrated, comfortable way to combine asciinema and markdown. Enhancing the asciicast format with (markdown) comments and make the asciicast players display them would be nice.


👤 sureshssarda
I use VSCode and Markdown files. You can select anything and run that in the terminal by executing the action 'Terminal: Run Selected text in active terminal'

I have also given it a shortcut: `Ctrl+e, e`. So I can just select something and execute it in the terminal. Works quite well.

(Inspired by a similar feature in Emacs)


👤 dangrie158
You can run any command in the shell by prefixing them with ! In the jupyter cell. However I don‘t think jupyter notebooks are super useful for that usecase as you can’t simply double click to open them

👤 pizza
You could use a jupyter notebook for this

Side-note: is the inverse of this available? E.g. open a jupyter notebook from in the middle of a python script


👤 bckr
I've wondered this exact same thing almost every day for the last year—Alas! I am still wondering.

👤 wizwit999
the new warp.dev terminal is kinda similar tho not exactly