Hi everyone! Here’s a simple session management setup I came up with a few weeks ago that I wanted to share.
I use the following as a kak
wrapper:
desktop="$(bspc query -D -d 2>/dev/null)"
# bspc result was empty, so most likely not using bspwm
[ -z "$desktop" ] && exec kak "$@"
kak -clear
# if session with desktop id is found, connect to it. otherwise create it
if kak -l | grep -q "^${desktop}$"; then
exec kak -c "$desktop" "$@"
else
exec kak -s "$desktop" "$@"
fi
What it does is take the focused bspwm desktop ID and use it as a session ID for Kakoune. Should be easy to port to other WMs too.
I find this to be a nice middle ground between “a single global session for all projects” and “only one session per project” and I find it pretty intuitive.
For each project I usually have all the buffers open together in a single desktop (disclaimer: I haven’t worked in “big” projects yet so I’m not sure how good this works with those).
Sometimes I’m not even working on a “project” and just want to copy code between two files, so opening both on the same desktop does the trick.
It does have the following issues though:
- (Edit: I fixed my wrapper above to clear dead sessions with
kak -clear
.)
Closing the terminal window (i.e. “alt f4” instead of:q
) results in the session becoming a dead session, and no new Kakoune clients will open on that desktop. This can be worked around by deleting the dead session socket before creating a new one. - Moving a terminal from one desktop to another messes up the whole “all Kakoune clients in this desktop belong to the same session” idea.
I’d like to hear your thoughts on this setup! If you have other ways to manage your sessions/projects please share them too!
This is my first time posting on here, so let me know if I messed anything up :