Newest 'xonsh' Questions - Stack Overflow

Questions tagged [xonsh]

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

1
vote
1answer
30 views

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 ...
0
votes
0answers
23 views

How do I display a selection menu in xonsh?

I would like to display a selection menu within the xonsh shell, whenever a certain keycombination is pressed and then run a function using the user's selection from the menu. I've come as far as ...
2
votes
1answer
587 views

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 ...
2
votes
2answers
69 views

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 ...
1
vote
1answer
36 views

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 ...
2
votes
1answer
81 views

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 <stdin>: $(ls -dl @(p)...
2
votes
1answer
82 views

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 ...
1
vote
0answers
52 views

Suspend and send a job to background in VIM 8

I've been trying to use VIM 8.1 with terminal support instead of tmux. It's been going pretty well. One problem I ran into is when I run something from a terminal and I want to sent it to the ...
0
votes
1answer
39 views

Lambda alias in Xon.sh and pipes

Why this peaces of code dont't run the same. samuel@corny ~ $ echo "pippo\npluto\nminnie\ntopolino" | @(lambda a,s=None: s.read()) pippo pluto minnie topolino Second ...
1
vote
1answer
65 views

xonsh: Clash between alias and function with same name

I've this function defined in my xonshrc: def turn_into_alias(func, keep=False): aliases[func.__name__] = func del func It's supposed to convert a function into an alias. But it doesn't work....
3
votes
3answers
82 views

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 ...
1
vote
1answer
36 views

How to write all variables to a JSON file in the python shell

Let's say I have created some variables in the python shell. I want to do something like this: >>> animal="Cat" >>> age="2" >>> weight="3.8" >>> name="Kitty" >&...
0
votes
1answer
23 views

Copy xonsh history to a new computer

With bash I can just copy .bash_history from my old computer to the new one. What should I do in xonsh? The xonsh's history tutorial mentions that the history is stored in the json file indicated ...
2
votes
0answers
107 views

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 ...
1
vote
2answers
260 views

How to run a shell command in a for loop in xonsh?

I would like to use xonsh to execute pandoc on all the md files in a directory. I could use subprocess, but that seems like the kind of thing that would be unnecessary in xonsh. Here's what I've tried ...
2
votes
2answers
453 views

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?
2
votes
1answer
130 views

How to run a Python file in xonsh?

I would like to execute a Python file in xonsh, the same way as %run works in ipython. In particular, I would like all the global variables from the script to be available in xonsh after running the ...
5
votes
1answer
346 views

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 ...
2
votes
2answers
517 views

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 ...