It would be nice to have a option to set a file extension on the temporary file used to read from stdin, so we can handle syntax on these contexts too.
Here's an use case where I'd try to just print a function definition from type with syntax enabled:
alias ?=wat
function wat() {
shopt -s extdebug
declare -F $1
shopt -u extdebug
typedef=$(type $1)
# Prints the debug output without highlighting
echo "$typedef" | head -n1
typedef=$(echo "$typedef" | tail -n+2)
if [[ ! -z $typedef ]]; then
if tty -s; then
# Prints the function definition with syntax highlighting
# '-s sh' produces /tmp/tmp.aP6kTGvrLT.sh so nvim reads it as a shell script
echo "$typedef" | nvimpager -c -s sh
else
echo "$typedef"
fi
fi
}
It would be nice to have a option to set a file extension on the temporary file used to read from stdin, so we can handle syntax on these contexts too.
Here's an use case where I'd try to just print a function definition from
type
with syntax enabled:Does that make sense?