Live data from Hacker News

Xonsh: Python-powered, cross-platform, Unix-gazing shell

xon.sh

41–50 of 97 posts

Re: Xonsh: Python-powered, cross-platform, Unix-gazing shell

#42
post #36
post #19

Earlier quoted context omitted.

It means that it is not fully sh-lang compatible (i.e. a true unix shell), but is as compatible as reasonably achievable while maintaining full compatibility with Python 3.

What sort of capabilities does sh-lang provide that Python cannot? Does sh-lang have some sort of privileged access to the OS not available to Python?

He means it's not POSIX-compliant. You can't replace /bin/sh with it and expect stuff to work.

Re: Xonsh: Python-powered, cross-platform, Unix-gazing shell

#44
Note, while you should feel free to use any interactive shell you like, you should only write scripts with POSIX sh. A friend of mine is working on another shell, mrsh, which aims to be POSIX-sh-as-a-library and will serve as the basis for building more sophisticated interactive shells on a POSIX base, if anyone is interested in that:

https://git.sr.ht/~emersion/mrsh

Re: Xonsh: Python-powered, cross-platform, Unix-gazing shell

#45

Anybody switched from fish shell to this? What is your experience? I like fish shell because the preconfiguration is pretty good. Same on xon.sh or config hell like zsh?

Ugh. I have so many conflicting opinions on this question.

So, Xonsh is superior in the manipulation of shell objects. I felt super at home changing the shell prompt and configuring/extending the default Xonsh functionality. This is all because it's literally a superset of Python.

Fish however, blows Xonsh out of the water when it comes to autocomplete and navigation. Xonsh's autocomplete / suggestions are very very weak in comparison to fish's. You feel bogged down when trying to navigate directories quickly with Xonsh. I wrote a small blog post about it here [0]

There was a piece of software I was trying to write that was meant to be Xonsh but with Fish's autocomplete [1], but really didn't succeed and have slightly abandoned it for the time being. But maybe I'll pick it back up soon.

[0] https://ezb.io/thoughts/programming/mollusk/mollusk_1.html

[1] https://github.com/enricozb/mollusk

Re: Xonsh: Python-powered, cross-platform, Unix-gazing shell

#46
Awesome that it uses repl.it embed. But leaves so much to be desired. I'm the repl.it ceo and have a few things in the works to make this experience so much better:

1. caching pypi installs between instances 2. using a real terminal emulator which means you'll get to use xon.sh (or any shell) in it's full glory

Still a nice surprise to see repl.it embedded in the wild.

Re: Xonsh: Python-powered, cross-platform, Unix-gazing shell

#47

Note, while you should feel free to use any interactive shell you like, you should only write scripts with POSIX sh. A friend of mine is working on another shell, mrsh, which aims to be POSIX-sh-as-a-library and will serve as the basis for building more sophisticated interactive shells on a POSIX base, if anyone is interested in that: https://git.sr.ht/~emersion/mrsh

I have a better idea: don't write scripts in shell language at all. They're terrible at basically everything. Instead, use a scripting language, like Python, Ruby, or Perl. They have control flow that make sense, are not riddled with subtle bugs due to legacy and compatibility reasons, and are simply easier to wield.

Shell scripts are a maintenance nightmare - even when used for personal scripts. They should be avoided at all cost.

Re: Xonsh: Python-powered, cross-platform, Unix-gazing shell

#48

Note, while you should feel free to use any interactive shell you like, you should only write scripts with POSIX sh. A friend of mine is working on another shell, mrsh, which aims to be POSIX-sh-as-a-library and will serve as the basis for building more sophisticated interactive shells on a POSIX base, if anyone is interested in that: https://git.sr.ht/~emersion/mrsh

I have a better idea: don't write scripts in shell language at all. They're terrible at basically everything. Instead, use a scripting language, like Python, Ruby, or Perl. They have control flow that make sense, are not riddled with subtle bugs due to legacy and compatibility reasons, and are simply easier to wield. Shell scripts are a maintenance nightmare - even when used for personal scripts. They should be avoid…

Nonsense, shell scripts are an incredibly useful tool for a huge variety of use-cases. Shell can be learned like anything else, and it mostly makes sense when it does. More so than I can say for Ruby and Perl, that's for sure!

You should know when to stop and reach for a different tool, but that point isn't before you use shell scripts at all.

Re: Xonsh: Python-powered, cross-platform, Unix-gazing shell

#49
XonSH has been my main shell for a solid two years now. The concept is awesome, but unfortunately it has many flaws.

* Nesting bash and python scripts makes performance terrible compared to using python's subprocess module directly. I have a xonsh script at [0], with an equivalent written in straight bash. The python scripts ends in less than a second, the xonsh script takes ages.

  - As a sub-problem of the above: You can't ctrl+c while in a python function in xonsh. That stinks.
* $(program) returns a string that ends with a \n. In bash, when the program returns a single line, the \n gets stripped.

* It sometimes has problems with certain interactive programs. My last experience with this was sudoedit starting neovim in xonsh caused neovim to crash. XonSH -> Neovim works. Bash -> Sudoedit -> neovim works. but Xonsh -> Sudoedit -> Neovim doesn't.

And that's just a small list of my biggest gripes that I keep running into. I really hope to see the project improve though! Despite all the bugs, it's still my favorite shell by a mile.

[0] https://gist.github.com/roblabla/d82c440908d08c8a232ac483e6b...

Re: Xonsh: Python-powered, cross-platform, Unix-gazing shell

#50

Note, while you should feel free to use any interactive shell you like, you should only write scripts with POSIX sh. A friend of mine is working on another shell, mrsh, which aims to be POSIX-sh-as-a-library and will serve as the basis for building more sophisticated interactive shells on a POSIX base, if anyone is interested in that: https://git.sr.ht/~emersion/mrsh

While that's true for portability (there's obviously reasons why nearly all distros ship with a POSIX sh compatible shell at /bin/sh), for simple tasks on my own system, oftentimes I simply want to get the job done without banging my head against a wall dealing with all the idiosyncrasies of sh. For internal use, I think this project excels for automation and administration tasks. Of course, I probably wouldn't ship anything written in xonsh-python, but I'd totally use it to, say, back up my dotfiles to a git repo automatically.
Post reply on HN