25 lines
898 B
Bash
Executable file
25 lines
898 B
Bash
Executable file
#!/bin/bash
|
|
#set -euo pipefail
|
|
|
|
# Use 'declare -p' to list all aliases in a more parseable format
|
|
# alias_output=$(declare -p alias | sed 's/^alias \([^=]\+\)='\''\([^'\'']*\)'\''$/\1='\''\2/' | sed "s/'/'\''/g")
|
|
|
|
list_aliases() {
|
|
shopt -s expand_aliases
|
|
alias
|
|
}
|
|
|
|
# Print header for the table
|
|
printf "%-20s\t%s\n" "Alias" "Command"
|
|
printf "%-20s\t%s\n" "-----" "-------"
|
|
|
|
# Iterate over each alias and extract its name and definition
|
|
list_aliases | while IFS='=' read -r alias_name alias_command; do
|
|
# Extract alias name and definition
|
|
#alias_name=$(echo "$line" | cut -d '=' -f 1)
|
|
#alias_command=$(echo "$line" | cut -d '=' -f 2- | sed "s/'//g")
|
|
alias_command="$(echo -e "${alias_command}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
|
|
# Print alias name and corresponding command in tabular format
|
|
printf "%-20s\t%s\n" "$alias_name" "$alias_command"
|
|
done
|
|
|