I use emacs at work, where I usually connect to the system with two different users:
The former is my own personal user, whereas the latter is shared by the whole team to manage an application. (Irrelevant hint: This is a terrible idea. There are generally better, albeit a bit less obvious, ways to manage privileges. Take it from my experience).
In order to avoid unfortunate mix-ups, I want to define a separate theme for each user, and define it in their respective init files.
Everything else defined in the init file has to be shared by the two.
I create a separate init file
/path/to/init/file/.emacs and created the following
.emacs file in each user's home directory:
(load-file "/path/to/init/file/.emacs") (load-theme my-favorite-theme)
This works like a charm. But of course, that would be too easy!
New solution needed
I was asked not to modify the
.emacs file of
commonuser. I won't go into the details of why, but the fact remains that I had to find a workaround. Here's what I got so far:
- Wrote a complete
~myuser/.emacsfile, that I will load regardless of the user.
Defined an alias for
alias emacs='emacs -Q --load ~myuser/.emacs'
This will make emacs ignore
commonuser's init file and load
Now my (simple) question is:
How can I make emacs behave differently according to the user launching it?
I am looking to do something similar:
if [[ $(whoami) == "myuser" ]]; then (load-theme 'theme1) if [[ $(whoami) == "commonuser" ]]; then (load-theme 'theme2)