__xonsh_history__ has been deprecated
Opened this issue · 3 comments
Hi,
Given the deprecation warning, line 5 should be replaced with
last_command = __xonsh__.history.__getitem__(-1)
but even then I can't get this to work.
The only working version I've found is (essentially the same as this one)
$THEFUCK_REQUIRE_CONFIRMATION=False
aliases['fuck'] = lambda args, stdin=None: execx($(thefuck $(history -1)))
I can't figure out a working implementation when confirmation active.
I've updated the history call to remove the deprecation warning and altered the function to use history properly, but it's still not working. I don't have time to look into this any further right now.
Yes I know this.
Can I ask if your original version worked before when $THEFUCK_REQUIRE_CONFIRMATION=True
? i.e. when asked to confirm the suggested corrected cmd? My guess is that the prompt would not show, since $(...)
swallows some stdout (just type $(thefuck ppython)
and you'll see that the confirmation prompt does not display, but thefuck
is waiting for a response)
If not, perhaps just use
$THEFUCK_REQUIRE_CONFIRMATION=False
aliases['fuck'] = lambda args, stdin=None: execx($(thefuck $(history -1)))
for now?
@deeuu This seems to work with requiring confirmation:
$ $THEFUCK_REQUIRE_CONFIRMATION
True
$ aliases["fuk"] = lambda args, stdin=None: execx($(thefuck @(__xonsh__.history[-1].cmd)))
$ puthon
Traceback (Most recent call last):
XonshError: xonsh: subprocess mode: command not found: puthon
Did you mean one of the following?
python: Command (python)
python3: Command (python3)
python2: Command (python2)
pythonw: Command (pythonw)
$ fuk
python [enter/↑/↓/ctrl+c]
Python 3.10.2 (main, Feb 15 2022, 16:15:17) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
I'm not sure if this solution can be worked into this xontrib or not, though. I'm getting syntax errors, presumably because the xontrib expects python code and not xonsh code?