Time all IPython commands by default - ipython

I would love for there to be an implicit %time run for every command I use in IPython. Is there a way to do that?

Related

Ctrl+S in fish shell does not work as in bash

Ctrl+S and Ctrl+Q can be used to pause/resume output in bash shell.
But in fish shell, it does not work.
Are there any replacement?
This is intentional. Fish disables terminal flow control because the original developers concluded the feature causes too many problems for inexperienced CLI users especially those used to emacs where [ctrl-s] is normally bound to the incremental search function and thus might type it at a shell prompt.
On the upside, the same functionality can be added to your fish shell with a function and a key-binding.
See the following plugins, for example:
https://github.com/oh-my-fish/plugin-sudope
https://github.com/oh-my-fish/plugin-bang-bang (implements the !! variant)

Reset an IPython kernel without restarting

Is there a way of programmatically reset an IPython kernel without restarting it?
Currently I am calling KernelManager.restart_kernel but that is quite slow.
The purpose of this is to isolate unit tests in a py.test plugin for using Notebook cells as unit tests. If you have other ideas to achieve this I'd love suggestions. The code is here:
https://github.com/zonca/pytest-ipynb/blob/master/pytest_ipynb/plugin.py#L100
I used the %reset IPython magic function instead of restarting the kernel. That removes all the variables but does not perform again the imports. That is suitable for my application.
See IPython docs: http://ipython.readthedocs.org/en/stable/interactive/magics.html?highlight=magic#magic-reset

How to autosave ipython notebook

Does anyone know if there's an option (or a suggested hack) to make IPython notebooks save automatically before executing a cell?
Many times I've been working on something without saving for quite some time, then I execute a stupid command that prints so much crap to the console that my browser becomes unresponsive, leading to me losing all my work.
A timed autosave might also do the trick.
The development version has that feature fully implemented. Install it by following the instructions on the ipython github.
Instructions form the repo:
If you want to hack on certain parts, e.g. the IPython notebook, in a
clean environment (such as a virtualenv) you can use pip to grab the
necessary dependencies quickly:
$ git clone --recursive https://github.com/ipython/ipython.git
$ cd ipython
$ pip install -e ".[notebook]"
This installs the necessary
packages and symlinks IPython into your current environment so that
you can work on your local repo copy and run it from anywhere:
$ ipython notebook
Updating iPython Notebook solved several problems I had with iPython Notebook; for instance, it autosaves, or auto-correction is disabled, or %matplotlib inline works now (before updating, I had to use --pylab inline in the command line when I was running $ipython notebook).
As I use coda on my mac, I updated iPython Notebook via conda:
$conda update ipython
You could simply set a lower interval for autosave feature using the following magic command:
%autosave 60
in order to save automatically your notebook every 60 seconds.

How to use ipython ZMQ-based console by default

I often use ipython with vim (vim-ipython plugin). It connects to ipython via ZMQ, so I need to run ipython console. I don't see any purpose to not use ipython console even if I don't use ZMQ features, so I want ipython to start ZMQ-based console without typing console. I know, that this problem could be partly solved with bash aliases, but I think that I would have problems with launching qtconsole or notebook.
We don't provide any way to make ipython console the default, and we're probably not about to, as it gets much less field testing than the regular terminal IPython. I'd recommend you just alias another convenient name to it.

sbt clear screen command

I am learning sbt build tool. I use interpreted sbt. I run lot of commands and get lot of output which clutters up the screen.
The question is any command for clear screen for sbt interpretive console , like cls in DOS shell or clear in bash
My googling skill did not helped
update : i am using console2 with windows power shell
In bash you should be able to use Ctrl+L, on OSX you can also use Cmd+K.
This specifically helps when you're doing something in continuous mode, ala `compile:
maxErrors := 5
triggeredMessage := Watched.clearWhenTriggered
This works as of 0.13.7. The second line clears the screen before each command runs. The first line limits the number of errors. With this config, you only ever have one screen full of errors to work through. Obviously could adjust maxErrors depending on your sbt window.
Sbt will load ~/.sbt/1.0/build.sbt as global settings.
commands += Command.command("cls") { state =>
print("\033c")
state
}
Then you can run any commands with cls. For example:
~;cls;compile
~;cls;testOnly