This repository has been archived on 2024-03-04. You can view files and clone it, but cannot push or open issues or pull requests.
linux/.config/bash/module/Find.sh

27 lines
698 B
Bash
Raw Normal View History

2023-11-25 23:24:09 +03:00
# Find all file extensions.
2023-12-07 01:44:42 +03:00
function find_ext() {
2023-12-05 21:50:45 +03:00
local types=($(find -type f | sed -e "s/.*\///" -e "s/^\.//" -e "/\./!d" -e "s/.*\.//"))
echo "${types[@]}" | tr ' ' '\n' | sort -u
}
2023-12-07 01:44:42 +03:00
2023-12-07 04:51:23 +03:00
# Find all modules.
function find_module() {
ls "${BASH_MODULE_PATH}" | sed -e "s/.sh$//"
}
2023-12-07 01:44:42 +03:00
# Find all module functions.
2023-12-07 04:51:23 +03:00
# Functions from all modules by default.
# Usage: find_function [MODULE]
function find_function() {
local module="${1}"
[[ "${module}" = "" ]] && module="*"
cat "${BASH_MODULE_PATH}"/${module}.sh | grep "^function.*()" | sed -e "s/^function //" -e "s/().*//"
2023-12-07 01:44:42 +03:00
}
# Autocomplete with module.
_find_module() {
_autocomplete_first $(find_module)
}
complete -F _find_module find_function