Created
June 3, 2023 19:43
-
-
Save aramperes/a02fb3f8ee3fe71fb2a101beb19d015a to your computer and use it in GitHub Desktop.
A leaner __git_ps1 function (~50%) for slow systems
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
# Original __git_ps1 | |
$ time orig__git_ps1 || 0 | |
(my-branch) | |
real 0m1.102s | |
user 0m0.000s | |
sys 0m0.140s | |
# Lean function | |
$ time __git_ps1 || 0 | |
(my-branch) | |
real 0m0.586s | |
user 0m0.000s | |
sys 0m0.077s |
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
# Keep original function definition | |
eval orig"$(declare -f __git_ps1)" | |
function __git_ps1 { | |
set -e | |
branch="$(git rev-parse --abbrev-ref HEAD 2>/dev/null)" | |
echo " ($branch)" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment