New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Autosuggestions suggest non-existing files #10414
Comments
So the problem is that fish doesn't know which arguments are files and which aren't (though paths with a 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. |
I think instead of integrating into fish, perhaps a plugin system would be better to maniplulate the |
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" This would also handle the case where commands are expected to take paths that don't yet exist (e.g. 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 (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. |
fish already does this. For example If I remove a directory, my history file will have
and Note sure why it's not working for @rickalex21. Can you check if your history file is missing the
I use multiline commands in that case so I always need to use history search as of today |
I thought that was the case but doubted myself from the conversation! |
This is a valid issue that I am trying to fix on my end. Sometime, suggestions just don't make sens, and it's weird edge case that are hard to describe. Most of the time, suggestions are ok. But I do agree with @mqudsi that I believe that fish's autosuggestion is a core feature. I don't want to have AI add better suggestion, but making it smarter would certainly help. Short
I think that we expect I would also expect Long@krobelus I'll illustrate how this affects me and how I am trying to solve it. Also, I think that An other example :
Fish history : - cmd: mkdir TEST/test -p
when: 1714138074
- cmd: cd TEST/
when: 1714138077
paths:
- TEST/
- cmd: touch test/test.txt
when: 1714138087
- cmd: cd ..
when: 1714138089
paths:
- .. Then writing @rickalex21 should say if it's consistent with what he mentioned. I may have over complexified the issue for a broader discussion while @rickalex21 may just want a simple test on the suggestion's token if it's a path to see if it still exist. An other example not related to paths :
Problematic situationsThe worst cases are :
When the current directory is changed the suggestion to For example, if I use it nvim, it may suggest a file that doesn't exist in the current directory like How I tried to address this in a wrong wayTo mitigate this, I was trying a few things :I added a function It would
function execute-or-preexec
# this is to merge history on exter with no arguments
set -l cmd (commandline)
if test -z "$cmd"
#echo -n "Debug: history merge"
history save
history merge
end
#commandline-paths-to-absolute
#history-last-cmd-paths-to-absolute # TODO
commandline -f execute
end
bind \r execute-or-preexec The new problemThe issue is handling special cases ! So I was thinking of processing An other more simple way with fish_history and autosuggestion test for validityIf fish history had the
So we could look to resolve that with a An old issue #120 is still opened to extend fish's history with additional information like In summary
|
@mqudsi Extra metadata would be something to consider.
@krobelus Ya, by the looks of it the paths are missing when the file does not exist. file /tmp/hyprpm/hyprland/subprojects/wlroots/build/meson-logs/meson-log.txt
/tmp/hyprpm/hyprland/subprojects/wlroots/build/meson-logs/meson-log.txt: cannot open `/tmp/hyprpm/hyprland/subprojects/wlroots/build/meson-logs/meson-log.txt' (No such file or directory)
Fish history: - cmd: file /tmp/hyprpm/hyprland/subprojects/wlroots/build/meson-logs/meson-log.txt
when: 1711668222
@johnr14 I think path is only one, I'm sure there are other commands like I'm not even in the directory that has Zoxide has a great approach to their system in which you can remove. However, it would be More metadata added to the history file could be an option as long as it does not interfere with |
This looks like when you ran that command, I'll make
Yeah that can be improved.
yeah that's unrelated and it needs design work, best to move to a different ticket.
not sure what you mean, are not both valid suggestions? |
I am looking for documentation about autosuggestion and can't seem to find much.
Do a check on file path to check that all directories exist before suggesting it should fix it right ? If it's just a filename, it's ok as it will be created, but not many application will create an non-existing path to create a file.
The example was that a previous file named For new files, it would be nice to have some regex matching rules that can be user customized. Is there a way to do that ? |
@krobelus I can confirm that is the case,
@johnr14 I'm not sure how well that would scale cause it sounds like O(n), a hashmap (key value) approach would prob |
fish, version 3.7.1
Linux void 6.6.22_1 SMP PREEMPT_DYNAMIC Fri Mar 15 23:56:15 UTC 2024 x86_64 GNU/Linux
xterm-kitty
no
This is not a problem more of a feature?
Is there a way to make the fish shell smarter? For example, if file foo does not exist
do not suggest it.
When I do:
cp /mn
it will suggest files that do not exist anymore. Same thing with rmdir etc...The output suggestion is this:
I would perfer that it suggests files that actually do exist.
Thanks
The text was updated successfully, but these errors were encountered: