by BeetleB · 2y ago · 0 comments
If you love Bash scripting, xonsh isn't for you. For everyone else, xonsh is.
The only serious headache I have with it - very poor compatibility with fzf. None of the main developers use fzf so they don't feel the pain. As an example, doing:
git checkout $(git branch | fzf)
doesn't work because the result of the fzf command has a newline. So you need something like @$(...).What I really want is to swap the default TAB autocompletion with an fzf selection, and there's no easy way to do it. You have to get deep into the underlying prompt_toolkit library and do a lot of surgery. It's doable, but I haven't had the time.
However, I feel like your criticism re fzf is not really fair, because I run into this with other tools quite often. So often in fact that it took me only a second to convert your command in my head to this:
git checkout @($(git branch |fzf).strip())And the history of fzf support in xonsh has been much worse. Until recently, the command you wrote was not guaranteed to work, because doing anything with fzf under $() would (seemingly) randomly not capture the results of fzf (it would often be any empty string). This was a long standing issue for years, until we finally had a user who knew the xonsh internals well enough to go and debug it.
So people like me had to find alternative ways to use fzf (e.g. attach it to a custom keybinding for specific tasks). I had to modify xontrib-fzf-widgets (because that itself failed often).
Take a look at these issues:
https://github.com/xonsh/xonsh/issues/5190
https://github.com/xonsh/xonsh/issues/5189
https://github.com/xonsh/xonsh/issues/2404 (note that it took 4 years to fix this - and until then your command would not reliably work).
https://github.com/xonsh/xonsh/issues/3548
https://github.com/xonsh/xonsh/issues/3035 (probably a clone of 2404).
The reality is: If people want to use fzf in xonsh the way they do in bash/zsh, they will be in for a lot of pain.