Skip to content

Commit 7b33fd1

Browse files
go tool fixes
1 parent 0ed71cb commit 7b33fd1

File tree

4 files changed

+26
-15
lines changed

4 files changed

+26
-15
lines changed

.zshrc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ export DOT_FILES_PATH=$(dirname $(readlink ~/.zshrc))
33
export DOT_DOT_PATH="${DOT_FILES_PATH}/dot"
44
export DOT_TOOLS_PATH="${DOT_FILES_PATH}/tools"
55

6+
source "${DOT_FILES_PATH}/dot/common.sh"
67
source "${DOT_FILES_PATH}/dot/load.sh"
78

89
# workspaces is either in ~/Projects or in codespaces it's in /codespaces
@@ -23,10 +24,6 @@ PROMPT='%(?.%F{green}√.%F{red}?%?)%f %B%F{250}%1~%f%b %(!.#.$) '
2324

2425
dot_load
2526
dot_help
26-
27-
# "${DOT_FILES_PATH}/dot/tools.sh" "init"
28-
# dot_load_tools
29-
# echo
3027
dot_tools "init"
3128

3229
# codespaces automatically takes you into that repo.

dot/common.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,17 @@ popd () {
1919
command popd "$@" > /dev/null
2020
}
2121

22+
# https://superuser.com/questions/39751/add-directory-to-path-if-its-not-already-there
23+
pathappend() {
24+
for ARG in "$@"
25+
do
26+
if [ -d "$ARG" ] && [[ ":$PATH:" != *":$ARG:"* ]]; then
27+
echo "appending path ${ARG}"
28+
PATH="${PATH:+"$PATH:"}$ARG"
29+
fi
30+
done
31+
}
32+
2233
cprint() {
2334
# https://stackoverflow.com/a/64824268/775184
2435
intense='1'

rc/tools.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ dot_tools() {
3030
"dot_tools_$cmd" "$@"
3131

3232
# reload tools env and paths
33-
dot_tools_init
33+
if [ "$cmd" != "init" ]; then
34+
dot_tools_init
35+
fi
3436
else
3537
dot_tools_ls
3638
fi

tools/go_init

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22
export TOOL_GO_PATH="/usr/local/go/bin"
33
export TOOL_GO_BIN="$HOME/go/bin"
44

5-
init() {
6-
if [ -d ${TOOL_GO_PATH} ]; then
7-
if [ ! -x "$(command -v go)" ]; then
8-
echo "Adding go to PATH"
9-
export PATH=$PATH:${TOOL_GO_PATH}
10-
fi
5+
if [ -d ${TOOL_GO_PATH} ]; then
6+
# -x tests for execute permission and exists
7+
if [ ! -x "$(command -v go)" ]; then
8+
echo "Adding go to PATH"
9+
pathappend "${TOOL_GO_PATH}"
10+
# export PATH=$PATH:${TOOL_GO_PATH}
11+
fi
1112

12-
if [ -d ${TOOL_GO_BIN} ]; then
13-
export PATH=$PATH:${TOOL_GO_BIN}
14-
fi
13+
if [ -d "${TOOL_GO_BIN}" ]; then
14+
pathappend "${TOOL_GO_BIN}"
15+
# export PATH=$PATH:${TOOL_GO_BIN}
1516
fi
16-
}
17+
fi

0 commit comments

Comments
 (0)