Skip to content

Commit e457830

Browse files
committed
.bashrc.*: be more robust against different systems
.bashrc host detection stuff was overly fragile and depended on all my variables being set up beforehand (unnecessarily). Also found the writetohistory stuff for emacs tramp sessions probably had been fixed a while ago (we already detect TERM=dumb). I think where I'd seen the TRAMP shell commands being written to history was on systems where I had no control over the .bashrc stuff there and they just unconditionally assumed it was an interactive shell and logged - can't do much about them...
1 parent 7c5ab0d commit e457830

File tree

4 files changed

+14
-22
lines changed

4 files changed

+14
-22
lines changed

files/homes/.bashrc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@ if [ -z "$NONINTERACT" -a -z "$PBS_ENVIRONMENT" ] ; then
6464
hushlogin=".hushlogin.$SHORTHOST"
6565
cd $HOME
6666
[ "$SHORTHOST" != pentane ] &&
67-
echo "$hushlogin : /etc/motd ; :" |
68-
make -f - -q $hushlogin || (
67+
[ $hushlogin -nt /etc/motd ] || (
6968
touch $hushlogin &&
7069
cat /etc/motd &&
7170
echo ------------------------------------------------------------

files/tree/etc/bash.bashrc.d/history.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ function write_history_in_background() {
101101
}
102102

103103
function writetohistory() {
104-
#FIXME: ideally detect when we're inside emacs TRAMP and do nothing
105104
# bt
106105

107106
choosehistoryfile

files/tree/usr/local/bin/colorizecommand

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ highlight "$colour" $bright
163163
# output the header if not asked to run the output directly
164164
if ! $colourall ; then
165165
echo "${args[@]}"
166-
highlight normal y
166+
highlight normal true
167167
fi
168168

169169
normaloutput
@@ -173,6 +173,6 @@ directoutput
173173

174174
#and reset the colour if we were just colourizing the whole output:
175175
if $colourall ; then
176-
highlight normal y
176+
highlight normal true
177177
fi
178178
exit $exit

files/tree/usr/local/bin/colorizeprompt

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,38 @@
22

33
#set -x
44

5-
CHROOTSHORTHOST=$SHORTHOST
5+
CHROOTSHORTHOST="$SHORTHOST"
66

77
if [ -e /etc/hostname ] ; then
88
CHROOTSHORTHOST=`cat /etc/hostname | sed 's/\..*//'`
9-
#elif [ -e /etc/HOSTNAME ] ; then
9+
#elif [ -e /etc/HOSTNAME ] ; then
1010
# CHROOTSHORTHOST=`cat /etc/HOSTNAME | sed 's/\..*//'` #new cluster nodes use dhcp and get the hostname wrong half the time -- since all the boxes I can ever hope to get root on, and hence use chroot, are debian, and debian uses /etc/hostname...
1111
fi
1212

1313

14-
if [ $REALHOST != $LONGHOST ] ; then
15-
CHROOTSHORTHOST=$REALHOST
14+
if [ "$REALHOST" != "$LONGHOST" ] ; then
15+
CHROOTSHORTHOST="$REALHOST"
1616
fi
1717

1818
CHROOT=""
19-
case $CHROOTSHORTHOST in
19+
case "$CHROOTSHORTHOST" in
2020
$SHORTHOST|$SHORTHOST.*)
2121
;;
2222
*)
2323
CHROOT="-`colorize --PS1prompt bright red -n chroot`"
2424
;;
2525
esac
2626

27-
file=$HOME/.bashcolors
28-
if [ ! -r $file ] ; then
29-
file=/etc/bashcolors
30-
fi
31-
32-
if [ ! -r $file ] ; then
33-
echo -n "$USER@$CHROOTSHORTHOST$CHROOT"
34-
exit
35-
fi
36-
37-
cat /etc/bashcolors $HOME/.bashcolors 2>/dev/null | (
27+
{
28+
cat /etc/bashcolors $HOME/.bashcolors 2>/dev/null
29+
echo "root * dark red dark red"
30+
echo "* * bright grey dark blue"
31+
} | (
3832
while read user hostname bu cu bh ch bg ; do
3933
if [ -n "$bg" ] ; then
4034
bg="--background $bg"
4135
fi
42-
case $CHROOTSHORTHOST in
36+
case "$CHROOTSHORTHOST" in
4337
$hostname)
4438
if [[ "$USER" == $user ]] ; then
4539
colorize --PS1prompt $bu $cu -n '\u' #--PS1prompt is to tell colorize to print opening \[ and close \] ; -n is to tell echo to print no newline

0 commit comments

Comments
 (0)