0

How can I launch the currently configured editor from the fish shell? That is the editor associated with $EDITOR.

What would a function look like that takes input from the pipeline and opens it in the editor identified by $EDITOR.

What would a function look like that opens a path in $EDITOR from the argument list?

Barett
  • 5,826
  • 6
  • 51
  • 55
Eric Schoonover
  • 47,184
  • 49
  • 157
  • 202

1 Answers1

1

How about something like:

function edit -d "Open a file using $EDITOR"
    for file in $argv
        if test -e $file
            eval $EDITOR $file
            echo "Opening file $file"
        else
            echo "Create file? (y/n)"
            read createFile
            if test $createFile = "y"
                eval $EDITOR -n $file
                echo "Creating file $file"
            end
        end
    end
end
lrm29
  • 458
  • 4
  • 17