Commit Graph

3 Commits

Author SHA1 Message Date
Fabian Boehm
b3ed2f215b __fish_anyeditor: Add missing -- separator
My $EDITOR is set to "emacs" and "-nw", which breaks this
2024-07-23 17:04:23 +02:00
Johannes Altmanninger
9158395d10 Fix __fish_list_current_token and friends for multiline commandlines
Some of these handled multiline prompts but not multiline command lines. We
first need to move the cursor to the end of the commandline, then we can
print a message.  Finally, we need to move the cursor back to where it was.
2024-04-12 12:00:24 +02:00
Johannes Altmanninger
47aa79813d Open command script in external editor on Alt+o
Fish functions are great for configuring fish but they don't integrate
seamlessly with the rest of the system. For tasks that can run outside fish,
writing scripts is the natural approach.

To edit my scripts I frequently run

    $EDITOR (which my-script)

Would be great to reduce the amount typing for this common case (the names
of editor and scripts are usually short, so that's a lot of typing spent on
the boring part).

Our Alt+o binding opens the file at the cursor in a pager.  When the cursor
is in command position, it doesn't do anything (unless the command is actually
a valid file path). Let's make it open the resolved file path in an editor.

In future, we should teach this binding to delegate to "funced" upon seeing
a function instead of a script. I didn't do it yet because funced prints
messages, so it will mess with the commandline rendering if used from
a binding.  (The fact that funced encourages overwriting functions that
ship with fish is worrysome. Also I'm not sure why funced doesn't open the
function's source file directly (if not sourced from stdin). Persisting the
function should probably be the default.)

Alternative approach: I think other shells expand "=my-script" to
"/path/to/my-script".  That is certainly an option -- if we do that we'd want
to teach fish to complete command names after "=".  Since I don't remember
scenarios where I care about the full path of a script beyond opening it in
my editor, I didn't look further into this.

Closes #10266
2024-02-07 00:07:47 +01:00