help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Customising .init.el for root user


From: Harry Putnam
Subject: Re: Customising .init.el for root user
Date: Fri, 21 Jun 2013 15:49:36 -0400
User-agent: Gnus/5.130008 (Ma Gnus v0.8) Emacs/24.0.92 (gnu/linux)

Johnny <yggdrasil@gmx.co.uk> writes:

> Hi,
>
> Starting emacs as my normal user running a root terminal (via su), I want
> emacs to start with some specific parameters that does not apply when
> running as the normal user. Specifically, I want the color to be
> distinct so that it is obvious which emacs is the root session. 
>
> I understand that by default the users init file is used [1]. This
> never worked well for me, defaulting into basic settings, but after
> looking into it and replacing any "~" references with full paths, it
> works as intended.
> However, this gives /all/ the defaults in the user init file, such as
> the color-theme used. I already use the same init file for multiple
> (well, two anyhow) computers and use a check which machine I am on for
> some dedicated settings, e.g.
> ,----
> | (when (string= (system-name) "the other machine")
> |       ..run some customisations...
> |       )
> `----
> Is there any similar way to check whether the session was started with
> root privileges to set customisations? E.g. 
> ,---- 
> | (when (session-started-as-root)
> |         (load-theme 'wheatgrass)
> |         )
> `----
> with a 'session-started-as-root' function? Better methods??
>
> I found one way is to default to a root init file by defining an alias
> in the root .bashrc as
> ,----
> | alias emacs="emacs -u root"
> `----
> however it would be nice to have only one init file to keep track of as
> many tweaks are nice to have in all sessions.

The old hands here will probably have much better ways, but I've found
its just easier to put the code for the desired changes in a small
*.el file in your path like for-root.el containing code to effect the
changes you want for the root session.

You do have to remember to load it manually unless you want the
slicker ways.  But I've found over time its just easier to keep up
with the way I described above.

Then when you start emacs as root just load that file with
M-x load-library <RET> for-root <RET>

Or perhaps create an aliase  for emacs that loads the file like:
alias emrt="emacs -l /path/to/for-root.el"

And start emacs with `emrt' when running as root.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]