Check all vim colorschemes for minor issues
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
Related articles
Related Articles:
- 2012/03/14 cream bash ide – vim with bash support
- 2012/02/15 Get yourself som new themes for vim
- 2011/11/05 g flag in :s useless in vim
- 2010/04/11 bash script to change vim colorscheme based on the available themes
- 2012/08/06 vim mappings for multiple files.
Authored By Amit Agarwal
Amit Agarwal, Linux and Photography are my hobbies.Creative Commons Attribution 4.0 International License.