]> git.pld-linux.org Git - projects/setup.git/blob - etc/profile
- moved from zsh.spec into proper place.
[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 /usr/local/bin || PATH="$PATH:/usr/local/bin"
9 echo "$PATH" | grep -q "$HOME/bin" || PATH="$PATH:$HOME/bin"
10
11 if [ `id -gn` = `id -un` -a `id -u` -gt 14 ]; then
12         umask 002
13 else
14         umask 022
15 fi
16
17 USER=`id -un`
18 LOGNAME=$USER
19
20 HOSTNAME=`/bin/uname -n`
21 HISTFILE="$HOME/.history"
22 HISTSIZE=1000
23 HISTFILESIZE=1000
24
25 # home_etc user config-dirs
26 #CONFIG_DIR=etc
27 #export CONFIG_DIR
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         case $TERM in
54                 xterm*)
55                         PS1="\[\033]0;\u@\h: \w\007\][\u@\h \W]\\$ "
56                         ;;
57                 *)
58                         PS1="[\u@\h \W]\\$ "
59                         ;;
60         esac
61         ;;
62   ksh|pdksh)
63         if [ `id -u` -eq 0 ]; then
64                 PS1='[${LOGNAME-$USER}@${HOSTNAME} `
65                         if [ "$PWD" = "/${PWD##*/}" ]; then
66                                 echo $PWD;
67                         else
68                                 echo ${PWD##*/};
69                 fi`]# '
70         else
71                 PS1='[${LOGNAME-$USER}@${HOSTNAME} `
72                         if [ "$PWD" = "/${PWD##*/}" ]; then
73                                 echo $PWD;
74                         else
75                                 echo ${PWD##*/};
76                 fi`]$ '
77         fi
78         PS2='> '
79         set -o emacs
80         bind '^I'=complete >/dev/null 2>&1
81         bind '^[^I'=complete-list >/dev/null 2>&1
82         #
83         # Setup some of the most basic editing functions
84         # to work properly under different termnal emulators.
85         #
86         case $TERM in
87         nxterm|xterm|xterm-color|rxvt)
88                 bind '^[[H'=beginning-of-line >/dev/null 2>&1
89                 bind '^[[F'=end-of-line >/dev/null 2>&1
90                 ;;
91         linux)
92                 bind '^[1~'=beginning-of-line >/dev/null 2>&1
93                 bind '^[4~'=end-of-line >/dev/null 2>&1
94                 ;;
95         esac
96         ;;
97   ksh93)
98         if [ `id -u` -eq 0 ]; then
99                 PS1='[${LOGNAME-$USER}@${HOSTNAME} `
100                         if [ "$PWD" = "/${PWD##*/}" ]; then
101                                 echo $PWD;
102                         else
103                                 echo ${PWD##*/};
104                 fi`]# '
105         else
106                 PS1='[${LOGNAME-$USER}@${HOSTNAME} `
107                         if [ "$PWD" = "/${PWD##*/}" ]; then
108                                 echo $PWD;
109                         else
110                                 echo ${PWD##*/};
111                 fi`]$ '
112         fi
113         PS2='> '
114         set -o nolog
115         set -o emacs
116         case $TERM in
117         nxterm|xterm|xterm-color|rxvt)
118                 trap 'case ${.sh.edchar} in  "\e[F") .sh.edchar="\ 5" ;; "\e[H") .sh.edchar="\ 1" ;; esac' KEYBD
119                 ;;
120         linux)
121                 trap 'case ${.sh.edchar} in  "\e[4~") .sh.edchar="\ 5" ;; "\e[1~") .sh.edchar="\ 1" ;; esac' KEYBD
122                 ;;
123         esac
124         ;;
125   zsh)
126         PS1='[%n@%m %~]%(!.#.%\$) '
127         RPS1="%T"
128         export RPS1
129
130         # aliases:
131         alias which=whence
132
133         # Setup key bindings:
134         bindkey -e >/dev/null 2>&1
135         bindkey "^[[1~" beginning-of-line >/dev/null 2>&1
136         bindkey "^[[H" beginning-of-line >/dev/null 2>&1
137         bindkey "^[[4~" end-of-line >/dev/null 2>&1
138         bindkey "^[[F" end-of-line >/dev/null 2>&1
139         bindkey "^[[3~" delete-char >/dev/null 2>&1
140         bindkey "^[[5~" history-search-backward >/dev/null 2>&1
141         bindkey "^[[6~" history-search-forward >/dev/null 2>&1
142
143         # xterm:
144         bindkey \`tput khome\` beginning-of-line >/dev/null 2>&1
145         bindkey \`tput kend\` end-of-line >/dev/null 2>&1
146         bindkey \`tput kdch1\` delete-char >/dev/null 2>&1
147         bindkey \`tput kpp\` up-history >/dev/null 2>&1
148         bindkey \`tput knp\` end-of-history >/dev/null 2>&1
149         bindkey \`tput kcuu1\` history-beginning-search-backward >/dev/null 2>&1
150         bindkey \`tput kcud1\` history-beginning-search-forward >/dev/null 2>&1
151
152         case "$TERM" in
153         aterm)
154                 bindkey '^[[A' up-line-or-history >/dev/null 2>&1
155                 bindkey '^[[B' down-line-or-history >/dev/null 2>&1
156                 bindkey '^[[D' backward-char >/dev/null 2>&1
157                 bindkey '^[[C' forward-char >/dev/null 2>&1
158                 ;;
159         xterm*)
160                 precmd () { print -Pn "\e]0;%n@%m: %~\a"i; }
161                 ;;
162         esac
163         # other HISTFILE, zsh uses diffrent fmt
164         HISTFILE=~/.historyz
165         # w/o this hist file wont get saved !
166         SAVEHIST=$HISTSIZE
167         ;;
168 esac
169
170 unset SH
171 export PATH PS1 PS2 HOSTNAME HISTFILE HISTSIZE HISTFILESIZE USER LOGNAME MAIL
172
173 for i in /etc/profile.d/*.sh ; do
174         if [ -x $i ]; then
175                 . $i
176         fi
177 done
178
179 unset i
180
181 # vi:syntax=sh
This page took 0.047847 seconds and 3 git commands to generate.