21 ms·
Xonsh: Python-powered, cross-platform, Unix-gazing shell
- di 8y agoXonsh is awesome! Execute Python directly on the command line?! Sign me up! Sadly it doesn't play well with all of my three thousand various vim plugins, so I still haven't been able to use it as my daily shell. Hopefully someday!
- devnonymous 8y agoIf vim plugins are the only thing holding you back you might want to consider just adding set shell=/path/to/bash to your vimrc and see how you get along.
- djsumdog 8y agoI current have that set in vim when using fish shell.
- scopatz 8y agoCan you please open an issue detailing the problem? https://github.com/xonsh/xonsh/issues https://github.com/xonsh/xonsh/issues I'd love to help make this work. I believe that the emacs folks have something that works for them
- mlevental 8y agolol do you really have 3000 vim plugins?
- sciurus 8y agoA better URL is https://xon.sh/ https://xon.sh/
- devnonymous 8y agoAlso previous https://hn.algolia.com/?query=xonsh%20&sort=byPopularity&prefix&page=0&dateRange=all&type=story https://hn.algolia.com/?query=xonsh%20&sort=byPopularity&pre...
- scrollaway 8y agoNote a couple of those use the .org tld. That is not a legitimate site, do not use that. Ref: https://github.com/xonsh/xonsh/issues/1077 https://github.com/xonsh/xonsh/issues/1077
- sctb 8y agoThanks, we've updated the link from https://github.com/xonsh/xonsh https://github.com/xonsh/xonsh.
- meowface 8y agoSounds amazing. If it ever gets a relatively active plugin ecosystem like zsh or fish, I'd definitely switch. Being able to write shell functions in Python would be very refreshing. If they want bigger adoption, dedicating a bunch of people who do nothing but port zsh and fish plugins would probably go a long way.
- scopatz 8y agoWe have a couple of dozen very handy plugins available already (powerline, conda support, etc) and are always looking for more!
- BeetleB 8y agoCurious: What zsh/fish plugins do you think are missing from xonsh?
- hayden592 8y agoIs there a plug-in for fzf searching your command history?
- BeetleB 8y agoSince I've not used fzf, I don't know how good this is, but there is a "xontrib" (i.e. plugin) for some of fzf capabilities in Xonsh: https://github.com/shahinism/xontrib-fzf-widgets https://github.com/shahinism/xontrib-fzf-widgets You can get a list of (known) xontribs here: https://xon.sh/xontribs.html https://xon.sh/xontribs.html
- deleted 8y ago[deleted]
- deleted 8y ago[deleted]
- ilyagr 8y agoSounds neat. However, the fact that `ls -l` either subtracts two numbers or calls a shell command, depending on whether there exist valriables 'ls' and 'l' in the Pythom environment, looks like a security nightmare waiting to happen. What if I create a python object 'ls' deep inside a script that does Evil when subtracted from?
- scopatz 8y agoPython variables are scoped as normal, so the security story for xonsh is the same as for Python. We are always open to suggestions and PRs to harden the code base as needed.
- bitwize 8y agoIt could be worse. It could be a Wolfram shell, in which case 'ls -l' would return 'l(s - 1)'.
- Norther 8y agoWhat's stopping a Bash script from doing something similar? You could alias ls to a malicious actor for example.
- kbd 8y agoWell, aliases are ignored in scripts usually, but you could prepend something to the PATH so your script/exe gets found before built-ins, no? I agree, I don't see that this is a problem unique to Xonsh.
- djsumdog 8y agoI mean, that's the underlying concept behind the fork bomb isn't it? With ":() { :|:&}" you're essentially redefining the bash noop to be a function that pipes/forks itself into itself recursively. It's the reason './' is not in the default path as well (so you can't place an 'ls' in your home directory and have the admin run your command instead of the real ls).
- m45t3r 8y agoYou
- pyedpiper 8y agoLove xonsh!! And gets more and more stable with every release. it's the shell I always wanted. And cross platform to boot. Alias ls -l? aliases['ls'] = "ls -l" Oops no I don't want that any more: del aliases['ls'] Add dir to path: $PATH.append('/foo/bar') Just the awesome python syntax sugar and readbility right in the May I never right a bash script again.
- stochastic_monk 8y agodel aliases[‘ls’] seems like a step back from unalias ls.
- scopatz 8y agoSure, but aliases is a real mapping object that you can access and manipulate
- BeetleB 8y agoOnly if you're coming from a different shell. For me, it's easier to remember that aliases acts like a dictionary, so I can treat it like any other dictionary. With "unalias" I have to remember the command. As I rarely use unalias (a few times over a period of years), I typically have to search the web on how to remove an alias. And if it really bothers you, I'm pretty sure it's trivial to define an unalias function in Xonsh that will act as you expect (without needing parentheses). It's part of the beauty of Xonsh - many such commands you're used to can be brought into it by writing fairly simple Python code.
- marmaduke 8y agono the point is that if you know Python, you know how to do it without looking it up
- Cyph0n 8y ago> May I never right a bash script again. Bash is not going away any time soon, for better or worse..
- blt 8y agowhat does the "-gazing" suffix mean?
- scopatz 8y agoIt 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.
- bmer 8y agoWhat 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?
- TheDong 8y agoposix sh mandates certain constructs work. For example: x=foo; x=${x%o}; echo $x # prints 'fo' Supporting that is non-trivial in python. There's no quotes around the strings, '%' is kinda weird there, etc. Of course, in python you can just say: x="foo"; x=x[0:2] ... but those are not compatible with each other. colon does different things in posix sh than python, and it would be quite complicated to reconcile it. I'll also point out the parent poster, when they wrote "sh-lang", meant "the superset of posix-sh that zsh/bash users expect", because at this point quite a few bash features are expected to work in most sh-like shells. Naturally, both xonsh and sh (and all other shells pretty much) are turing complete and can execute programs, which makes them all equally capable. Having equivalent capabilities does not mean things are compatible though. I recommend reading up on what a POSIX shell is, and then reading fish and xonsh's arguments why they're not POSIX compliant (spread through various locations)
- t-3 8y agoHe means it's not POSIX-compliant. You can't replace /bin/sh with it and expect stuff to work.
- fiatjaf 8y agoYour best option for designing scripts that must talk to other programs and also do what you want (as bash won't).
- 0x8BADF00D 8y agoI tested it out on mobile, I like the ability to script with it in a HLL like Python, will give it a try for sure on desktop.
- j2kun 8y agoThe demo on the front page raises an error when running "ls"
- protomikron 8y agoSo I just tried it and it's surprisingly usable (I am always somehow skeptical about non-Bash shells). It even takes into account my ~/.inputrc, so kudos. However, I struggled a little bit with $ time ls where the output of `time` is mangled in-between the output of `ls` - this may be related to STDOUT and STDERR buffering?
- hathawsh 8y agoThis looks very promising: >>> ls `a(a+|b+)a` aaa aba abba Regex filename matching triggered by backticks. I like that design choice!
- h1d 8y agoGood that they didn't choose slash delimiters.
- therealmarv 8y agoAnybody 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?
- anreekoh 8y agoUgh. 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 https://ezb.io/thoughts/programming/mollusk/mollusk_1.html [1] https://github.com/enricozb/mollusk https://github.com/enricozb/mollusk
- faho 8y ago>I wrote a small blog post about it here [0] I work on fish, and one of the things that the upcoming fish 3.0 contains is a new `math` builtin (previously we shipped a function of that name that just wrapped `bc`). So your math expressions here are interesting to me, because they work in math (with the caveat that `` is still the symbol for globbing, so it needs to be quoted or escaped): $ math 0x113e8b3 18081971 $ math '719 * 114679' 82454201 Adding them to the core syntax carries backward-compatibility questions and also isn't really what fish is about.
- anreekoh 8y agoThe benefits of xonsh are more than just the quick math, but I'm glad fish is getting something like this. I've had a Python script that does math for me, something like this [0] I do think something like a Python shell is the best solution (for me), however, simply because of the ease of use with modifying the current state of the shell (environment variables, etc). [0] https://gist.github.com/wackywendell/919042f19ab6932447df https://gist.github.com/wackywendell/919042f19ab6932447df
- brazzledazzle 8y agoThis seems really cool. Trying it out with repl.it was really neat. One thing I'd do is add PowerShell to the comparison table.
- pen2l 8y agoI love the concept, and I am generally happy with how it works. I think it should catch on. Except the damned name. Come on guys, there are already enough crazily named things out there, you didn't have to be another one :(
- programmarchy 8y agoYou know it's a pun on conch shell, right? ;-)
- dguaraglia 8y agoWouldn't it make more sense if it was called "Ponsh" then? Heck, now that I think of it, "posh" would be a perfect name for a Python-powered shell.
- gricardo99 8y agoPerhaps “pysh”, although that has some negative connotations.
- jodrellblank 8y agoPowerShell went for "pwsh" instead of "posh" because posh is already a name of a shell - https://www.commandlinux.com/man-page/man1/posh.1.html https://www.commandlinux.com/man-page/man1/posh.1.html
- dguaraglia 8y agoDamn. Maybe go for "Posh Again" instead, in the bash tradition :)
- pen2l 8y agoThat makes it worse. Too many names are based on insider-jokes, too many of it just scares away noobies. posh, I agree, with the other poster, is a fabulous name for something like this
- dec0dedab0de 8y agoI have wanted something like this for a while. I can't wait to try it out
- Sir_Cmpwn 8y agoNote, 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 https://git.sr.ht/~emersion/mrsh
- roblabla 8y agoI 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.
- Sir_Cmpwn 8y agoNonsense, 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.
- cookiecaper 8y agoRuby and Python are pretty unwieldy for the kind of situations that are well-suited to shell scripts. It's a pain to spawn a command, a pain to make sure you get the process's output in the right place, and just far more overhead than necessary. I agree, however, that classic shells are worse, because they lack many of the niceties expected in modern languages and have opaque, sensitive syntax. fish shell has made me pretty happy. It's a great middle ground. It makes no pretense at POSIX compatibility. Truly a shell for the 90s.
- h1d 8y agoAgreed. There's definitely a good demand for a modern shell scripting language but fish is an existing solution that is saner than bash/zsh. I don't use fish as a shell but for shell scripts only as it acted a bit weird on me, though it's possible I didn't search enough but zsh can cover pretty much all I want from fish with plugins.
- amasad 8y agoAwesome 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.
- roblabla 8y agoXonSH 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/d82c440908d08c8a232ac483e6be7202 https://gist.github.com/roblabla/d82c440908d08c8a232ac483e6b...
- jijojv 8y agoFiled https://github.com/xonsh/xonsh/issues/2815 https://github.com/xonsh/xonsh/issues/2815 $ yes test | tee /tmp/xonsh.log $ wc -l /tmp/xonsh.log 208076 /tmp/xonsh.log bummer ctrl+c does eventually work several seconds later (about 10x slower) which is still a deal breaker as it could be disastrous when you need to abort a mistyped command or for scripts that give you a few seconds to abort before it does something the destructive step...
- austinpray 8y agoI use zsh daily but type `xonsh` any time I do something in the shell that would normally require a google. “Uh ok so I have this JSON file. When I pipe this to `jq` I forget: to pivot an array of objects to an object keyed by array[x].id is it like `to_entries` then chain it to `map`? Uhh let’s look at the docs...” However in Python I can write that function at the speed of thought. It may be a couple more lines of code but I’m also 100% confident in the output. Like I understand some people can legitimately program in bash [0]. But I just can’t bring myself to practice. Why would anyone inflict this language on themselves? [0] https://github.com/docker-library/python/blob/master/update.sh https://github.com/docker-library/python/blob/master/update....
- xiaq 8y agoShameless plug: if you like modern shells that you can use to do real programming, try Elvish too: https://elv.sh https://elv.sh
- h1d 8y agoI've always been thinking there can be a better shell like having a split pane to show the list of command options with descriptions as you start typing in the command or show snippets of a preset of command options that does task X as in search by use case instead of going to stackoverflow every time. I think the way people handle shell, as in typing commands on a dumb shell, has not improved for decades and I don't know why. The only thing they help without explicitly asking is with autocompletion.
- djsumdog 8y agoI really like fish. It doesn't open a split pane, but it can show lists of command switches in tab complete based on man pages. I'm really tempted to try xnosh again as my daily driver for a few weeks though. I like the idea of typing out arbitrary Python code without spawning up IPython. The problems people seem to be stating about xonsh were similar to a lot of the early bugs with Fish, but those things tend to go away once more people start using the shell and reporting issues. I hope we got a whole new generation of usable shells with xonsh, oil and fish.
- vdm 8y ago> a split pane to show the list of command options with descriptions as you start typing https://github.com/mhayashi1120/Emacs-shelldoc https://github.com/mhayashi1120/Emacs-shelldoc
- baddash 8y agowhat exactly does "Unix-gazing" mean?
- BlaXpirit 8y agoSince the start of the project there has been a desire to point out that most things that work in Bash also work in Xonsh. The motto started out as "BASHwards-compatible", but that was unsatisfactory because on one hand it sounds like nonsense, and on the other hand, it's not actually compatible with Bash. So that devolved over time into what we have now. https://github.com/xonsh/xonsh/blame/ebd4e597a3cf063b124e5a54d8a3d7e1a06bcf3a/README.rst#L24 https://github.com/xonsh/xonsh/blame/ebd4e597a3cf063b124e5a5... https://github.com/xonsh/xonsh/blame/82cac3fff08b5cc26e421f143a41c57b55e295c0/README.rst#L21 https://github.com/xonsh/xonsh/blame/82cac3fff08b5cc26e421f1... https://github.com/xonsh/xonsh/blame/bd964ce552282334c8811818bcab30bca18ba493/README.rst#L14 https://github.com/xonsh/xonsh/blame/bd964ce552282334c881181...
- JepZ 8y agoSometimes I wonder which languages people use for system tools. I mean, it is hard enough that C programs (with dynamic linking) break sometimes, but building a shell on top of Python seems like a particualar bad choice to me (similar to building a package manager with python). In my opinion, such few-dependency, high-importance tools should linked statically.
- munchbunny 8y agoI think that anyone who is trying to imagine "the next shell" owes it to themselves to try PowerShell. It's .NET based and very, very different from the sh lineage, but I absolutely love its ability to use objects instead of strings as the underlying transmission medium between "processes". E.g. ls gives you file descriptors, ps gives you process descriptors, etc.
- JepZ 8y agoI was just about to ask if it is available for Linux, but then I saw that the official page advertises its cross-platform properties [1] :D I know about the different concept of Powershell for quite a while now, but since it is MS tech I didn't expect it to be available for Linux. Maybe I will try someday how it feels, but I am sceptical as the thing I like most about POSIX shells is that everything is just text and I wonder how Powershell will integrate with other *nix tools. [1]: https://github.com/powershell/powershell https://github.com/powershell/powershell
- munchbunny 8y agoThe boundary layer between text and object is definitely a weak spot in the abstraction for PowerShell. That's the main reason why I don't consider PowerShell strictly superior. That said, the way the language is designed makes calling into compiled .NET code seamless, which in turn makes doing really sophisticated shell scripting a breeze. When I saw what xonsh was trying to do, I recognized a lot of "PowerShell solves this problem a bit more gracefully".
- xrd 8y ago
- mastrsushi 8y agoA shell scripting language written in a shell scripting language. What could go wrong?