Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion .aliases_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,24 @@ define(){
declare -f $1 | bat --style numbers,grid --language sh || return 0 # declare only on functions, don't error out if $1 is an alias
}

# Shows definition of all functions that match the passed string (case insensitive). TODO: support aliases as well
define_all() {
local function_names=""

if [ -n "$BASH_VERSION" ]; then
function_names=$(declare -F | awk '{print $3}')
elif [ -n "$ZSH_VERSION" ]; then
function_names=$(print -l ${(k)functions})
fi

matches=$(echo $function_names | grep -i $1)

# ${=var} splits the string on whitespace into an array. Only required for zhs, in bash this is a noop and works as expected.
for match in ${=matches}; do
define $match
done
}

# default: returns a default value if STDIN is empty, otherwise return STDIN
default() {
grep . || echo $1
Expand Down Expand Up @@ -465,4 +483,4 @@ EOF

export TABLEAU_SITE_ID=$(tableau_get "/sites" | jq -r ".sites.site[] | select(.contentUrl == \"$TABLEAU_CONTENTURL\").id")
cenv TABLEAU_SITE_ID
}
}