How do I restrict the number of digits in the REPL display?

To use a variable in the Printf format string, see for example this post.

You could define your function in the startup.jl file.