Skip to content

Instantly share code, notes, and snippets.

@Genzer
Last active October 29, 2020 03:31
Show Gist options
  • Save Genzer/da565bb8158780c094623933afd67c53 to your computer and use it in GitHub Desktop.
Save Genzer/da565bb8158780c094623933afd67c53 to your computer and use it in GitHub Desktop.
My attempt to list all git aliases plus colors
#!/bin/bash -e
# I went through some hard time editing the ~/.gitconfig and finally gave up because
# escaping the single-quotes was too hard.
# Finally, I left the job to Bash and Git CLI.
# Save for future use.
# CHANGELOG
# v2
# - Change the way to process the alias: replace the first `=` with a `#`.
# - Print the alias's command on the next line.
git config --global alias.alias \
'!f() { git config -l | grep alias | cut -c 7- | sed "s/=/#/" | awk -F"#" "{ print \"\\033[0;31m\"$1\"\\033[0m\" \" = \"$2 }"; }; f'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment