From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: david@adboyd.com (J. David Boyd) Newsgroups: gmane.emacs.help Subject: Re: Customising .init.el for root user Date: Fri, 21 Jun 2013 09:13:15 -0400 Message-ID: References: <871u7woijw.fsf@gmx.co.uk> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1371820431 30310 80.91.229.3 (21 Jun 2013 13:13:51 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 21 Jun 2013 13:13:51 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Jun 21 15:13:51 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Uq19y-0007WZ-5h for geh-help-gnu-emacs@m.gmane.org; Fri, 21 Jun 2013 15:13:50 +0200 Original-Received: from localhost ([::1]:46445 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uq19x-0004vX-Mo for geh-help-gnu-emacs@m.gmane.org; Fri, 21 Jun 2013 09:13:49 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56887) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uq19k-0004sa-CG for help-gnu-emacs@gnu.org; Fri, 21 Jun 2013 09:13:39 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uq19h-0001yJ-CT for help-gnu-emacs@gnu.org; Fri, 21 Jun 2013 09:13:36 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:55788) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uq19h-0001y6-66 for help-gnu-emacs@gnu.org; Fri, 21 Jun 2013 09:13:33 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1Uq19e-00075G-2R for help-gnu-emacs@gnu.org; Fri, 21 Jun 2013 15:13:30 +0200 Original-Received: from 169.15.137.27 ([169.15.137.27]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 21 Jun 2013 15:13:30 +0200 Original-Received: from david by 169.15.137.27 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 21 Jun 2013 15:13:30 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 69 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 169.15.137.27 User-Agent: Gnus/5.1299999999999999 (Gnus v5.13) Emacs/24.3 (cygwin) Cancel-Lock: sha1:yqFhRG+gJt+IF3reurGYrc+HBPU= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:91632 Archived-At: Johnny 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. > > Any ideas / good practices? > > All the best > > Johnny > > > Footnotes: > [1] (info "(emacs)Find Init") How about something like this that I saw the basics of on stackoverflow? (setq whoami-string (substring (shell-command-to-string "whoami") 0 -1)) Then you could do (when (string= (whoami-string) "root") ..run some customisations... ) Dave