Check all vim colorschemes for minor issues

2013-10-10 231 words 2 mins read

Here is script that checks all the colorschemes in the current directory and corrects them if possible (Processing of the file is done with simple commands like sed, grep)

Checks that the color_name is same as Filename

Here is the script:

#!/bin/bash -
#===============================================================================
#
#          FILE: check_colors.sh
#
#         USAGE: ./check_colors.sh
#
#   DESCRIPTION:
#
#       OPTIONS: ---
#  REQUIREMENTS: ---
#          BUGS: ---
#         NOTES: ---
#        AUTHOR: Amit Agarwal (aka), 
#      REVISION:  ---
#===============================================================================
cd ~/.vim/colors
for i in *vim
do
    #echo "Processing $i"
    if [[ $(grep -c g:colors_name $i ) -eq 0 ]]; then
        if [[ $(grep -c colors_name $i ) -eq 0 ]]; then
            echo "File $i does not have colorname";
            missing=$missing" $i"
        else
            sed -i.bak '/colors_name/ s/.*/let g:colors_name="'${i//.vim}'"/g' $i
        fi
    else
        if [[ $(grep -c colors_name $i|grep let ) -gt 1 ]]; then
            echo "WARN ----->> File $i has more than one colorsname"
        fi
        colorname=$(grep g:colors_name $i|grep let| sed -e 's/"//g' -e 's/.*=//' |tr -d ' ')
        if [[ ${colorname}.vim != $i ]]; then
            echo "Filename $i does not match colorname $colorname .. correcting "
            sed -i.bak '/colors_name/ s/.*/let g:colors_name="'${i//.vim}'"/g' $i
            #sed -i.bak 's/(.*g:colors_name.*=)/1'${i//.vim}'/g' $i
        fi
    fi
done

if [[ x$missing != x ]] ; then
    echo "Missing colornames in $missing"
fi

 

Enhanced by Zemanta

author

Authored By Amit Agarwal

Amit Agarwal, Linux and Photography are my hobbies.Creative Commons Attribution 4.0 International License.

We notice you're using an adblocker. If you like our webite please keep us running by whitelisting this site in your ad blocker. We’re serving quality, related ads only. Thank you!

I've whitelisted your website.

Not now
This website uses cookies to ensure you get the best experience on our website. Learn more Got it