Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Gentoo: User

Setting default user environments in /etc/profile.d/

 

 

Gentoo user RSS feed   Index | Next | Previous | View Threaded


stroller at stellar

May 1, 2012, 11:11 AM

Post #1 of 11 (369 views)
Permalink
Setting default user environments in /etc/profile.d/

So /etc/profile contains the following message:

# You should override these in your ~/.bashrc (or equivalent) for per-user
# settings. For system defaults, you can add a new file in /etc/profile.d/.
export EDITOR=${EDITOR:-/bin/nano}
export PAGER=${PAGER:-/usr/bin/less}

Therefore I have created a plain text file /etc/profile.d/essential_defaults

$ cat

export HISTSIZE=900
export HISTFILESIZE=900
export HISTCONTROL=erasedups

# vi-style Bash history editing
set -o vi

export MANPAGER="/usr/bin/most"
$

Yet when I log in, these environment variables are not set.

The file is world-readable (mode 644), and I even tried setting the execute bit (`chmod +xxx`).

If I source the file using `. /etc/profile.d/essential_defaults` then suddenly I get the right pager, but it does not seem to be sourced at login, as I believe is promised. What am I doing wrong or misunderstanding, please?

Stroller.


remy.blank at pobox

May 1, 2012, 11:20 AM

Post #2 of 11 (360 views)
Permalink
Re: Setting default user environments in /etc/profile.d/ [In reply to]

Stroller wrote:
> What am I doing wrong or misunderstanding, please?

Rename your file to "essential_defaults.sh". Only files with a ".sh"
extension are sourced (assuming you are using bash).

-- Remy
Attachments: signature.asc (0.19 KB)


michael at orlitzky

May 1, 2012, 11:27 AM

Post #3 of 11 (361 views)
Permalink
Re: Setting default user environments in /etc/profile.d/ [In reply to]

On 05/01/2012 02:11 PM, Stroller wrote:
> So /etc/profile contains the following message:
>
> # You should override these in your ~/.bashrc (or equivalent) for per-user
> # settings. For system defaults, you can add a new file in /etc/profile.d/.
> export EDITOR=${EDITOR:-/bin/nano}
> export PAGER=${PAGER:-/usr/bin/less}
>
> Therefore I have created a plain text file /etc/profile.d/essential_defaults
>

First of all, use `eselect pager` =)

The reason this isn't working is that the comment at the top of
/etc/profile fails to mention this:

for sh in /etc/profile.d/*.sh ; do
[ -r "$sh" ] && . "$sh"
done
unset sh

So it looks like you need to add a ".sh" extension.


wonko at wonkology

May 1, 2012, 11:38 AM

Post #4 of 11 (365 views)
Permalink
Re: Setting default user environments in /etc/profile.d/ [In reply to]

Stroller writes:

> Therefore I have created a plain text
> file /etc/profile.d/essential_defaults
[...]
> Yet when I log in, these environment variables are not set.
>
> The file is world-readable (mode 644), and I even tried setting the
> execute bit (`chmod +xxx`).

It needs to be readable by your user, more is not needed.

> If I source the file using `. /etc/profile.d/essential_defaults` then
> suddenly I get the right pager, but it does not seem to be sourced at
> login, as I believe is promised. What am I doing wrong or
> misunderstanding, please?

/etc/profile is sourced for login shells only. That happens when you log
in a text console, but usually not for a graphical terminal. As a KDE
user, I have set my Konsole's profiles to run '/bin/bash -l', this gives
me login shells. For xterm or aterm, you would use the '-ls' option.

Wonko


stroller at stellar

May 1, 2012, 12:40 PM

Post #5 of 11 (353 views)
Permalink
Re: Setting default user environments in /etc/profile.d/ [In reply to]

On 1 May 2012, at 19:27, Michael Orlitzky wrote:

> On 05/01/2012 02:11 PM, Stroller wrote:
>> So /etc/profile contains the following message:
>>
>> # You should override these in your ~/.bashrc (or equivalent) for per-user
>> # settings. For system defaults, you can add a new file in /etc/profile.d/.
>> export EDITOR=${EDITOR:-/bin/nano}
>> export PAGER=${PAGER:-/usr/bin/less}
>>
>> Therefore I have created a plain text file /etc/profile.d/essential_defaults
>>
>
> First of all, use `eselect pager` =)

Actually, if you look at the contents of my essential_defaults file, I'm not so interested in the pager as the MANPAGER setting. I find that after using `most` as my man-pager, it's quite horrible using `less` on a new system. For anything else, `less` is fine.

Stroller.


stroller at stellar

May 1, 2012, 12:41 PM

Post #6 of 11 (355 views)
Permalink
Re: Setting default user environments in /etc/profile.d/ [In reply to]

On 1 May 2012, at 19:20, Remy Blank wrote:

> Stroller wrote:
>> What am I doing wrong or misunderstanding, please?
>
> Rename your file to "essential_defaults.sh". Only files with a ".sh"
> extension are sourced (assuming you are using bash).

Many thanks!

That's it.

Stroller.


stroller at stellar

May 1, 2012, 12:42 PM

Post #7 of 11 (355 views)
Permalink
Re: Setting default user environments in /etc/profile.d/ [In reply to]

On 1 May 2012, at 19:38, Alex Schuster wrote:
>> …
>> The file is world-readable (mode 644), and I even tried setting the
>> execute bit (`chmod +xxx`).
>
> It needs to be readable by your user, more is not needed.

Yeah, I thought not, but I thought I'd mention trying it.

Stroller.


waltdnes at waltdnes

May 1, 2012, 3:52 PM

Post #8 of 11 (356 views)
Permalink
Re: Setting default user environments in /etc/profile.d/ [In reply to]

On Tue, May 01, 2012 at 07:11:37PM +0100, Stroller wrote
> So /etc/profile contains the following message:
>
> # You should override these in your ~/.bashrc (or equivalent) for per-user
> # settings. For system defaults, you can add a new file in /etc/profile.d/.
> export EDITOR=${EDITOR:-/bin/nano}
> export PAGER=${PAGER:-/usr/bin/less}
>
> Therefore I have created a plain text file /etc/profile.d/essential_defaults

I don't know if it gets executed in the right order. Are you using
baselayout 2? The items you mentioned are EDITOR and PAGER. For the
official way of changing global settings, see...
http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=2&chap=5&style=printable
for examples. In my case...

waltdnes [at] d53 ~ $ cat /etc/env.d/99editor
EDITOR="/usr/bin/vim"

In your case, I would suggest creating a file called /etc/env.d/99pager
containing the line...
PAGER="/usr/bin/most"

Note that the files are sourced by name in your current locale sort
order. In just about every locale numbers should sort properly, which
would start at 00blahblahblah and go through 99blahblahblah.

--
Walter Dnes <waltdnes [at] waltdnes>


pandu at poluan

May 1, 2012, 7:26 PM

Post #9 of 11 (354 views)
Permalink
Re: Setting default user environments in /etc/profile.d/ [In reply to]

On May 2, 2012 2:48 AM, "Stroller" <stroller [at] stellar> wrote:
>
>
> On 1 May 2012, at 19:27, Michael Orlitzky wrote:
>
> > On 05/01/2012 02:11 PM, Stroller wrote:
> >> So /etc/profile contains the following message:
> >>
> >> # You should override these in your ~/.bashrc (or equivalent) for
per-user
> >> # settings. For system defaults, you can add a new file in
/etc/profile.d/.
> >> export EDITOR=${EDITOR:-/bin/nano}
> >> export PAGER=${PAGER:-/usr/bin/less}
> >>
> >> Therefore I have created a plain text file
/etc/profile.d/essential_defaults
> >>
> >
> > First of all, use `eselect pager` =)
>
> Actually, if you look at the contents of my essential_defaults file, I'm
not so interested in the pager as the MANPAGER setting. I find that after
using `most` as my man-pager, it's quite horrible using `less` on a new
system. For anything else, `less` is fine.
>
> Stroller.
>
>

'most' is for sissies ; I use vimmanpager for MANPAGER, and vimpager for
PAGER. ;-)

Rgds,


stroller at stellar

May 1, 2012, 8:58 PM

Post #10 of 11 (353 views)
Permalink
Re: Setting default user environments in /etc/profile.d/ [In reply to]

On 1 May 2012, at 23:52, Walter Dnes wrote:

> On Tue, May 01, 2012 at 07:11:37PM +0100, Stroller wrote
>> So /etc/profile contains the following message:
>>
>> # You should override these in your ~/.bashrc (or equivalent) for per-user
>> # settings. For system defaults, you can add a new file in /etc/profile.d/.
>> export EDITOR=${EDITOR:-/bin/nano}
>> export PAGER=${PAGER:-/usr/bin/less}
>>
>> Therefore I have created a plain text file /etc/profile.d/essential_defaults
>
> … The items you mentioned are EDITOR and PAGER. For the
> official way of changing global settings, see...
> http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=2&chap=5&style=printable
> for examples. In my case…

Nope, those are merely the next two lines from the file when I ran `grep -C X` to find where I'd read about putting files in /etc/profile.d/.

If you read my original post (solved) now, you'll see that in my actual my_defaults.sh file I only concern myself with the MANPAGER, the history file and vi-style line editing (for Bash).

Sorry if this was unclear,

Stroller.


stroller at stellar

May 1, 2012, 9:01 PM

Post #11 of 11 (358 views)
Permalink
Re: Setting default user environments in /etc/profile.d/ [In reply to]

On 2 May 2012, at 03:26, Pandu Poluan wrote:

>> Actually, if you look at the contents of my essential_defaults file, I'm not so interested in the pager as the MANPAGER setting. I find that after using `most` as my man-pager, it's quite horrible using `less` on a new system. For anything else, `less` is fine.
>
> 'most' is for sissies ; I use vimmanpager for MANPAGER, and vimpager for PAGER. ;-)

Hmmmn… I use vim as my editor, but most is much better for manpages. Perhaps it is simply the default syntax colouring that is so much better. I have tried your suggestion, and couldn't get along with it.

Stroller.

Gentoo user RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.