Quick Linux Tip #125:
Question: Why does my bash shell take 3 seconds to start?
Try: PS4='+ $EPOCHREALTIME\011 ' bash -x -lic exit 2>&1 | awk '/^\+/{if (prev) print $2-prev, cmd; prev=$2; cmd=$3" "$4" "$5}' | sort -rn | head -10
Info: Times and sorts bash startup commands to isolate performance bottlenecks.
Examples:
- $
time bash -lic exit# Measure total shell startup duration - $
bash -lx 2>startup.log# Output a complete startup execution trace to a file - $
bash --noprofile --norc# Launch a clean shell bypassing all initialization files
Note: Common performance bottlenecks include heavy framework plugins, version managers (like NVM/RVM), and large completion scripts. Use lazy-loading functions or lightweight prompt engines to optimize load times.
Leave a Reply