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