Default session name based on directory name + branch name
Is it possible to set the default session name based on directory name + branch name? At the moment I have this in my config
let g:session_autosave = 'yes'
let g:session_autoload = 'yes'
let g:session_default_name = fnamemodify(getcwd(), ':t')
and it saves sessions under the name of the project directory. But I would like to have separate sessions for every branch. Is it possible?
@Seybo when u set this as ur default name it works for u? Cause it doesn't for me.
As an experiment I just change the working diretory with :cd <dir-name> and call :SaveSession afterwards. When I take a look to the list of stored sessions, there isn't any new session and nor with the name of by current working directory.
Can u help me, cause I'm really interested in the same as u, without the branches.
Furthermore it would be awesome to have a solution, that open vim tries to search for a stored session based on the current working directory.
I would also like to store the default session based off of branch name. That was as I go between branches I go back to the appropriate session automatically. Did you figure this out @Seybo @weilbith ?
@Dbz not so far, sry.
@xolox do you have a recommendation for how we can solve this?
I solved this by switching plugins.
Plug 'tpope/vim-obsession'
Plug 'dhruvasagar/vim-prosession'
I have the setting: let g:prosession_per_branch = 1
So far, this works as well for me as vim-session, and I have the git branch feature I really wanted.
@Dbz this is a good solution. But the problem for me is that you can't save named sessions using this solution. Right? I want to have two sessions for the same branch (let's say front-end-session and back-end-session) and be able to load them explicitly. And i can't do it with the plugins you suggest. AFAIU
Are you sure? You should still be able to call mksession and source on the session to load it.
Oh right. That should work. Anyway i decided to keep using vim-session plugin for these needs
Yeah, the most important thing for me is automatic sessions with a default name of the git_branch. For that:
Plug 'tpope/vim-obsession'
Plug 'dhruvasagar/vim-prosession'
and let g:prosession_per_branch = 1 match my needs perfectly. Also, those plugins are regularly maintained, and vim-session is not actively maintained. If that changes I would consider using this plugin, but I will choose not to use a non maintained plugin when there are maintained plugins that do what I want and better :)
@Dbz I have come here due to a different issue (#154), and just noticed the lack of maintenance (#172).
I completely agree with you, in both that this plugin could use a little bit of love and about avoid using non maintained plugins.
Do you mind sharing which similar plugins you have found that we can use while we don't have word from @xolox?