Xonsh

From wikinotes

Xonsh is kind of neat, and I like it a lot for complex manipulation of files. It meets halfway between shellscript and python


Usage

## example use-case: renaming ripped episodes
from glob import glob
files = glob('*.mkv')
for i in range(len(files)):
    filename = sorted(files)[i]
    mv @(filename) @('SE02E'+ str(i+10).zfill(2))
...

Configuration

~/.xonshrc
config file
http://xon.sh/envvars.html?highlight=vi_mode environment variables that can be set to modify xonsh


vi mode

env VI_MODE=1 xonsh


Aliases

Aliases, in xonsh are stored in a dictionary.

## Example
print( aliases )
>>> 'ls': ['ls', '--color=auto'],
>>> 'grep': ['grep', '--color=auto'],
>>> ...

Setting aliases is done similarly:

aliases['ll'] = ['ls', '-l']


Syntax

Environment

Xonsh works within a few different environments (generally determined by the command first issued on the line, and whether it looks like a command, or a python-command).

@(  )  # within bash-mode, anything executed between these brackets will be from the python env
${  }  # ?

$HOME  # environment variables within python-mode