]> git.pld-linux.org Git - projects/setup.git/blob - etc/profile
- added setting of xterm-window title for bash and zsh. TODO: ksh*
[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         # Setup key bindings
131         bindkey -e >/dev/null 2>&1
132         bindkey "^[[1~" beginning-of-line >/dev/null 2>&1
133         bindkey "^[[H" beginning-of-line >/dev/null 2>&1
134         bindkey "^[[4~" end-of-line >/dev/null 2>&1
135         bindkey "^[[F" end-of-line >/dev/null 2>&1
136         bindkey "^[[3~" delete-char >/dev/null 2>&1
137         bindkey "^[[5~" history-search-backward >/dev/null 2>&1
138         bindkey "^[[6~" history-search-forward >/dev/null 2>&1
139
140         case "$TERM" in
141         aterm)
142                 bindkey '^[[A' up-line-or-history >/dev/null 2>&1
143                 bindkey '^[[B' down-line-or-history >/dev/null 2>&1
144                 bindkey '^[[D' backward-char >/dev/null 2>&1
145                 bindkey '^[[C' forward-char >/dev/null 2>&1
146                 ;;
147         xterm*)
148                 precmd () { print -Pn "\e]0;%n@%m: %~\a"i; }
149                 ;;
150         esac
151         # other HISTFILE, zsh uses diffrent fmt
152         HISTFILE=~/.historyz
153         # w/o this hist file wont get saved !
154         SAVEHIST=$HISTSIZE
155         ;;
156 esac
157
158 unset SH
159 export PATH PS1 PS2 HOSTNAME HISTFILE HISTSIZE HISTFILESIZE USER LOGNAME MAIL
160
161 for i in /etc/profile.d/*.sh ; do
162         if [ -x $i ]; then
163                 . $i
164         fi
165 done
166
167 unset i
168
169 # vi:syntax=sh
This page took 0.045085 seconds and 4 git commands to generate.