Here is a situation: I want to manage my working environment on multiple projects separately, and all of them should have its own session (Session.vim
) to save and restore.
So I would like to launch each project via nvim -S SESSION_FILE
. And in order to save and quit easily, I define the following:
nnoremap <leader>q :mksession! ~/.config/nvim/session.vim<cr>:wqa<cr>
However, I want to set the SESSION_FILE
to some variable in the vimrc at the launch time automatically, and then quit via <leader>q
whatever the current project is, by replacing the ~/.config/nvim/session.vim
to the variable I read via the command-line argument. However, I'm not sure how I can extract the command-line argument that is executed on Terminal.
So how can I read the command-line argument from the launch and set it in the vimrc while the vim is working, and then when it quits, it automatically save the session file that is specific to the current project?