tpope / vim-obsession

obsession.vim: continuously updated session files
http://www.vim.org/scripts/script.php?script_id=4472
1.76k stars 70 forks source link

Make sessions executable #46

Closed gleachkr closed 6 years ago

gleachkr commented 6 years ago

It's possible to insert a shebang at the beginning of a vimscript file to specify vim or nvim as the interpreter (ref. :help #!).

What would you think of a patch that added such a shebang to obsession's session files and made the session executable, so that you could start your session with ./session.vim?

tpope commented 6 years ago

It's a little weird, and I wouldn't want to make it the default lest people mistake it for an endorsement, but I'd certainly be open to making it possible.

What would the shebang line look like? Neither #!vim -S nor #!/usr/bin/env vim -S will do what you expect.

gleachkr commented 6 years ago

For me, #!/bin/env -S nvim -S does the trick. -S to env splits the arguments in the way you'd expect.

gleachkr commented 6 years ago

Should I try a PR? Any suggestions in advance for how to expose the option to a user?

tpope commented 6 years ago

env -S isn't portable.

gleachkr commented 6 years ago

OK. I can't find a fully portable solution. If it's optional anyway, I suppose you could configure the shebang line. But if that's a bit too fiddly for your taste, no worries.

tpope commented 6 years ago

exepath(v:progpath) looks like it would technically work but looks strange, returning values like /Applications/MacVim.app/Contents/MacOS/Vim and /usr/bin/vim.gtk3.

I'd recommend starting by implementing an external solution with autocmd User Obsession, and see how useful you find it in practice.

gleachkr commented 6 years ago

:+1: