bash script to change vim colorscheme based on the available themes

Image via Wikipedia

Here\’s one script that you may find useful. A little variation or wrapper for this script can make your life colorful 🙂

You can write a wrapper to this to take one of the inputs randomly and then use it in alias to start vim.

#!/bin/bash –
#          FILE:
#         USAGE:  ./
#   DESCRIPTION: Change the vim colorscheme from command prompt
#       OPTIONS:  —
#          BUGS:  —
#         NOTES:  —
#        AUTHOR:  Amit Agarwal (AKA),
#       COMPANY:  Individual
#       VERSION:  1.0
#       CREATED:  02/02/2010 10:30:07 PM IST
#      REVISION:  —

#Change the directory to where we will find all colors and then print them 🙂
cd ~/.vim/colors
for i in *.vim
echo \”${i%.vim}\”
#Read the choice of the user

read -p \”Enter one of the colorschemes :: \” choice
if [ ! -f $file ]
echo \”Colorscheme file \”$file\” does not exist\”
exit -1

#Do the susbstitution in new file in /tmp
sed \’s#\\(^ *colorscheme\\).*#\\1 \’$choice\’#\’ ~/.vimrc > /tmp/vimrc
diff ~/.vimrc /tmp/vimrc
read -p \”Do you want to make the changes (y/n) :: \” yn
if [ $yn = \”y\” ]
echo {/tmp/,~/.}vimrc
cp {/tmp/,~/.}vimrc
echo \”Modified changes are available in /tmp/vimrc\”


5 thoughts on “bash script to change vim colorscheme based on the available themes”

This site uses Akismet to reduce spam. Learn how your comment data is processed.