-
Notifications
You must be signed in to change notification settings - Fork 2
/
.source
32 lines (28 loc) · 1 KB
/
.source
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
#!/usr/bin/env bash
# source only once
if ! command -v init_dotfiles >/dev/null 2>&1; then
_profile=${BASH_SOURCE:-$0}
# ------------------------------------------------------------------------------
if ! command -v realpath >/dev/null; then
_realpath() {
local _l _d
_l=$1
if [ -L "$_l" ]; then
_l=$(readlink "$_l") || return $?
# If symlink is relative:
if [ "${_l:0:1}" != "/" ]; then
_d=$(dirname "$1")
[ "$_d" = "." ] && _d=${PWD:-$(pwd)}
[ "$_d" != "." ] && [ -n "$_d" ] && _l="$_d/$_l"
fi
fi
echo "$_l"
[ -e "$_l" ]
}
_dotfiles=$(dirname "$(_realpath "$_profile")")
. "$_dotfiles/src/realpath/.realpath"
fi
# ------------------------------------------------------------------------------
_profile=$(realpath "$_profile")
. "$(dirname "$_profile")/~/source"
fi