Skip to main content

A versatile Jupyter cell magic that allows running a cell with any command line utility.

Project description

AnyCmd

    Do the provided cell magics not quite fit your needs? AnyCmd is a versatile Jupyter cell magic that allows you to run a cell with any command line utility. Simply specify the command you want to run as arguments after the magic. Access the contents of the cell as a file using the literal string "%FILE" or "%FILE.someExtension"
    By default, the command specified after the magic will be run from a temporary working directory. However, you may use -d/--dir to chdir into a custom directory before running the cell command. Use "-d ." to run it in the current working directory.
    Use -i/--inplace if you would like to write the cell contents temp files in the specified working directory, rather than the temporary directory (has no effect without --dir). This may help with compilers that reference libraries in the same directory, for instance.
    Use "-p/--print" to print command output live, instead of outputting to the cell. This may improve readability, and make it easier to debug long-running commands.
    -l/--lines adds a newline character before the cell contents in the temporary file to offset the first line taken up by the cell magic. This may help prevent interpreter error messages that reference a line number one line before the actual error when jupyter line numbers are enabled.

You may install this package via PyPi:

!pip install anycmd-jupyter-magic
%load_ext anycmd

Example (compiling and running c++):


%%any -p -l -- clang++ -O3 %FILE.cpp -o file && ./file

#include <iostream>  
using namespace std;  
int main(int argc, const char** argv) {  
  cout << "Hello World\n";  
}  

Result:
Hello World

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

anycmd-jupyter-magic-0.1.3.tar.gz (5.3 kB view details)

Uploaded Source

File details

Details for the file anycmd-jupyter-magic-0.1.3.tar.gz.

File metadata

  • Download URL: anycmd-jupyter-magic-0.1.3.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for anycmd-jupyter-magic-0.1.3.tar.gz
Algorithm Hash digest
SHA256 e8989e861b5a0882c7626fe7b56d538a5d0ca0ca3c5f86b6a9d754d4daca58e1
MD5 a856ce04e8b4f7edf1daafaf962c4224
BLAKE2b-256 d7bb6fb2962c0745c4cd0e059fc96f94635ae1a55f5816dab87cbcb86289ae2a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page