Questions tagged [xonsh]

Xonsh is a Python-powered, cross-platform, Unix-gazing shell language and command prompt.

Xonsh is a Python-powered, cross-platform, Unix-gazing 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. It works on all major systems including Linux, Mac OSX, and Windows. Xonsh is meant for the daily use of experts and novices alike.

See also:

39 questions
7
votes
3 answers

How to write a multi-command alias in xonsh?

In bash and zsh I used to write: alias nb='cd /home/lincoln/Dropbox/nupis/ && jupyter notebook' But in xonsh this returns an error saying that the command was not found. The tutorial's section on aliases says that I should do something…
lincolnfrias
  • 1,983
  • 4
  • 19
  • 29
6
votes
2 answers

Use xonsh to loop over files with ls

I want to use xonsh to bzip several files in a directory. I first attempt this with the following: $ ls table_aa.csv table_amgn.csv table_csco.csv table_esrx.csv table_hal.csv table_jbl.csv table_pcg.csv table_zmh.csv table_aapl.csv …
MRocklin
  • 55,641
  • 23
  • 163
  • 235
5
votes
1 answer

How to pipe In the xonsh shell the output of a Python construct to another command?

In the xonsh shell how can I pipe the output of a Python construct to another command? Desired example: for v in ${...}: print ("{}={}".format(v,${v})) | head In this for v in ... is the Python construct and head is the command I want to pipe its…
halloleo
  • 9,216
  • 13
  • 64
  • 122
4
votes
2 answers

What is the best way in xonsh to loop over the lines of a file?

What is the best way in the xonsh shell to loop over the lines of a text file? (A) At the moment I'm using for l in !(cat file.txt): line = l.strip() # Do something with line... (B) Of course, there is also with open(p'file.txt') as f: …
halloleo
  • 9,216
  • 13
  • 64
  • 122
3
votes
2 answers

Xonsh and rsync command

I have a test folder like this: [20/01/3|2:08:12][samuel@localhost:/tmp] >>> ls test1 1.txt 2.txt 3.txt 4.txt 5.txt in a normal bash/zsh shell this is the output of the command >>> rsync -avz --exclude="2.txt" --dry-run test1/ test2/ sending…
3
votes
0 answers

How can I use xonsh with edit-command-line in ZSH?

I'd like to open an editor buffer in ZSH using edit-command-line and have the contents of the buffer executed by xonsh. Is it possible to do this cleanly? The edit-command-line command in ZSH lets you edit a command line using your editor, which can…
emchristiansen
  • 3,550
  • 3
  • 26
  • 40
3
votes
1 answer

How to use {env_name} conditionally in a xonsh prompt

In the xonsh shell how can I use the name of the virtual environment I'm use as a condition in the definition of $PROMPT? (More in detail: I have a virtual environment called 'xonsh' for the xonsh shell itself, but I do not want this venv to be…
halloleo
  • 9,216
  • 13
  • 64
  • 122
3
votes
2 answers

In xonsh how can I receive from a pipe to a python expression?

In the xonsh shell how can I receive from a pipe to a python expression? Example with a find command as pipe provider: find $WORKON_HOME -name pyvenv.cfg -print | for p in : $(ls -dl @(p)) The for p in : is obviously pseudo code. What…
halloleo
  • 9,216
  • 13
  • 64
  • 122
3
votes
3 answers

List comprehension with xonsh

I am still new to this, but is it possible to execute multiple commands in xonsh using a list-comprehension syntax? I would expect the following to create five files file00 to file04, but it errors instead: $ [@(['touch', 'file%02d' % i]) for i in…
Jonathan H
  • 7,591
  • 5
  • 47
  • 80
2
votes
1 answer

Piping an alias hangs xonsh

I have the following alias: aliases['test'] = 'grep @($args) somefile' It works perfectly fine, however when I try piping it to anything, e.g.: $ test smth | head it still prints out the full output of test smth ignoring the head command, and then…
confucious
  • 121
  • 2
2
votes
1 answer

Why does `stty cols 40` have different effects in the two shells bash and xonsh

I get weird behaviour when using stty in the xonsh shell on Linux/macOS. (Commands do not seem to obey the defined column under xonsh, but they do so under bash.) To get a better understanding of the situation I wrote a little C program which calls…
halloleo
  • 9,216
  • 13
  • 64
  • 122
2
votes
1 answer

How to override built-in command in xonsh?

I'm trying to override 'ls' command to display dotfiles in "dotfiles" directory. Here is my code. def _ls(): if $(pwd).rstrip(os.linesep) == $DOTFILES: ls -Ga else: ls -G aliases['ls'] = _ls This code goes into an endless…
miyashiiii
  • 169
  • 1
  • 1
  • 6
2
votes
1 answer

Activate a Conda Environment within VSCode terminal using Xonsh

Using xonsh as my shell and conda environments, I hit an error within the VSCode terminal when it attempts to activate an environment. This is because VSCode issues the source activate environment command whenever the selected interpreter is a conda…
meatballs
  • 3,917
  • 1
  • 15
  • 19
2
votes
2 answers

infix operator to pipe subprocess output to python function

Can xonsh pipe subprocess output to a python function? int($(ls|wc -l)) > 20 as ls | wc -l | int > 20 I can get close from toolz import pipe pipe($(ls |wc -l),int) > 20 this comes searching ways to port # bash [ $(ls |wc -l ) -gt 20 ] && echo…
Will
  • 1,206
  • 9
  • 22
2
votes
2 answers

Move the eval $(pyenv init -) from zsh to xonsh

How can I move eval "$(pyenv init -)" that is in .zshrc to .xonshrc? What is the syntax in xonsh to do that?
redeemefy
  • 4,521
  • 6
  • 36
  • 51
1
2 3