Giter VIP home page Giter VIP logo

Comments (5)

zanchey avatar zanchey commented on June 2, 2024

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.

rickalex21 avatar rickalex21 commented on June 2, 2024

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.

mqudsi avatar mqudsi commented on June 2, 2024

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.

krobelus avatar krobelus commented on June 2, 2024

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.

mqudsi avatar mqudsi commented on June 2, 2024

fish already does this.

I thought that was the case but doubted myself from the conversation!

from fish-shell.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.