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