Provides a global minor mode to display information about a buffer’s project (a “project tag”) in its mode line.
To derive a buffer’s project tag, we first look for dir-local
variables named project-mode-line-tag
or project-name
. If none of
these are set, we call the project-name
function if it exists (Emacs
29), and fall back to the project’s directory name (e.g. bar
for
/code/foo/bar
) otherwise.
In addition, if one of project-mode-line-tag-template
or
project-name-template
is present, it is used as the format-string in a
call to format
to further customize the project tag. The format-string
is expected to have a single %s
sequence which will be substituted
with the current project tag. This can be useful if you want to have
all projects in a directory share a common prefix, for example.
If you use MELPA, an easy way to install this package is via
package-install
. Alternatively, download project-mode-line-tag.el
, put
it in your load-path
and require
it. Finally, use
(project-mode-line-tag-mode 1)
or M-x project-mode-line-tag-mode
to
turn on the provided minor mode.
If you use both MELPA and use-package
, you can use this, too:
(use-package project-mode-line-tag
:ensure
:config
(project-mode-line-tag-mode 1))
Showing 3 windows; from top to bottom:
- Project tag
project-mode-line-tag
derived from its buffer’s relatedproject.el
project’s root directory. - Project tag
foobar
derived from theproject-name
dir-local variable that applies to its buffer. - None of the above, so no project tag.
The face applied to the project tag and the format of how to display it in the mode line are fully customizable.
- Check out the cascading-dir-locals package if you want to use nested dir-local variables.
- The tab-bar-groups package integrates with this package and applies the current tab bar group’s color to the project tag in the mode line. You might want to use this in combination with the project-tab-groups package if you follow a “one tab group per project” workflow.