]> git.pld-linux.org Git - projects/setup.git/blob - etc/profile
ksh93 support
[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 [ "`echo $PATH | grep -q /usr/X11R6/bin`" = "" ] && PATH="$PATH:/usr/X11R6/bin"
8 [ "`echo $PATH | grep -q "$HOME/bin"`" = "" ] && PATH="$PATH:$HOME/bin"
9
10 if [ `id -gn` = `id -un` -a `id -u` -gt 14 ]; then
11         umask 002
12 else
13         umask 022
14 fi
15
16 USER=`id -un`
17 LOGNAME=$USER
18 MAIL="/var/mail/$USER"
19
20 HOSTNAME=`/bin/hostname`
21 HISTFILE="$HOME/.history"
22 HISTSIZE=1000
23 HISTFILESIZE=1000
24
25 #
26 # Setup the environment for varius shells
27 #
28
29 if [ "$TERM" = "" -o "$TERM" = "unknown" ]; then
30  TERM=linux
31 fi
32
33 SH="${0#\-}"
34 SH="${SH#/bin/}"
35 if [ "$SH" = "sh" ]; then
36         if [ -n "$KSH_VERSION" ]; then
37                 SH=ksh
38         elif [ -n "$ZSH_VERSION" ]; then
39                 SH=zsh
40         elif [ -n "$BASH_VERSION" ]; then
41                 SH=bash
42         fi
43 fi
44
45 case "$SH" in
46   bash)
47         PS1="[\u@\h \W]\\$ "
48         ;;
49   ksh|pdksh)
50         if [ `id -u` -eq 0 ]; then
51                 PS1='[${LOGNAME-$USER}@${HOSTNAME} `
52                         if [ "$PWD" = "/${PWD##*/}" ]; then
53                                 echo $PWD;
54                         else
55                                 echo ${PWD##*/};
56                 fi`]# '
57         else
58                 PS1='[${LOGNAME-$USER}@${HOSTNAME} `
59                         if [ "$PWD" = "/${PWD##*/}" ]; then
60                                 echo $PWD;
61                         else
62                                 echo ${PWD##*/};
63                 fi`]$ '
64         fi
65         PS2='> '
66         set -o emacs
67         bind '^I'=complete >/dev/null 2>&1
68         bind '^[^I'=complete-list >/dev/null 2>&1
69         #
70         # Setup some of the most basic editing functions
71         # to work properly under different termnal emulators.
72         #
73         case $TERM in
74         nxterm|xterm|xterm-color|rxvt)
75                 bind '^[[H'=beginning-of-line >/dev/null 2>&1
76                 bind '^[[F'=end-of-line >/dev/null 2>&1
77                 ;;
78         linux)
79                 bind '^[1~'=beginning-of-line >/dev/null 2>&1
80                 bind '^[4~'=end-of-line >/dev/null 2>&1
81                 ;;
82         esac
83         ;;
84   ksh93)
85         if [ `id -u` -eq 0 ]; then
86                 PS1='[${LOGNAME-$USER}@${HOSTNAME} `
87                         if [ "$PWD" = "/${PWD##*/}" ]; then
88                                 echo $PWD;
89                         else
90                                 echo ${PWD##*/};
91                 fi`]# '
92         else
93                 PS1='[${LOGNAME-$USER}@${HOSTNAME} `
94                         if [ "$PWD" = "/${PWD##*/}" ]; then
95                                 echo $PWD;
96                         else
97                                 echo ${PWD##*/};
98                 fi`]$ '
99         fi
100         PS2='> '
101         set -o emacs
102         ;;
103   zsh)
104         PS1='[%n@%m %~]%(!.#.%\$) '
105
106         # Setup key bindings
107         bindkey -e >/dev/null 2>&1
108         bindkey "^[[1~" beginning-of-line >/dev/null 2>&1
109         bindkey "^[[H" beginning-of-line >/dev/null 2>&1
110         bindkey "^[[4~" end-of-line >/dev/null 2>&1
111         bindkey "^[[F" end-of-line >/dev/null 2>&1
112         bindkey "^[[3~" delete-char >/dev/null 2>&1
113         bindkey "^[[5~" history-search-backward >/dev/null 2>&1
114         bindkey "^[[6~" history-search-forward >/dev/null 2>&1
115
116         case "$TERM" in
117         aterm)
118                 bindkey '^[[A' up-line-or-history >/dev/null 2>&1
119                 bindkey '^[[B' down-line-or-history >/dev/null 2>&1
120                 bindkey '^[[D' backward-char >/dev/null 2>&1
121                 bindkey '^[[C' forward-char >/dev/null 2>&1
122                 ;;
123         esac
124         # other HISTFILE, zsh uses diffrent fmt
125         HISTFILE=~/.historyz
126         # w/o this hist file wont get saved !
127         SAVEHIST=$HISTSIZE
128         ;;
129 esac
130
131 unset SH
132 export PATH PS1 PS2 HOSTNAME HISTFILE HISTSIZE HISTFILESIZE USER LOGNAME MAIL
133
134 for i in /etc/profile.d/*.sh ; do
135         if [ -x $i ]; then
136                 . $i
137         fi
138 done
139
140 unset i
141
142 # vi:syntax=sh
This page took 0.062575 seconds and 4 git commands to generate.