-
Notifications
You must be signed in to change notification settings - Fork 0
/
paths_util.sh
193 lines (148 loc) · 5.97 KB
/
paths_util.sh
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
#!/usr/bin/env bash
# vim:tw=0:ts=2:sw=2:et:norl:ft=sh
# Author: Landon Bouma (landonb @ retrosoft . com)
# Project: https://github.com/landonb/home-fries#🍟
# License: MIT
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #
check_deps () {
check_dep 'path_prefix'
check_dep 'path_suffix'
}
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #
# Some of the standard system path components will already exist, but
# set them here so our code reorders these, keeping them clustered
# together.
home_fries_add_to_path_bins () {
# No whep. 2016.04.28 and this is the first time I've seen this.
# $ ifconfig
# Command 'ifconfig' is available in '/sbin/ifconfig'
# The command could not be located because '/sbin' is not included in the PATH environment variable.
# This is most likely caused by the lack of administrative privileges associated with your user account.
# ifconfig: command not found
path_prefix "/sbin"
path_prefix "/bin"
}
home_fries_add_to_path_usr_bins () {
path_prefix "/usr/sbin"
path_prefix "/usr/bin"
}
home_fries_add_to_path_usr_local_bins () {
# 2020-08-26: On macOS, default `bash --noprofile --norc` PATH is:
# /usr/bin:/bin:/usr/sbin:/sbin
# Where's /usr/local/bin? Did I do something to mess it up?
path_prefix "/usr/local/sbin"
path_prefix "/usr/local/bin"
}
# For MacPorts. [2021-08-20: That I installed and then uninstalled.
# Nonetheless, seems useful to at least check for /opt/local/s?bin.]
home_fries_add_to_path_opt_local_bins () {
path_prefix "/opt/local/bin"
# 2021-08-04: Interesting. Just one sbin file. And not sure if
# they mean the prefix literally or not. It's an empty file.
# /opt/local/sbin/.turd_MacPorts
path_prefix "/opt/local/sbin"
}
# ++++++++++++++++++++++++++++++ #
home_fries_add_to_path_home_fries_lib () {
# Make sourcing Home Fries files easy.
path_prefix "${HOMEFRIES_DIR}/lib"
}
home_fries_add_to_path_home_fries_bin () {
# Make Home Fries commands available.
path_prefix "${HOMEFRIES_DIR}/bin"
}
home_fries_add_to_path_home_local_bin () {
# Make commands installed by Zoidy Pooh et al available.
# E.g., ~/.local/bin is where `pip install --user blah` installs.
# And where zoidy_apps_et_al installs non-apt/-snap applications.
path_prefix "${HOME}/.local/bin"
}
# ++++++++++++++++++++++++++++++ #
# MEH/2019-09-16: Some of these paths are author-specific.
# But they're also paths to commands installed via Zoidy Pooh Ansible.
# So it's not that much of a stretch to include them herein, as
# opposed to moving to the author's private startup script.
# MAYBE/2019-09-16: You could move these Java-/Android-, and golang-specific functions
# to new language-specific files, e.g., .homefries/lib/java_util.sh, golang_util.sh.
home_fries_add_to_path_java_jdk_jre () {
local install_dir="${HF_DOWNLOADS_DIR:-${HOME}/.downloads}"
local jdk_dir="${install_dir}/jdk"
if [ -d "${jdk_dir}" ]; then
# FIXME/2019-09-16: Seems like a weird side-effect of updating PATH
# to also be exporting other variables.
export JAVA_HOME="${jdk_dir}"
export JRE_HOME="${JAVA_HOME}/jre"
path_suffix "${JAVA_HOME}/bin"
path_suffix "${JRE_HOME}/bin"
fi
}
home_fries_add_to_path_android_studio () {
local install_dir="${HF_DOWNLOADS_DIR:-${HOME}/.downloads}"
path_suffix "${install_dir}/android-studio/bin"
path_suffix "${install_dir}/android-sdk/platform-tools"
# 2017-02-25: Have I been missing ANDROID_HOME for this long??
local sdk_dir="${install_dir}/Android/Sdk"
if [ -d "${sdk_dir}" ]; then
# FIXME/2019-09-16: Seems like a weird side-effect of updating PATH
# to also be exporting other variables.
export ANDROID_HOME=${install_dir}/Android/Sdk
path_suffix "${ANDROID_HOME}/tools"
fi
}
home_fries_add_to_path_golang () {
local go_dir="${HOME}/.gopath"
if [ -d "${go_dir}" ]; then
# FIXME/2019-09-16: Seems like a weird side-effect of updating PATH
# to also be exporting other variables.
export GOPATH="${go_dir}"
# You can check GOPATH with: `go env`.
path_prefix "${GOPATH}/bin"
path_prefix "${GOPATH}"
fi
}
# 2023-04-20 16:32: Last Ubuntu 22.04/Linux Mint 21.1 installs
# apt's `fd-find`'s `fd` to /usr/lib/cargo/bin/fd (was /usr/bin/fd).
home_fries_add_to_path_rust_cargo_bin () {
path_suffix "/usr/lib/cargo/bin"
}
# ++++++++++++++++++++++++++++++ #
home_fries_set_path_environ () {
# Add systemwide path prefixes first, so the the
# local paths added later take precedence.
home_fries_add_to_path_bins
unset -f home_fries_add_to_path_bins
home_fries_add_to_path_usr_bins
unset -f home_fries_add_to_path_usr_bins
home_fries_add_to_path_usr_local_bins
unset -f home_fries_add_to_path_usr_local_bins
home_fries_add_to_path_opt_local_bins
unset -f home_fries_add_to_path_opt_local_bins
# ++++++++++++++++++++++++++++++ #
home_fries_add_to_path_java_jdk_jre
unset -f home_fries_add_to_path_java_jdk_jre
home_fries_add_to_path_android_studio
unset -f home_fries_add_to_path_android_studio
home_fries_add_to_path_golang
unset -f home_fries_add_to_path_golang
home_fries_add_to_path_rust_cargo_bin
unset -f home_fries_add_to_path_rust_cargo_bin
# ++++++++++++++++++++++++++++++ #
home_fries_add_to_path_home_local_bin
unset -f home_fries_add_to_path_home_local_bin
home_fries_add_to_path_home_fries_lib
unset -f home_fries_add_to_path_home_fries_lib
# 2020-12-16: Until now, it did not matter that ~/.homefries/bin
# followed ~/.local/bin in PATH (first two entries), but now I've
# added a reset utility (promoted alias to function to file). So
# ~/.homefries/bin should be V. First. Also because it's closest
# to home (and ~/.local/bin is mostly third-party, second-class).
home_fries_add_to_path_home_fries_bin
unset -f home_fries_add_to_path_home_fries_bin
}
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #
main () {
check_deps
unset -f check_deps
}
main "$@"
unset -f main