Comments (9)
Thanks.
from thefuck.
@kballard, the bits about waste, quoting and sourcing instead of evaling are spot-on, but are you sure about history
also including the currently running command?
$ echo foo
foo
$ echo (history | head -n1)
echo foo
Conversely, I find that history[2]
yields the second-to-last command:
$ echo foo
foo
$ echo bar
bar
$ echo $history[2]
echo foo
This is with fish v2.1.1,
from thefuck.
That's odd. My several-months-old dev version of Fish 2.1.1, and my just-installed tip-of-master version of Fish 2.1.2, both behave as I described:
> echo foo
foo
> echo (history | head -n1)
echo (history | head -n1)
> echo foo
foo
> echo bar
bar
> echo $history[2]
echo bar
from thefuck.
I can see mentions of $history[1]
in various threads:
Where ridiculousfish themself agree that it should return the last
executed command.
May be a difference in arch/plugins/etc? For comparison, this is Fish
v2.1.1 installed with Homebrew on OSX.
from thefuck.
I'm also running OS X.
I'm wondering now if maybe master
has a bug where it's adding the command to history too eagerly. Note that master
actually has a lot of changes from 2.1.2 (I believe master
has been considered to be equivalent to at least 2.2 for a long time, and 2.1.1 / 2.1.2 were just minor changes from 2.1.0).
Given the state of things at the moment, I guess the install instructions should be changed to use $history[1]
instead of $history[2]
until this can be tracked down.
from thefuck.
Yep, the commit referenced in that issue fish-shell/fish-shell#984 (aa1b065dd1c03f7c0867d002badcf0dc88feb3c4) is the culprit. Building fish from before that commit expands $history[1]
to the previous command instead of the current one. That commit is only on master
, it's not in v2.1.2.
from thefuck.
Here is a repeatable test on a completely pristine machine from instantcloud.io with even older fish 2.1.0:
from thefuck.
I've filed fish-shell/fish-shell#2028 about this issue.
In the meantime, @nvbn, it seems clear that the instructions need to be changed to say $history[1]
instead of $history[2]
(but other than that, the new function is better than the old).
from thefuck.
I agree, if not only for the quoting and eval issues.
Performance is also (predictably) way better:
$ time -p fish -c 'for a in (seq 1000); history | head -n1 > /dev/null; end'
real 3.25
user 2.06
sys 1.58
$ time -p fish -c 'for a in (seq 1000); echo $history[1] > /dev/null; end'
real 1.32
user 0.65
sys 0.84
from thefuck.
Related Issues (20)
- [WARN] Output log isn't specified when "instant mode" turned on
- `<editor> <bash-path> +1 && puthon` suggestion instead of `python` HOT 4
- OpenSSL 1.1 End of Life HOT 4
- subprocess.run does not work inside side_effect
- ModuleNotFoundError: No module named 'imp' (python 3.12.0) HOT 3
- Not fully compatible with python 3.12.0 yet. HOT 1
- [Suggestion] Correct pip remove, delete to uninstall
- How about adding a typo correction rule related to 'nvm'?
- Request for adding Pull Request Template
- I can't run thefuck on powershell HOT 1
- Unhandled `apt` "Packages were downgraded and -y was used without --allow-downgrades" error
- Support for Windows CMD HOT 4
- /.zshrc:1: command not found: thefuck HOT 3
- Shell slow to start with `eval "$(thefuck --alias)"`, workaround is a lazy loading trick HOT 1
- Fuck command does not work on Alacritty (Mint) HOT 1
- When using Windows Terminal to ssh to a remote server with Zsh/OMZ/powerlevel10k, and instant mode in ~/.zshrc, sometimes crash on start up.
- Help for installing on windows HOT 4
- ModuleNotFoundError: No module named 'imp' when running 'fuck' HOT 10
- Error in building development container
- Feature Request: Instant-Interactive Mode + Zoxide with FZF HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from thefuck.