Terminal command to load session.
Opened this issue · 3 comments
Hello. I used to use obsession
for my sessions management. But it is slightly slow...
May I use possession
the same way as obsession?
I normally do :Obsession
in session which I want to track and than i do nvim -S
if I want restore session for current dir and just nvim
if I doesn't.
How can I do it with possession
?
Hi, one thing that vim-obsession
does differently (as far as I understand) is that it saves session files in the current directory. possesion
uses a common directory for all sessions (e.g. ~/.local/share/nvim/possession/
) and the current code would require quite a bit of refactoring if the common directory approach is a no-go for you.
But if you would be ok with common directory, than the potential workflow could be:
- in
setup {...}
setautosave.current = true
- use
PossessionSave yoursessionname
to save the session; it will now also be auto-saved before quitting nvim due toautosave.on_quit = true
- when you want to start nvim using the session for current dir you would use a command like
PossessionLoadCwd
that would check existing sessions and find a best match based on cwd, then load it
To make this work we would need to implement the metioned PossessionLoadCwd
command. Available sessions can be found using as_list() and then session.cwd
can be checked. There are even some helper functions in query.lua
that could be used, probably some combination like M.group_by(M.by_root_dir(current_dir), sessions)
and then find best match (closest to cwd).
What do you thing of such a workflow vs what you are currently using?
I have a use case for something like this. I'd like to be able to quickly quit nvim and re-enter right where i left off for when i make updates to my nvim config.
@Justinfan827 Would saving temporary session work? You would work on something, then quit, this would save tmp
session, then you can open nvim and use PossessionLoad tmp
. I'm suggesting this soultuion, as I don't think I'll have time to work on CWD-based session in the near future.