-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbash
More file actions
33 lines (28 loc) · 954 Bytes
/
Copy pathbash
File metadata and controls
33 lines (28 loc) · 954 Bytes
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
# functions used by the functions in this file, must be declared before use by other functions
describe() {
local explain="$1"
local description="$2"
if [[ "$explain" == "true" ]]; then
echo "$description"
return 0
fi
return 1
}
,() {
printf "%-20s | %s\n" "Function Name" "Description"
printf "%-20s | %s\n" "--------------------" "--------------------"
declare -F | awk '{print $3}' | grep -oE '^,[a-zA-Z_][a-zA-Z0-9_-]*' | while read -r func; do
desc=$("$func" "true" 2>/dev/null) # Call each function with "true" and suppress errors
if [[ -n "$desc" ]]; then
printf "%-20s | %s\n" "$func" "$desc"
fi
done
}
# Acts as a template on how to structure your functions to make use of ,() properly
,functions() {
local description="Opens functions file in use on VS Code"
if describe "$1" "$description"; then
return 0
fi
code "$DIR/bash"
}