-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcore-utils.sh
More file actions
22 lines (19 loc) · 850 Bytes
/
core-utils.sh
File metadata and controls
22 lines (19 loc) · 850 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/bash
# core-utils.sh
# Core Helper functions
# This regex pattern finds function names in shell scripts. It looks for
# strings that look like `function_name()` and ignores those starting with `_`.
# \K resets the start of the reported match, so we only get the function name itself.
DOTFILES_GREP_PATTERN='^\s*(function\s+)?\K[a-zA-Z_][a-zA-Z0-9_]*(?=\s*\(\))'
# List all function names
_dotfiles_functions_list() {
grep -rhoP "$DOTFILES_GREP_PATTERN" ~/dotfiles/*.sh 2>/dev/null | grep -v '^_' | sort -u
}
# Conditionally enable FZF Ctrl-T integration
if [[ "${ENABLE_DOTFILES_FZF_CTRL_T:-0}" == "1" ]]; then
if command -v fzf >/dev/null 2>&1; then
export FZF_CTRL_T_COMMAND="grep -rhoP \"$DOTFILES_GREP_PATTERN\" ~/dotfiles/*.sh 2>/dev/null | grep -v '^_' | sort -u"
else
echo "fzf not found: install via git clone"
fi
fi