]> git.pld-linux.org Git - projects/setup.git/blob - etc/profile
bbf534e737a56d7cfe22005f84299454d26e38b2
[projects/setup.git] / etc / profile
1 # /etc/profile
2 # $Id$
3
4 # System wide environment and startup programs
5 # Functions and aliases go into the shells dependent startup files
6
7 # returns TRUE if $1 contains $2
8 strstr() {
9         [[ $1 = *$2* ]] && return 0 || return 1
10 }
11 strstr "$PATH" /usr/X11R6/bin || PATH="$PATH:/usr/X11R6/bin"
12 strstr "$PATH" /usr/local/bin || PATH="$PATH:/usr/local/bin"
13 strstr "$PATH" "$HOME/bin" || PATH="$PATH:$HOME/bin"
14 unset strstr
15
16 USER=`id -un`
17 LOGNAME=$USER
18
19 HOSTNAME=`/bin/uname -n`
20 HISTFILE="$HOME/.history"
21 HISTSIZE=1000
22
23 if [ `id -gn` = $USER -a `id -u` -gt 14 ]; then
24         umask 002
25 else
26         umask 022
27 fi
28
29 #
30 # Setup the environment for various shells
31 #
32
33 if [ "$TERM" = "" -o "$TERM" = "unknown" ]; then
34         TERM=linux
35 fi
36
37 SH="${0#\-}"
38 SH="${SH#/bin/}"
39 if [ "$SH" = "sh" ]; then
40         if [ -n "$KSH_VERSION" ]; then
41                 SH=ksh
42         elif [ -n "$ZSH_VERSION" ]; then
43                 SH=zsh
44         elif [ -n "$BASH_VERSION" ]; then
45                 SH=bash
46         elif [ -n "`$SH -c 'echo ${.sh.version}' 2>/dev/null`" ]; then
47                 SH=ksh93
48         fi
49 fi
50
51 case "$SH" in
52   bash)
53         # currently - nothing
54         ;;
55   ksh|pdksh)
56         PS2='> '
57         set -o emacs
58         bind '^I'=complete >/dev/null 2>&1
59         bind '^[^I'=complete-list >/dev/null 2>&1
60         #
61         # Setup some of the most basic editing functions
62         # to work properly under different terminal emulators.
63         #
64         case $TERM in
65         nxterm|xterm|xterm-color)
66                 bind '^[[H'=beginning-of-line >/dev/null 2>&1
67                 bind '^[[F'=end-of-line >/dev/null 2>&1
68                 ;;
69         linux|rxvt)
70                 bind '^[[1~'=beginning-of-line >/dev/null 2>&1
71                 bind '^[[4~'=end-of-line >/dev/null 2>&1
72                 ;;
73         esac
74         ;;
75   ksh93)
76         if [ `id -u` -eq 0 ]; then
77                 PS1='[${LOGNAME-$USER}@${HOSTNAME} `
78                 if [ "$PWD" = "/${PWD##*/}" ]; then
79                         echo $PWD;
80                 else
81                         echo ${PWD##*/};
82                 fi`]# '
83         else
84                 PS1='[${LOGNAME-$USER}@${HOSTNAME} `
85                 if [ "$PWD" = "/${PWD##*/}" ]; then
86                         echo $PWD;
87                 else
88                         echo ${PWD##*/};
89                 fi`]$ '
90         fi
91         PS2='> '
92         set -o nolog
93         set -o emacs
94         case $TERM in
95         nxterm|xterm|xterm-color)
96                 trap 'case ${.sh.edchar} in "\e[F") .sh.edchar="\ 5" ;; "\e[H") .sh.edchar="\ 1" ;; esac' KEYBD
97                 ;;
98         linux|rxvt)
99                 trap 'case ${.sh.edchar} in "\e[4~") .sh.edchar="\ 5" ;; "\e[1~") .sh.edchar="\ 1" ;; esac' KEYBD
100                 ;;
101         esac
102         ;;
103   zsh)
104         # other HISTFILE, zsh uses diffrent fmt
105         HISTFILE=~/.historyz
106         # w/o this hist file won't get saved!
107         SAVEHIST=$HISTSIZE
108         ;;
109 esac
110
111 unset SH
112 export PATH USER LOGNAME HOSTNAME HISTFILE HISTSIZE PS1 PS2
113
114 # Put all of the variables as files in /etc/env.d/
115 # example:
116 # cat /etc/env.d/VARIABLE
117 # VARIABLE="value"
118 if [ -f /etc/profile.env ]; then
119         . /etc/profile.env
120 else
121         for i in /etc/env.d/* ; do
122                 NAME=${i##*/}
123                 case $NAME in
124                         *~ | *.bak | *.old | *.rpmnew | *.rpmsave )
125                                 # nothing
126                                 ;;
127                         * )
128                                 if [ -r $i ]; then
129                                         . $i; export $NAME
130                                 fi
131                                 ;;
132                 esac
133         done
134         unset NAME
135 fi
136
137 # Scripts:
138 for i in /etc/profile.d/*.sh ; do
139         . $i
140 done
141
142 unset i
143
144 # vi:syntax=sh
This page took 0.045147 seconds and 2 git commands to generate.