HomeSetup Developer Handbook
Standard-Tools
Table of contents
Search related functions
__hhs_search_file
usage: __hhs_search_file <search_path> [file_globs...]
Notes:
** <globs...>: Comma separated globs. E.g: "*.txt,*.md,*.rtf"
Purpose
Search for files and links to files recursively.
Returns
0 on success; non-zero otherwise.
Parameters
- $1 Required : The base search path.
- $2 Required : The search glob expressions.
Examples
__hhs_search_file . '*.properties,*.yaml'
Output
./tests/bats/bats-core/.pre-commit-config.yaml
./gradle/wrapper/gradle-wrapper.properties
./.gradle/7.4/gc.properties
./.gradle/7.4/dependencies-accessors/gc.properties
./.gradle/vcs-1/gc.properties
./.gradle/buildOutputCleanup/cache.properties
./.gradle/7.4.2/gc.properties
./.gradle/7.4.2/dependencies-accessors/gc.properties
./gradle.properties
./assets/colorls/hhs-preset/file_aliases.yaml
./assets/colorls/hhs-preset/dark_colors.yaml
./assets/colorls/hhs-preset/folder_aliases.yaml
./assets/colorls/hhs-preset/folders.yaml
./assets/colorls/hhs-preset/light_colors.yaml
./assets/colorls/hhs-preset/files.yaml
./assets/colorls/orig-preset/file_aliases.yaml
./assets/colorls/orig-preset/dark_colors.yaml
./assets/colorls/orig-preset/folder_aliases.yaml
./assets/colorls/orig-preset/folders.yaml
./assets/colorls/orig-preset/light_colors.yaml
./assets/colorls/orig-preset/files.yaml
__hhs_search_dir
usage: __hhs_search_dir <search_path> [dir_globs...]
Notes:
** <dir_names...>: Comma separated directories. E.g:. "dir1,dir2,dir2"
Purpose
Search for directories and links to directories recursively.
Returns
0 on success; non-zero otherwise.
Parameters
- $1 Required : The base search path.
- $2 Required : The search glob expressions.
Examples
__hhs_search_dir . 'bash*,bin*'
Output
./dotfiles/bash
./bin
./bin/hhs-functions/bash
./bin/completions/bash
./bin/key-bindings/bash
./bin/dev-tools/bash
./bin/apps/bash
./tests/bats/bats-core/bin
./docs/handbook/pages/applications/bash
./templates/bash
__hhs_search_string
usage: __hhs_search_string <search_path> [options] <regex/string> [file_globs]
Options:
-i | --ignore-case : Makes the search case INSENSITIVE.
-w | --words : Makes the search to use the STRING words instead of a REGEX.
-r | --replace <replacement> : Makes the search to REPLACE all occurrences by the replacement string.
-b | --binary : Includes BINARY files in the search.
Notes:
- <file_globs...>: Comma separated file globs. E.g: "*.txt,*.md,*.rtf"
- If <file_globs> is not specified, it will assume "*.*"
Purpose
Search in files for strings matching the specified criteria recursively.
Returns
0 on success; non-zero otherwise.
Parameters
- $1 Required : The base search path.
- $2 Required : The search expression. Can be a regex or just a string.
- $3 Required : The search glob expressions.
Examples
__hhs_search_string /var/log 'apple' '*.log'
Output
/var/log/com.apple.xpc.launchd/launchd.log:1:2023-12-27 16:40:17.298063 (gui/504 [100004]) <Warning>: denied lookup: name = com.apple.contactsd.persistence, requestor = imagent[859], error = 159: Sandbox restriction
/var/log/com.apple.xpc.launchd/launchd.log:2:2023-12-27 16:40:17.904750 (gui/504 [100004]) <Warning>: denied lookup: name = com.apple.audio.audiohald, flags = 0x9, requestor = Microsoft Teams[20877], error = 159: Sandbox restriction
__hhs_search_string . 'timezone:' '*.yaml,*.yml'
Output
./src/main/resources/application.yml:1:timezone: America/Los_Angeles
__hhs_search_string . -r 'timezone: America/Sao_Paulo' 'timezone: America/Los_Angeles' '*.properties,*.yaml'
Output
./src/main/resources/application.yml:1:timezone: America/Sao_Paulo