Upgrade to Pro — share decks privately, control downloads, hide ads and more …

2016 - Matthias Bussonnier - Xonsh – put some Python in your Shell

PyBay
August 20, 2016
87

2016 - Matthias Bussonnier - Xonsh – put some Python in your Shell

Description
Xonsh is a Python-ish, BASHwards-looking shell language and command prompt. The language is a superset of Python 3.4+ with additional support for the best parts of shells that you are used to, such as Bash, zsh, fish, and IPython. It works on all major systems including Linux, Mac OSX, and Windows. Xonsh is meant for the daily use of experts and novices alike.

Abstract
Programmers spend their time at a command line interface often sticking to
default shell. A lot of progress have been made for the friendliness,
usability, extensibility of shell. We thus introduce Xonsh which attempt to
bring the command line shell to the 21st century.

Xonsh is general purpose shell that combines Python and the best features of
Bash, zsh, IPython and fish. Written in Python and relying only the standard
library and PLY, the xonsh language is a strict superset of Python that
compiles to a Python AST. The shell can provides exciting features: rich
history, tab completion from bash and man pages, syntax highlighting,
auto-suggestion, foreign-function aliases and more!

Wether you are a novice who is looking to use use the command line, or an
Python expert Xonsh is made for you.

Because xonsh is Python, it automatically has all the available python
ecosystem at your fingertip. Xonsh makes meshing and intertwining python code
with command-line interfaces as seamless as possible. Have you ever wanted to
use regular expressions to glob files? No problem! Ever wanted to curl a remote
resource right into `json.loads()`? Now you can. Do you not want to leave the
command line to use pandas, NLTK or add two numbers together? No big deal.

The xonsh homepage is at https://xon.sh

Bio
I am a PostDoc at UC Berkeley Institute for Data science, and have been a core Developer of IPython and Jupyter for a couple of years. With a background in Physics I spend most of my time developing tools for the scientific community and for education as well as promoting Python 3.

https://youtu.be/lopI4HkA9rE

PyBay

August 20, 2016
Tweet

Transcript

  1. Xonsh Xonsh is a Python-ish, BASHwards-looking shell language and command

    prompt. The language is a superset of Python 3.4+ with additional shell primitives that you are used to from Bash and IPython. Anthony Scopatz @scopatz By
  2. http://xon.sh $ pip install xonsh # Py3.4+ $ conda config

    ––add channels conda-forge $ conda install xonsh github://xonsh/xonsh/ v0.4.5
  3. How do you pronounce it ? ★ The wrong way

    ★ Carefully ★ Differently each time ★ I only write it I, will go with Xonsh. Where Χ it’s not a X but a greek uppercase Χ*, like in LaTeΧ. You are free[as in speech] to disagree. It’s extremely important for puns, we like puns, our Xontributor, or Xonfiguration system, and the Xonshtant questions from various Xorner of the Xontinent, and have a Xonshistant pronounshiation**. *Your font may render X and Χ differently, or not. ** Yesh autoxorrect, jheese are shpelled xorrectly.
  4. Why ? Because we can Not to bash on other

    shell, but I can’t remember 1/2 of the loop and conditions syntax. Get the Python ecosystem at our finger tips. Get the other 1/2 of the shell syntax in python. + + https://www.youtube.com/watch?v=uaje5I22kgE Anthony Scopatz, PyCon 2016, Xonsh
  5. Do everything you are always told not to do. Reminder

    the next 2 talks are: A Guide to Bad Programming – Paul Bailey Evil Hacks in Service of Marginally Improved Syntax: "Compile-Time" Python Programming – Scott Sanderson I think there is a theme here...
  6. “Is that the shell that no-one uses ?” - David

    Powell, @dontusethiscode – SciPy 2016 It is my everyday shell
  7. Works out of the box • No dependencies required. •

    Uses Ply to lex/parse; Python to compile/execute • Custom Tokenizer, and Ast Transform step. • Better with a few optional ones • prompt_toolkit • Pygments... • 21st century shell • Colors, Multiline edition, Autocompletion, Autosuggestion, introspection... inspired from OhMyZsh, Fish... aka batteries included
  8. The (risky) Demo (Me right now in my head) Please

    ask questions so that I can take breaks, and make sure I’m clear ! This demo may contain gotchas, references, easter eggs, bugs, and omissions; let’s say it’s to see if you are following.
  9. That was the tip of the iceberg • Captured and

    uncaptured subprocess : • $[]and ![] • $() and !() • help (object?) and super help (object??) like IPython. • Customizing Prompt with functions... • Asynchronous prompt • File formats (`.xsh`) • have an import hook. • Compile to python AST !
  10. Richer data structures • Env variable are strings/lists/bool • Rich

    history: • Sessions, • JSON • return status, timestamp Xontrib • Xonsh Extensions • Package Manager (pip, conda) • Completions • Input editing... • Speed type for 30min...
  11. And More This Context manager Can get these as strings

    ! (xontrib load distributed) (anyone interested in having macro within the Python language?)