Last active
August 23, 2023 12:02
-
-
Save sebastiancarlos/6bdab0fcabe62818e9d04a77d31254c3 to your computer and use it in GitHub Desktop.
Custom version of "declare -F" with filename and line number.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# All my gist code is licensed under the terms of the MIT license. | |
# Video demo: https://www.youtube.com/shorts/q26DJ5qOXxM | |
# custom declare -F | |
# - add filename and table output to "declare -F" | |
# - this is based on the "declare -F name" output when shopt extdebug is on | |
function declare () { | |
if [[ $# == 1 && "$1" == "-F" ]]; then | |
shopt -s extdebug | |
source <( | |
command declare -F | \ | |
awk ' | |
{ | |
print "declare -F " $NF; | |
}' | |
) | \ | |
sed -E "s|$HOME|~|g" | \ | |
column -t | |
shopt -u extdebug | |
else | |
command declare "$@"; | |
fi; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment