matthias-t / workspace

Mirror of https://git.sr.ht/~matthias_t/workspace
MIT License
0 stars 1 forks source link

`edit` subcommand #56

Closed matthias-t closed 6 years ago

matthias-t commented 6 years ago

Open the toml file for the workspace in the default editor

matthias-t commented 6 years ago

Here's a solution in bash (from stackoverflow):

"${EDITOR:-vi}" ~/.workspace/NAME.toml

where vi is a POSIX-guaranteed-to-be-present fallback in case $EDITOR is unset.

In PowerShell that'd be just ~/.workspace/NAME.toml. Actually, that behaves more like xdg-open.

Since it's different for each shell, we should add a new recognized prefix to our shell wrappers, something like EDIT>. I chose to get the environment variable from Rust and then pass down a command to the shell function. There is no fallback, so if $EDITOR and $VISUAL are unset it will show a descriptive error message.

pExeen commented 6 years ago

This is the shortest solution I found for fish: set editor $EDITOR vi; eval $editor[1] ~/.workspace/NAME.toml