dotfiles

My collection of dotfiles
git clone git://git.noxz.tech/dotfiles
Log | Files | Refs

print-sxhkd (1040B)


      1 #!/bin/sh
      2 
      3 raw="$(sed -e 's/shift + \([a-z]\)$/\U\1/g' ~/.config/sxhkd/sxhkdrc | awk '
      4 BEGIN {
      5 	first   = 1;
      6 	desc    = "";
      7 	len     = 0;
      8 }
      9 desc!="" {
     10 	printf "|%s|%s|\n", $0, desc;
     11 	desc    = "";
     12 }
     13 match($0, /# ---([^-]*)/, a) {
     14 	if (!first) printf "\n";
     15 	printf "#%s#\n", substr($0, 6, RLENGTH - 5);
     16 	first   = 0;
     17 }
     18 /# :.*/ {
     19 	 desc    = substr($0, 4);
     20 }
     21 {
     22 	if (length > len) len = length;
     23 }
     24 END {
     25 	print len;
     26 }
     27 ')"
     28 length="$(echo "$raw" | sed '$!d')"
     29 
     30 echo "$raw"                                     \
     31 | sed '$d'                                      \
     32 | pr                                            \
     33 	-t                                          \
     34 	-"$((($(tput cols)+$length-1)/$length))"    \
     35 	-w "$(tput cols)"                           \
     36 | sed                                           \
     37 	-e "s/|\([^#|]*\)|\([^|]*\)|/`printf        \
     38 		"\033[38;1;255m"`\1`printf              \
     39 		"\033[0m"` \2  /g"                      \
     40 	-e "s/#\([^#]*\)#/`printf                   \
     41 		"\033[48;5;255m\033[30m"`\1`printf      \
     42 		"\033[0m  "`/g"