Comments (5)
So the problem is that fish doesn't know which arguments are files and which aren't (though paths with a /
could be picked up), and whether the argument should exist or shouldn't. For example, mv existing nonexisting
is a perfectly reasonable command to suggest, but mv nonexisting existing
isn't.
Without adding special knowledge of particular commands I'm not sure if this would be possible. I thought we had considered and rejected the idea of programmable suggestions (as opposed to completions) in the past, but I can't find any discussion with a brief search.
from fish-shell.
I think instead of integrating into fish, perhaps a plugin system would be better to maniplulate the
way this is done. This way users can modify to thier liking. I'm not sure, I'm not familar with plugins.
Another thing to consider is how much would this affect speed. Suggestions are a fraction of a second
so every ms counts.
from fish-shell.
As at the time that the history is retrieved it is not possible to know if an argument is a path that previously existed or not, IMHO the correct way to do this (if we are to do this at all, read on) would be for the history file to include information about which arguments were paths (e.g. a "column" paths
that contains something like 1,3,5
indicating that arguments 1, 3, and 5 are/were valid paths at the time the command was executed. At the time of history retrieval, it would be possible to see if these paths existed or not before showing the history entry.
This would also handle the case where commands are expected to take paths that don't yet exist (e.g. touch README.md
should be suggested when README.md
doesn't already exist because the command creates it).
But I'm not sure it is a universally good approach because there's absolutely no rule that says retrieved history lines are executed as-is. If I were to venture a guess, I would say that well over 50% of the time when I am retrieving something from history that involves a path, I am going to edit it to reflect my current needs before execution. If I have a complicated command that wraps over 12 lines that took me 5 minutes to come up with but the payload of the input file argument -i foo.in
doesn't exist, I still absolutely want that history suggestion, I'm just going to complete from history then edit the command to change -i foo.in
to -i bar.in
instead.
(This applies for autosuggestions or history search suggestions equally.)
It might still be useful for the history file to include that information for other purposes, but not so that the autosuggestion can be hidden.
from fish-shell.
would be for the history file to include information about which arguments were paths (e.g. a "column" paths that contains something like 1,3,5 indicating that arguments 1, 3, and 5 are/were valid paths at the time the command was executed
fish already does this.
For example If I remove a directory, my history file will have
- cmd: rmdir some.path
when: 1713298898
paths:
- some.path
and rmdir some.path
will no longer be autosuggested until I recreate the directory.
Note sure why it's not working for @rickalex21. Can you check if your history file is missing the paths
entry with /mnt/an-old-file-I-deleted-last-year
?
If I have a complicated command that wraps over 12 lines that took me 5 minutes to come up with but the payload of the input file argument -i foo.in doesn't exist, I still absolutely want that history suggestion
I use multiline commands in that case so I always need to use history search as of today
from fish-shell.
fish already does this.
I thought that was the case but doubted myself from the conversation!
from fish-shell.
Related Issues (20)
- Inconsistanc behavior when changing a symlinked folder in the current working directory HOT 1
- [Suggestion] Do not include final slash on path completion for symlinks to directories HOT 2
- `commandline` seems to lose line break characters HOT 2
- consider making `history-prefix-search-backward` and forward don't change cursor position HOT 1
- [Feature] [vi-mode] Support command count HOT 2
- cd fails for directory without read permission, displays `Permission denied` HOT 4
- `history merge` has mmap issues with certain remote filesystems HOT 8
- WARNING: 'envvar' reference target not found when running 'sphinx-build' to build docs HOT 3
- Using `read` in script cause panic
- Parse and even freeze issue on pasting large input HOT 2
- Error with scp completion HOT 6
- How to have completions for a command match that of an empty command line? HOT 2
- A strange escape sequence "^[[O"
- bind: cannot parse key '▒▒' HOT 2
- Getting the next release ready HOT 7
- Metaprogramming in fish question HOT 4
- Some konsole input sequences aren't recognized
- Ensure that required flag is passed to script, not just that it has a value when provided HOT 2
- Make `fish_opt` option optional HOT 1
- Fishshell PPA use weak Algorithm HOT 3
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 fish-shell.