Skip to content

Commit ceed773

Browse files
authored
Update .bashrc
1 parent 8b9c57e commit ceed773

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Linux/.bashrc

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
#-------------------------------------------------------------------------------#
1717
#shellcheck disable=SC1090,SC1091,SC2034,SC2142,SC2148
18-
export BASHRC_SRC_VER="v0.0.1"
18+
export BASHRC_SRC_VER="v0.0.1+1"
1919
##Is Interactive?
2020
export BASH_IS_INTERACTIVE="0"
2121
case $- in
@@ -325,7 +325,15 @@ function nixbuild_static()
325325
export -f nixbuild_static
326326
function refreshenv()
327327
{
328-
source "$(realpath "${HOME}/.bashrc" | tr -d '[:space:]')"
328+
local BASHRC_FILE="$(realpath "${HOME}/.bashrc" | tr -d '[:space:]')"
329+
if [[ -f "${BASHRC_FILE}" ]]; then
330+
source "${BASHRC_FILE}"
331+
if command -v sed &>/dev/null; then
332+
sed -n '/^\s*export\s\+BASHRC_SRC_VER=/s/^\s*export\s\+//p' "${BASHRC_FILE}"
333+
elif command -v grep &>/dev/null; then
334+
grep -oP '^\s*export\s+\K(BASHRC_SRC_VER="[^"]+")' "${BASHRC_FILE}"
335+
fi
336+
fi
329337
}
330338
export -f refreshenv
331339
function refresh_bashrc()

0 commit comments

Comments
 (0)