├── imgs ├── main.png ├── time.png ├── colors.png ├── installer.png └── reinstall.png ├── Readme.md ├── colorised_norm_install_installer.sh ├── colorised_norm.sh └── colorised_norm_install.sh /imgs/main.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liftchampion/colorised_Norminette/HEAD/imgs/main.png -------------------------------------------------------------------------------- /imgs/time.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liftchampion/colorised_Norminette/HEAD/imgs/time.png -------------------------------------------------------------------------------- /imgs/colors.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liftchampion/colorised_Norminette/HEAD/imgs/colors.png -------------------------------------------------------------------------------- /imgs/installer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liftchampion/colorised_Norminette/HEAD/imgs/installer.png -------------------------------------------------------------------------------- /imgs/reinstall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liftchampion/colorised_Norminette/HEAD/imgs/reinstall.png -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | # **Colorised Norminette** 2 | 3 | ## Makes the **Norminette**'s output **prettier** and **easier** 4 | ![main_img](https://bitbucket.org/liftchampion/colorised-norminette/raw/73c899c2ecd1dea6d1fdd2c866c0c03a850135e0/imgs/main.png) 5 | 6 | ## **Wide** choice of colors 7 | ![colors_img](https://bitbucket.org/liftchampion/colorised-norminette/raw/73c899c2ecd1dea6d1fdd2c866c0c03a850135e0/imgs/colors.png) 8 | 9 | ## **Nice** and **Easy** installer 10 | ![installer](https://bitbucket.org/liftchampion/colorised-norminette/raw/73c899c2ecd1dea6d1fdd2c866c0c03a850135e0/imgs/installer.png) 11 | 12 | ## With option to delete/reinstall/change colors 13 | ![reinstall](https://bitbucket.org/liftchampion/colorised-norminette/raw/73c899c2ecd1dea6d1fdd2c866c0c03a850135e0/imgs/reinstall.png) 14 | 15 | ## Doesn't make it slower 16 | ![time.png](https://bitbucket.org/liftchampion/colorised-norminette/raw/73c899c2ecd1dea6d1fdd2c866c0c03a850135e0/imgs/time.png) 17 | 18 | # **Installation guide** 19 | Just use that command in your terminal: 20 | 21 | `sh -c "$(curl -s https://bitbucket.org/liftchampion/colorised-norminette/raw/b4272f2c2dac52b1da721ae658815c43f64e5cb2/colorised_norm_install_installer.sh)"` 22 | 23 | Then follow the instructions (or just press *Enter*) 24 | 25 | If you wish to reinstall/modify/delete script, just use the previous command and choose necessary option 26 | 27 | Leave your feedback in Intra: https://forum.intra.42.fr/topics/20818 -------------------------------------------------------------------------------- /colorised_norm_install_installer.sh: -------------------------------------------------------------------------------- 1 | # **************************************************************************** # 2 | # # 3 | # ::: :::::::: # 4 | # colorised_norm_install_installer.sh :+: :+: :+: # 5 | # +:+ +:+ +:+ # 6 | # By: ggerardy +#+ +:+ +#+ # 7 | # +#+#+#+#+#+ +#+ # 8 | # Created: 2019/04/25 18:53:10 by ggerardy #+# #+# # 9 | # Updated: 2019/04/28 20:54:12 by ggerardy ### ########.fr # 10 | # # 11 | # **************************************************************************** # 12 | #!/usr/bin/env bash 13 | 14 | TMP_DIRNAME=~/.tmp_for_installing_norm_script 15 | MAIN_PWD=$(pwd) 16 | echo "\x1B[38;5;202mInstallation in progress...\x1B[0m" 17 | mkdir -p $TMP_DIRNAME 18 | cd $TMP_DIRNAME 19 | TMP_PWD=$(pwd) 20 | git init --quiet 21 | git remote add origin \ 22 | https://liftchampion@bitbucket.org/liftchampion/colorised-norminette.git 2> /dev/null 23 | git fetch --quiet 24 | git checkout --quiet origin/master -- colorised_norm_install.sh 25 | cd $MAIN_PWD 26 | exec ${TMP_PWD}/colorised_norm_install.sh 27 | rm -rf $TMP_DIRNAME 28 | echo "\x1B[38;5;29mDone!\x1B[0m" 29 | -------------------------------------------------------------------------------- /colorised_norm.sh: -------------------------------------------------------------------------------- 1 | # **************************************************************************** # 2 | # # 3 | # ::: :::::::: # 4 | # colorised_norm.sh :+: :+: :+: # 5 | # +:+ +:+ +:+ # 6 | # By: ggerardy +#+ +:+ +#+ # 7 | # +#+#+#+#+#+ +#+ # 8 | # Created: 2019/04/25 18:53:10 by ggerardy #+# #+# # 9 | # Updated: 2019/04/28 20:55:30 by ggerardy ### ########.fr # 10 | # # 11 | # **************************************************************************** # 12 | 13 | #!/usr/bin/env bash 14 | 15 | # Write here color codes you want 16 | ## You can find codes here: http://www.lihaoyi.com/post/Ansi/Rainbow256.png 17 | ### Warning! In your terminal colors may differ 18 | 19 | # ! better way to change colors: 20 | # use installer: 21 | # sh -c "$(curl -s https://bitbucket.org/liftchampion/colorised-norminette/raw/b4272f2c2dac52b1da721ae658815c43f64e5cb2/colorised_norm_install_installer.sh)" 22 | NORM_COLOR=29 23 | NO_NORM_COLOR=202 24 | 25 | norminette $* | awk -v nc="$NORM_COLOR" -v nnc="$NO_NORM_COLOR" ' 26 | BEGIN {buf = "lol"} 27 | { 28 | if (buf != "lol" && $1 == "Norme:") 29 | { 30 | if (buf ~ /Norme:*/) 31 | print "\x1B[38;5;" nc "m" buf "\x1B[0m" 32 | else 33 | print buf 34 | } 35 | else if (buf != "lol") 36 | { 37 | if (buf ~ /Norme:*/) 38 | print "\x1B[38;5;" nnc "m" buf "\x1B[0m" 39 | else 40 | print buf 41 | } 42 | buf = $0 43 | } 44 | END { 45 | if (buf != "lol") 46 | { 47 | if (buf ~ /Norme:*/) 48 | { 49 | print "\x1B[38;5;" nc "m" buf "\x1B[0m" 50 | } 51 | else 52 | { 53 | print buf 54 | } 55 | } 56 | } 57 | ' 58 | -------------------------------------------------------------------------------- /colorised_norm_install.sh: -------------------------------------------------------------------------------- 1 | # **************************************************************************** # 2 | # # 3 | # ::: :::::::: # 4 | # colorised_norm_install.sh :+: :+: :+: # 5 | # +:+ +:+ +:+ # 6 | # By: ggerardy +#+ +:+ +#+ # 7 | # +#+#+#+#+#+ +#+ # 8 | # Created: 2019/04/25 18:53:10 by ggerardy #+# #+# # 9 | # Updated: 2019/05/13 15:49:41 by ggerardy ### ########.fr # 10 | # # 11 | # **************************************************************************** # 12 | 13 | #!/usr/bin/env bash 14 | 15 | DIRNAME=~/.scripts/ 16 | ALIASNAME=norminette 17 | NORM_COLOR=29 18 | NO_NORM_COLOR=202 19 | 20 | ############################# CHECK ZSHRC #################################### 21 | 22 | function check_zshrc { 23 | ISZSHRC=$(find ~ -d 1 -name '.zshrc' 2> /dev/null | wc -w) 24 | if (( $ISZSHRC == 0)); then 25 | echo "No ~/.zshrc found. Sorry" 26 | exit 1 27 | fi 28 | } 29 | ################################ ASK REOPEN ################################## 30 | function ask_reopen { 31 | echo "\x1B[38;5;82mReopen\x1B[0m your \x1B[38;5;82mterminal\x1B[0m, please" 32 | } 33 | 34 | ################ CHECK PREV ALIASES TO COLORISED NORM ######################## 35 | 36 | function get_prev_colors { 37 | NORM_COLOR=$(cat ${DIRNAME}colorised_norm.sh | grep '^NORM_COLOR' | awk -F '=' '{print $2}') 38 | NO_NORM_COLOR=$(cat ${DIRNAME}colorised_norm.sh | grep '^NO_NORM_COLOR' | awk -F '=' '{print $2}') 39 | } 40 | 41 | function find_prev_alias { 42 | PREV_ALIAS_TO_THIS=$(cat ~/.zshrc | grep '^alias.\+/colorised_norm\.sh') 43 | if [[ $PREV_ALIAS_TO_THIS != "" ]]; then 44 | ALIASNAME=$(echo $PREV_ALIAS_TO_THIS | sed 's/alias //g' | \ 45 | awk -F '=' '{print $1}') 46 | DIRNAME=$(echo $PREV_ALIAS_TO_THIS | sed 's/^.*=//g' | \ 47 | awk -F '/' '{$NF=""; print $0}' | tr ' ' '/' | tr -d "'") 48 | get_prev_colors 49 | echo "Found \x1B[38;5;202mexisting\x1B[0m alias to this script:" 50 | echo "alias \x1B[38;5;29m$ALIASNAME\x1B[0m='\x1B[38;5;29m${DIRNAME}colorised_norm.sh\x1B[0m'" 51 | fi 52 | } 53 | ############################# GET ALIASNAME ################################### 54 | 55 | function get_alias_name { 56 | echo "Choose \x1B[38;5;128malias name\x1B[0m (leave blank for '$ALIASNAME'):" 57 | read NEW_ALIASNAME 58 | NEW_ALIASNAME=$(echo $NEW_ALIASNAME | tr -d '\n') 59 | WORDS_IN_NEW_ALIASNAME=$(echo $NEW_ALIASNAME | wc -w) 60 | SAME_ALIASES=$(cat ~/.zshrc | grep "^alias $NEW_ALIASNAME=" | grep -v 'colorised_norm.sh') 61 | SAME_ALIASES_COUNT=$(echo $SAME_ALIASES | wc -w) 62 | if (( $WORDS_IN_NEW_ALIASNAME > 1)) || (( $SAME_ALIASES_COUNT > 0)); then 63 | echo "\x1B[38;5;160mBad aliasname: '$NEW_ALIASNAME'\x1B[0m" 64 | if (( $SAME_ALIASES_COUNT > 0)); then 65 | echo "Alias with this name already exists" 66 | echo $SAME_ALIASES 67 | fi 68 | printf "Try again (Y/n): " 69 | read Q_RES 70 | if [[ "$Q_RES" == 'n' ]] || [[ "$Q_RES" == 'N' ]]; then 71 | exit 0 72 | fi 73 | get_alias_name 74 | elif (( $WORDS_IN_NEW_ALIASNAME == 1 )) ; then 75 | ALIASNAME=$NEW_ALIASNAME 76 | fi 77 | } 78 | 79 | ############################# GET DIRNAME ################################### 80 | function add_slash_to_dirname { 81 | NEW_DIRNAME=$(echo $NEW_DIRNAME | sed 's/\/$//g' | sed 's/$/\//g') 82 | } 83 | 84 | function add_pwd_if_needed { 85 | FIRST_CHAR=$(echo $NEW_DIRNAME | cut -c 1) 86 | SCREENED_PWD=$(pwd | sed 's/\//\\\//g' | sed 's/$/\\\//g') 87 | if [[ "$FIRST_CHAR" != "~" ]] && [[ "$FIRST_CHAR" != "/" ]]; then 88 | NEW_DIRNAME=$(echo $NEW_DIRNAME | sed "s/^/$SCREENED_PWD/g") 89 | fi 90 | } 91 | 92 | function get_dir_name { 93 | echo "Choose \x1B[38;5;128mdirectory\x1B[0m (leave blank for '$DIRNAME'):" 94 | read NEW_DIRNAME 95 | SCREENED_HOME=$(echo $HOME | sed 's/\//\\\//g') 96 | NEW_DIRNAME=$(echo $NEW_DIRNAME | tr -d '\n' | sed "s/~/$SCREENED_HOME/g") 97 | WORDS_IN_NEW_DIRNAME=$(echo $NEW_DIRNAME | wc -w) 98 | if (( $WORDS_IN_NEW_DIRNAME == 0 )); then 99 | NEW_DIRNAME=$DIRNAME 100 | fi 101 | if (( $WORDS_IN_NEW_DIRNAME > 1 )); then 102 | echo "Bad directory: '$NEW_DIRNAME'" 103 | printf "Try again (Y/n): " 104 | read Q_RES 105 | if [[ "$Q_RES" == 'n' ]] || [[ "$Q_RES" == 'N' ]]; then 106 | exit 0 107 | fi 108 | get_dir_name 109 | else 110 | add_pwd_if_needed 111 | add_slash_to_dirname 112 | mkdir -p $NEW_DIRNAME 2> /dev/null 113 | touch "${NEW_DIRNAME}/.test_file_for_installing_colorised_norm" 2> /dev/null 114 | if [ ! -d "$NEW_DIRNAME" ] || [ ! -f "${NEW_DIRNAME}/.test_file_for_installing_colorised_norm" ]; then 115 | echo "\x1B[38;5;160mBad directory: '$NEW_DIRNAME'\x1B[0m" 116 | printf "Try again (Y/n): " 117 | read Q_RES 118 | if [[ "$Q_RES" == 'n' ]] || [[ "$Q_RES" == 'N' ]]; then 119 | exit 0 120 | fi 121 | get_dir_name 122 | else 123 | rm -f "${NEW_DIRNAME}/.test_file_for_installing_colorised_norm" 2> /dev/null 124 | DIRNAME=$NEW_DIRNAME 125 | fi 126 | fi 127 | } 128 | 129 | ######################### RM PREV ALIAS TO THIS ############################### 130 | function rm_prev_alias { 131 | set -e 132 | cat ~/.zshrc | grep -v "$PREV_ALIAS_TO_THIS" > ~/.zshrc.backup.colorised_norm 133 | cat ~/.zshrc.backup.colorised_norm > ~/.zshrc 134 | rm -f ~/.zshrc.backup.colorised_norm 135 | rm -f ${DIRNAME}colorised_norm.sh 136 | set +e 137 | } 138 | 139 | ################################ INSTALL ###################################### 140 | function install_script { 141 | PWD=$(pwd) 142 | TMP_DIRNAME=~/.tmp_for_installing_norm_script 143 | mkdir -p $TMP_DIRNAME 144 | mkdir -p $DIRNAME 145 | cd $TMP_DIRNAME 146 | git init --quiet 147 | git remote add origin \ 148 | https://liftchampion@bitbucket.org/liftchampion/colorised-norminette.git 2> /dev/null 149 | git fetch --quiet 150 | git checkout --quiet origin/master -- colorised_norm.sh 151 | mv colorised_norm.sh "${DIRNAME}colorised_norm.sh" 152 | cd $PWD 153 | rm -rf $TMP_DIRNAME 154 | echo "alias $ALIASNAME='${DIRNAME}colorised_norm.sh'" >> ~/.zshrc 155 | } 156 | 157 | ################################## SETTINGS #################################### 158 | 159 | function print_example { 160 | echo "\nCurrent colors are \x1B[38;5;${NEW_NORM_COLOR}m$NEW_NORM_COLOR\x1B[0m" \ 161 | "\x1B[38;5;${NEW_NO_NORM_COLOR}m$NEW_NO_NORM_COLOR\x1B[0m:" 162 | echo "'\x1B[38;5;${NEW_NO_NORM_COLOR}mNorme: /Users/ggerardy/CLION/FDF/ft_fdf_events.c\x1B[0m" 163 | echo " Error: file must end with a single empty line" 164 | echo " Error (line 127): bad indentation" 165 | echo " \x1B[38;5;${NEW_NORM_COLOR}mNorme: /Users/ggerardy/CLION/FDF/main.c\x1B[0m'\n" 166 | } 167 | 168 | function print_colors { 169 | echo "Possible colors is:\n" 170 | for (( b = 0; b < 16; b++ )) 171 | do 172 | for (( a = 1; a <= 16; a++ )) 173 | do 174 | code=$(( b * 16 + a )) 175 | printf "\x1B[38;5;${code}m%3d\x1B[0m " $code 176 | done 177 | printf "\n" 178 | done 179 | } 180 | 181 | function set_colors { 182 | cat ${DIRNAME}colorised_norm.sh | awk -v nc=$NORM_COLOR -v nnc=$NO_NORM_COLOR \ 183 | '{if ($0 ~ /^NORM_COLOR=/){$0="NORM_COLOR="nc} 184 | if ($0 ~ /^NO_NORM_COLOR=/){$0="NO_NORM_COLOR="nnc} print $0}' > ~/.colorised_norm_color_tmp 185 | cat ~/.colorised_norm_color_tmp > ${DIRNAME}colorised_norm.sh 186 | rm -f ~/.colorised_norm_color_tmp 187 | } 188 | 189 | function read_colors { 190 | echo "Write norm color (leave blank for \x1B[38;5;${NORM_COLOR}m$NORM_COLOR\x1B[0m)" 191 | read NEW_NORM_COLOR 192 | if [[ "$NEW_NORM_COLOR" == "" ]]; then 193 | NEW_NORM_COLOR=$NORM_COLOR 194 | fi 195 | echo "Write NON-norm color (leave blank for \x1B[38;5;${NO_NORM_COLOR}m$NO_NORM_COLOR\x1B[0m)" 196 | read NEW_NO_NORM_COLOR 197 | if [[ "$NEW_NO_NORM_COLOR" == "" ]]; then 198 | NEW_NO_NORM_COLOR=$NO_NORM_COLOR 199 | fi 200 | if ! [[ "$NEW_NORM_COLOR" =~ ^[0-9]+$ ]] || ! [[ "$NEW_NO_NORM_COLOR" =~ ^[0-9]+$ ]] || 201 | (( $NEW_NORM_COLOR > 256 )) || (( $NEW_NO_NORM_COLOR > 256 )) || 202 | (( $NEW_NORM_COLOR <= 0 )) || (( $NEW_NO_NORM_COLOR <= 0 )) 203 | then 204 | echo "\x1B[38;5;160mBad color(s)\x1B[0m" 205 | read_colors 206 | else 207 | print_example 208 | printf "Confirm? [Y/n]:" 209 | read Q_RES 210 | if [[ "$Q_RES" == "n" ]] || [[ "$Q_RES" == "N" ]]; then 211 | read_colors 212 | else 213 | NORM_COLOR=$NEW_NORM_COLOR 214 | NO_NORM_COLOR=$NEW_NO_NORM_COLOR 215 | fi 216 | fi 217 | } 218 | 219 | function change_color { 220 | NEW_NO_NORM_COLOR=$NO_NORM_COLOR 221 | NEW_NORM_COLOR=$NORM_COLOR 222 | print_colors 223 | echo "" 224 | read_colors 225 | set_colors 226 | } 227 | 228 | function ask_color_set { 229 | echo "Would you like to set custom \x1B[38;5;128mcolors\x1B[0m? [y/N]" 230 | read Q_RES 231 | if [[ "$Q_RES" == 'y' ]] || [[ "$Q_RES" == 'Y' ]]; then 232 | change_color 233 | fi 234 | } 235 | 236 | ############################### ASK MODE ###################################### 237 | function ask_mode { 238 | if [[ $PREV_ALIAS_TO_THIS != "" ]]; then 239 | printf "Would you like to Reinstall/Delete/Exit/\x1B[38;5;128mSetColors\x1B[0m?\n[R/d/e/\x1B[38;5;128ms\x1B[0m]: " 240 | read Q_RES 241 | if [[ "$Q_RES" == 'd' ]] || [[ "$Q_RES" == 'D' ]]; then 242 | rm_prev_alias 243 | ask_reopen 244 | exit 0 245 | fi 246 | if [[ "$Q_RES" == 'e' ]] || [[ "$Q_RES" == 'E' ]]; then 247 | exit 0 248 | fi 249 | if [[ "$Q_RES" == 's' ]] || [[ "$Q_RES" == 'S' ]]; then 250 | change_color 251 | exit 0 252 | fi 253 | rm_prev_alias 254 | fi 255 | } 256 | 257 | #################################### MAIN ###################################### 258 | check_zshrc 259 | find_prev_alias 260 | ask_mode 261 | get_alias_name 262 | get_dir_name 263 | install_script 264 | ask_color_set 265 | ask_reopen 266 | --------------------------------------------------------------------------------