⚠️ This post is archived. The content is likely outdated and is kept for historical context only.
I have recently been doing a fair bit of work on some DNS/DHCP appliances that are based on a version of RHEL, as a result I have started to use the Bash shell alot more. In the past on Solaris and HP-UX I have resorted to using KSH and had configured my .profile to pretty much work how I needed.
Although if I really wanted I am sure I could carry on using KSH and update the .profile to work with the RHEL boxes, however how boring. I decided to use Bash (various reason) I thought that I should probably get it to work exactly how I want, so here is my journey.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
########### Source global definitions ################
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
############# set the prompt ##########################
# uncomment out 1 and only one below....
# this is hostname and time
#PS1="\h-(\@): "
# this is hostname and history number
#PS1="\h-(\!)# "
# this is hostname and current working directory
PS1="\h-(\w)# "
# this is hostname and shortened current working directory
#PS1="\h-(\W)# "
############# path manipulation #######################
# add ~/bin to the path, cwd as well
PATH="$PATH:$HOME/bin:./"
################# env variables #######################
export PATH
unset USERNAME
###### User specific aliases and functions ############
|
Another profile that I used a lot when working on a number of Unix hosts;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
export PWD=`pwd`
PS1=`uname -n`_'$LOGNAME # '
export PS1
# Set up search paths
if [ -d $HOME/bin ]
then
export PATH=$PATH:$HOME/bin
fi
if [ -d /opt/tsg/bin ]
then
export PATH=$PATH:/opt/tsg/bin
fi
if [ -d /usr/local/bin ]
then
export PATH=$PATH:/usr/local/bin
fi
if [ -d /usr/openwin/bin ]
then
export PATH=$PATH:/usr/openwin/bin
fi
if [ -d /usr/ucb ]
then
export PATH=$PATH:/usr/ucb
fi
if [ -d /opt/SUNWspro/bin ]
then
export PATH=$PATH:/opt/SUNWspro/bin
fi
PATH=/usr/sbin:$PATH:$HOME:/usr/etc
export PATH
# Set up default creation mask to 755 (directory) and 644 (files)
umask 022
# Set up the shell environment
set -u
trap "echo 'logout'" 0
# Prompt if terminal type is unknown
if [ "$TERM" = unknown ] ; then
export PWD=`pwd`
PS1=`uname -n`_'$LOGNAME # '
export PS1
# Set up search paths
if [ -d $HOME/bin ]
then
export PATH=$PATH:$HOME/bin
fi
if [ -d /opt/tsg/bin ]
then
export PATH=$PATH:/opt/tsg/bin
fi
if [ -d /usr/local/bin ]
then
export PATH=$PATH:/usr/local/bin
fi
if [ -d /usr/openwin/bin ]
then
export PATH=$PATH:/usr/openwin/bin
fi
if [ -d /usr/ucb ]
then
export PATH=$PATH:/usr/ucb
fi
if [ -d /opt/SUNWspro/bin ]
then
export PATH=$PATH:/opt/SUNWspro/bin
fi
PATH=/usr/sbin:$PATH:$HOME:/usr/etc
export PATH
# Set up default creation mask to 755 (directory) and 644 (files)
umask 022
# Set up the shell environment
set -u
trap "echo 'logout'" 0
# Prompt if terminal type is unknown
if [ "$TERM" = unknown ] ; then
echo "Please enter Terminal Type - \c"
read TERM
export TERM
echo
fi
export EXSU=exsu
export TMP=/tmp
if [ `uname -r` = "B.10.20" ]
then
HISTFILE=$TMP/.sh_history.$LOGNAME
export HISTFILE
else
HISTFILE=$HOME/.sh_history
export HISTFILE
fi
HISTSIZE=1024
export HISTSIZE
echo "Checking DISPLAY variable."
export HOSTNAME=`hostname`
DISPLAY2=`who -mu | awk '{ print $8 }' | awk -F: '{ print $1 ":0" }'| sed 's/(//
s/)//'`
if [ `uname -s` = "HP-UX" ]
then
xset -q > /dev/null 2>&1
if [ "$?" != "0" ]
then
export DISPLAY=$DISPLAY2
xset -q > /dev/null 2>&1
if [ "$?" != "0" ]
then
DISPLAY=""
fi
fi
else
export DISPLAY=$DISPLAY2
fi
if [ -z "$DISPLAY" ]
then
echo "Unable to set DISPLAY value.\n\n"
unset DISPLAY
else
echo "Display set to \"$DISPLAY\"\n\n"
fi
|