Various Linux scripts.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

42 lines
935 B

#!/bin/bash
#Создан: чт 14 ноя 2019 14:03:43
#Изменён: Сб 29 фев 2020 02:48:48
# Список псевдонимов git
#
# Формат:
#
# # Комментарий
# name = function
#
# Игнорирование в выводе:
#
# # noindex Комментарий
# или
# name = function #noindex
#
green="\033[1;32m"
rstc="\033[00m"
GITCONFIG=~/.gitconfig
GIT_ALIASES=$(git config --get-regexp 'alias.*' | sed 's/alias.//' | sed 's/ .*//' | sort)
while read -r alias; do
line=$(\grep -n -E "^\s*${alias}\s+" "$GITCONFIG")
number=${line/:*}
full_alias=${line/*:}
name=$(sed "s/^[[:space:]]*//; s/=.*$//g; ${number}q;d" $GITCONFIG)
commentary=$(sed "s/[[:space:]]*# //; $((--number))q;d" $GITCONFIG)
if [[ ! "$full_alias" =~ "noindex" ]] && [[ ! "$commentary" =~ "noindex" ]]; then
printf "${green}%-15s${rstc}- %s\n" "$name" "$commentary"
fi
done <<<"$GIT_ALIASES"