about summary refs log tree commit diff stats
path: root/shrc
blob: 135b2169736d0cbf3d01dc8867eeb5ea128f66d5 (plain)
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
# ~/.shrc -*- sh -*-

case $- in			# only do these things in interactive shells
	*i*) . ~/.profile ;;
	*) return ;;
esac

# Prompt

ecdollar() {
	case $? in
		(0) return ;;
		(*) printf '*%s ' "$?" ;;
	esac
}

pwd_tilde() {
	printf '%s' "$PWD" | sed 's,'"$HOME"',~,'
}

case "$0" in
	*ksh)
		PS1=$'\1\r$(smileycode)\1 '
		PS1+=$'\1\e[34m\1$(pwd_tilde)\1\e[0m\1 '
		PS1+=$'$ '
		;;
	*bash)
		#PS1='$(ecdollar)\$ \[\e[4m\]\w\[\e[0m\] > '
		PS1='\[\e[1m\]($(ecdollar) \w )\[\e[0m\] '
		;;
esac

# Aliases
alias ls='ls --color=none -F '
alias ll='ls -Al'

alias sudo=$SUDO
for cmd in shutdown reboot halt mount umount poweroff zzz ZZZ
do alias $cmd="$SUDO $cmd"
done

# installedp is in ~/.profile
if installedp bc
then export BC_ENV_ARGS='-lq'
fi

if installedp less
then export LESS='--mouse --RAW-CONTROL-CHARS'
fi

if installedp apk
then
	_apk() (
		apk=$(which apk)
		case "$1" in
			(add|del|update|upgrade) $SUDO "$apk" "$@" ;;
			(*) "$apk" "$@" ;;
		esac
	)
	alias apk=_apk
fi

if installedp rlwrap
then
	for cmd in sbcl
	do alias $cmd="rlwrap $cmd"
	done
fi