This article was originally published as a blog entry at http://alweb.dk/blog/anders/kate_named_sessions and is now donated to this website.
The biggest change in Kate (http://kate.kde.org, http://www.kate-editor.org) in the KDE 3.5 series is definitely the introduction of named sessions. Instead of defaulting to one instance, Kate now as a standard allows you to run many instances.
And not even that, it will allow you to keep those sessions, with the list of open files as well as the instance specific GUI configuration. This is a big change in behavior, but once you get used to it, you will hopefully appreciate the benefits.
If not, it is still possible to restore the old-style kate behavior by utilizing the various related commandline and configuration options. You will of course loose at least some of the advantages of named settings, but if you desire keeping things as they were, you probably do not care a lot.
Because this is new, there are of course problems and unforeseen issues. Due to busyness with real life, I have not had a chance to get much into named sessions prior to the KDE 3.5/Kate 2.5 release, but I have been working hard on enhancing the named sessions experience for KDE 3.5.1/Kate 2.5.1 and upwards.
Read on for more about how it works, what have been fixed so far and some ideas for future improvements.
Basically, a Kate session is a instance of the application with its own set of open documents and its own window setup (toolbars, toolviews, editor frame[s]). The session can be named and saved with the file list and optional the window setup, so that it can easily be restored again.
If you edit a lot of text files for different purposes, such sessions can make your life much easier. I for example have sessions for various websites I maintain and for my various KDE related projects. When I want to work on a project, I open the session and have the setup as I left it last time I used it. For one thing, the named sessions feature will obsolete the filelist loader plug-in that some of you may have used.
You can create a new session in many ways:
--start <New session name>. If the session with the specified name does not exist, it is created.
There are equally easy ways to open a session once you have some:
kate --start YourSession in the exec property)If I want to open one or more files and forget about them again, I can just open then in an anonymous session which will not be saved.
If I want to add files to a running session from outside, I can use command line options to do so. In Kate 2.5 that means any running instance (—use) or an instance selected by its process ID (PID) (—use —pid PID).
Kate saves your sessions pr. default, but you can have it ask you or not save sessions if that suits your work flow better (I’m personally happy with this default, although i sometimes forgets to close some files that I’m done with).
As indicated above, Kate has tree new command line options to support named sessions:
-s, --start <name>--use so that when both is specified only the specified session will be reused, if it is not running it will be started or created.-u, --use--pid <PID> (or, in the future, --start >name<) the first instance found by DCOP (the one with the lowest PID) will be used.-p, --pid <pid>Sessions have gotten their own panel in Kate’s configuration dialog, with so far tree options allowing you to tweak the behavior.
Many users have grown accustomed to the old style behavior, where Kate would run only one instance and all files would be forwarded to that instance. We know from the bugs database (http://bugs.kde.org) and mailling list (http://lists.kde.org/?l=kwrite-devel) that many users got a bit confused when kate didn’t behave as usual, and given the lack of warning and documentation of the new behavior that is not suprising.
To restore the old style behavior, you can follow this strategy:
kate --use %U--use automatically. If you use bash as your shell, add something like alias kate="kate --use" to your ~/.bashrc file.Be warned though that until KDE 3.5.1 is released (soon!) you will experience some problems with this: when opening files from the KDE environment with --use, you get a KIO error about not being able to launch kate. As indicated, this has been fixed in the 3.5 branch of KDE and if you compile KDE yourself, get this version of the kdebase module to fix those problems.
I have tried to do a few improvements in Kate 2.5.1 because there is quite some time until we get to KDE 4. Most are really bug fixes, although mostly for unreported issues. Many but not all are related to named sessions.
Improvements include
--start <name> will work with --use.kdeinit not being able to launch kate is history.A very obvious step is to include more configurations in the session data. This could include
In Kate 2.5.1 the pid is exported to the environment variable KATE_PID so that you can alias kate with kate -up $KATE_PID if that is set, in Kate 2.5.2 this will not be nessecary anymore, Kate will automatically select the current instance if the KATE_PID variable is set.
One thing that has lead to quite a few complaints is the removal of the project support in Kate. This came as a suprise to us developers, as we all found the project support very poor, but it appears that it has been used and appreciated by quite a few users. Adding project support on the top of named sessions would be good, and I am considering how it can be done in a nice and flexible way. My own demands are that any file can be a member of a project, and I would like to see some sort of project type that would support various commands such as building software, synchronizing directories etc.
Comments
Thanks for this awesome
Thanks for this awesome feature, which is now indispensable; I can’t imagine using any other editor unless it had this facility. I’d been using Debian Sarge with an older version of Kate for much too long past its sell-by date and was looking forward to using the new Kate 2.5.5 once I upgraded. I am seriously impressed and it does everything I could wish for :-) I now have 5+ instances of Kate loading up automatically at boot time with my most important sessions, and others are easily loadable when needed.Thank you very much for this information.
Still not clear how sessions work
Sorry, maybe I am too stupid, but I still haven’t understood how sessions work. I have heard that they are very useful and I thought, I can save my text files related to project A, B, C… separately. In fact, all files are mixed up and most are empty after a certain period of time. Sometimes I create a new session and later I found out that I have overwritten an existing text (the window was empty but once there have been text).
All the desciption is too technical and I still don’t know how it works and how to use it. Sorry, but as most features in KDE: Sounds nice, but not usable.
Kate is a goddess!
Thanks for this awesome feature, which is now indispensable; I can’t imagine using any other editor unless it had this facility. I’d been using Debian Sarge with an older version of Kate for much too long past its sell-by date and was looking forward to using the new Kate 2.5.5 once I upgraded. I am seriously impressed and it does everything I could wish for :-) I now have 5+ instances of Kate loading up automatically at boot time with my most important sessions, and others are easily loadable when needed.
Cheers, Malcolm Smith
How to remove saved session
Hello I didn’t find how to remove saved session from session list?
site
Your drupal site is nice but I can’t get to the 2nd page of articles. It just gives me a blank page. With Developers nd HOWTO’s Hardly worth signing up to the bugs list. Hal
Reusing Windows
The whole idea of sessions is just great, but I personally found it poorly implemented. Why the sessions aren’t update automatically, just when I save them ? We could at least have a way to NOT open a new window everytime I call kate from the command line and ask it to use an existing session. It’d be the best of both worlds, the old one, where I could simply call kate lots of times and it’d just keep adding documents to the open kate window, and the new one, where I could have this behaviour done on a session basis.
Kate Project was very different from session !!!
Doesn’t matter if only few people use kate’s projects… It was very very stupid to remove that feature !! Because now, there is no alternative for people like me that use kate’s projects… becuase Session are completly different !! There’s no common points !! I’m starting using Kate only because kate’s project feature !!! Because it was so simple and efficient !! If somethings is poor doesn’t imply that is useless !!
good article
thanks, it was very useful for me!
Are all my kateproject files useless???
I have been using kate to edit my R scripts for statistical analysis of many research projects. For each separate experiment I could add the data files and several separate scripts together as a .kateproject. I had just become quite efficient getting things done in this manner. Was all of this for nothing? Do I have to now create a named session for each one of these projects? and open them up by name at the command line???
I really hope this functionality can be restored. Until then I will have to once again search for a good R script editor…
This is all very well...
…but I liked restricting kate to a single session. For one thing, it meant that I could bring up the instance of Kate I was using with its appropriate KDE keyboard shortcut (such as CTRL+ALT+K), rather than Alt-tabbing my way through a program list. For another, it meant I could type
into a console to open every file matching that pattern in an existing Kate session. Wonderful little tool, but since I upgraded Kubuntu to Dapper yesterday, apparently it’s no longer useful.
Post new comment