Last active
April 13, 2022 21:08
-
-
Save ThinGuy/a0bba8a3cb600c13e7c0b09c3d592979 to your computer and use it in GitHub Desktop.
Display CPU Flags in a nicely formatted table
This file contains 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
#Using table here: https://bit.ly/gh-cpu-flags | |
show-common-cpu-flags() { | |
declare -ag COL_LEN=($(wget -qO- http://bit.ly/cpu_flags|awk -F\| 'BEGIN { NR==1;getline; H1=$1; H2=$2; H3=$3 } { for (i=1; i<=NF; i++) { max[i] = length($i) > max[i] ? length($i) : max[i] ;ncols = i > ncols ? i : ncols }} END { {print H2":"max[2]"\n"H3":"max[3]"\n"H1":"max[1]"\n"}}')) | |
export LS='─' | |
(printf "%s\n" ${COL_LEN[@]%%:*}|paste -sd\| && printf "%s\n" ${COL_LEN[@]##*:}|xargs -n1 bash -c 'eval printf "%.3s" ${LS}{1..${0}};echo'|paste -sd"|" | |
wget -qO- http://bit.ly/cpu_flags|awk -F\| '/AMD-EXTENDED\||AMD\||INTEL\||V12N\|/{print $2"|"$3"|"$1}')|column -nexts'|'|sed '1,2s/.*$/'$(printf "\e[1m")'&'$(printf "\e[0m")'/' | |
} | |
show-all-cpu-flags() { | |
declare -ag COL_LEN=($(wget -qO- http://bit.ly/cpu_flags|awk -F\| 'BEGIN { NR==1;getline; H1=$1; H2=$2; H3=$3 } { for (i=1; i<=NF; i++) { max[i] = length($i) > max[i] ? length($i) : max[i] ;ncols = i > ncols ? i : ncols }} END { {print H2":"max[2]"\n"H3":"max[3]"\n"H1":"max[1]"\n"}}')) | |
export LS='─' | |
(printf "%s\n" ${COL_LEN[@]%%:*}|paste -sd\| && printf "%s\n" ${COL_LEN[@]##*:}|xargs -n1 bash -c 'eval printf "%.3s" ${LS}{1..${0}};echo'|paste -sd"|" | |
wget -qO- http://bit.ly/cpu_flags|awk -F\| '!/^CLASS/{print $2"|"$3"|"$1}')|column -nexts'|'|sed '1,2s/.*$/'$(printf "\e[1m")'&'$(printf "\e[0m")'/' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment