File: hxtools_profile.bash

package info (click to toggle)
hxtools 20251011-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,468 kB
  • sloc: ansic: 4,384; perl: 3,467; sh: 1,664; cpp: 353; makefile: 90
file content (72 lines) | stat: -rwxr-xr-x 1,518 bytes parent folder | download | duplicates (4)
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
#!/bin/bash

. /etc/hxloginpref.conf >/dev/null 2>/dev/null || :;

if [ "$HXPREF_ENABLE" == "yes" ]; then

hxtools_profile_setsbin ()
{
	local IFS=":";
	local path;
	local sbin;

	set -- $PATH;
	PATH="";

	for path; do
		sbin="";
		if [[ ! -d "$path" ]]; then
			continue;
		fi;
		PATH="$PATH:$path";
		if [[ "$path" == "/bin" || "$path" == "/usr/bin" ||
		      "$path" == "/usr/local/bin" ]]; then
			path="${path/bin/sbin}";
			if [[ -d "$path" ]]; then
				PATH="$PATH:$path";
			fi;
		fi;
	done;
	PATH="${PATH:1}";
}

hxtools_profile_main ()
{
	local isroot=0;
	[[ "$UID" -eq 0 ]] && isroot=1;

	export CVS_RSH="ssh";
	[[ -n "$EDITOR" ]] && export EDITOR;

	if [[ "$HXPREF_SBIN" == yes ]]; then
		hxtools_profile_setsbin;
	fi;

	if [[ "$HXPREF_COLORS" == yes ]]; then
		#
		# See if grep knows about --color, and set inverse-cyan
		#
		grep --color=auto x /dev/null &>/dev/null;
		[[ "$?" -ne 2 ]] && alias grep="command grep --color=auto";
		pcregrep --color=auto x /dev/null &>/dev/null;
		[[ "$?" -ne 2 ]] && alias pcregrep="command pcregrep --color=auto";
		export GREP_COLORS="mt=36;7:se=1;31:ln=36"
		export PCREGREP_COLOR="36;7";
	fi;

	#
	# Retain language across sudo and `bash --login` (which would otherwise
	# re-source /etc/sysconfig/language)
	#
	if [[ -n "$HX_LC_MESSAGES" ]]; then
		export LC_MESSAGES="$HX_LC_MESSAGES";
	else
		export HX_LC_MESSAGES="$LC_MESSAGES";
	fi;
}

hxtools_profile_main;
unset hxtools_profile_main;
unset hxtools_profile_setsbin;

fi; # if [ "$HXPREF_ENABLE" == "yes" ];