aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/sh/.profile
blob: 0b1d17571c387ea86501c4643e6777339ee2d43d (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
#!/bin/sh
# shellcheck disable=1090,2046

# Most of this script is a user scoped version of /etc/profile

# Prepend "$1" to $PATH when not already in.
# This function API is accessible to scripts in $XDG_CONFIG_HOME/profile.d
prepend_path() {
	case ":$PATH:" in
	*:"$1":*) ;;
	*)
		PATH="$1${PATH:+:$PATH}"
		;;
	esac
}

# Use systemd-environment-d-generator(8) to generate environment, and export those variables
#
# See: https://wiki.archlinux.org/title/Environment_variables#Per_Wayland_session
for generator in /usr/lib/systemd/user-environment-generators/*; do
	export $($generator | xargs)
done

# Load profiles from $XDG_CONFIG_HOME/profile.d
if test -d "$XDG_CONFIG_HOME"/profile.d/; then
	for profile in "$XDG_CONFIG_HOME"/profile.d/*.sh; do
		test -r "$profile" && . "$profile"
	done
	unset profile
fi

prepend_path "$HOME/.local/bin"

# Force PATH to be environment
export PATH

# Unload our profile API functions
unset -f append_path