bash script to change the vim colorscheme from the list of locally available schemes

\"MacVim
Image via Wikipedia

Today I was just wondering how good it would be to have a script to change the <a class="zem_slink freebase/en/vim" title="Vim (text editor)" rel="homepage" href="http://www.vim.org/">vim colorscheme from the <a class="zem_slink freebase/en/cmd_exe" title="Command Prompt" rel="wikipedia" href="http://en.wikipedia.org/wiki/Command_Prompt">command prompt. The plan for the script was simply to print the list of available schemes and then let the user select the actions from there on. So, here is the result:

#!/bin/bash –
#===============================================================================

#          FILE:  change_vim_colorscheme.sh

#         USAGE:  ./change_vim_colorscheme.sh

#   DESCRIPTION: Change the vim colorscheme from command prompt

#       OPTIONS:  —
#  REQUIREMENTS:  —
#          BUGS:  —
#         NOTES:  —
#        AUTHOR:  <a class="zem_slink" title="Amit Agarwal" rel="me" href="http://amit-agarwal.co.in">Amit Agarwal (AKA), amit.agarwal@amit-agarwal.co.in
#       COMPANY:  Individual
#       VERSION:  1.0
#       CREATED:  02/02/2010 10:30:07 PM IST
#      REVISION:  —
#===============================================================================

cd ~/.vim/colors
for i in *.vim
do
echo &#8221;${i%.vim}&#8221;
done

read -p &#8221;Enter one of the colorschemes :: &#8221; choice
file=~/.vim/colors/$choice.vim
if [ ! -f $file ]
then
echo &#8221;Colorscheme file &#8221;$file&#8221; does not exist&#8221;
exit -1
fi

sed &#8217;s#\(^ *colorscheme\).*#\1 &#8217;$choice&#8217;#&#8217; ~/.vimrc > /tmp/vimrc
diff ~/.vimrc /tmp/vimrc
read -p &#8221;Do you want to make the changes (y/n) :: &#8221; yn
if [ $yn = &#8221;y&#8221; ]
then
echo {/tmp/,~/.}vimrc
cp {/tmp/,~/.}vimrc
else
echo &#8221;Modified changes are available in /tmp/vimrc&#8221;
fi<h6 class="zemanta-related-title">Related articles by Zemanta <ul class="zemanta-article-ul"> <li class="zemanta-article-ul-li"><a href="http://blog.amit-agarwal.co.in/2010/01/20/gnome-disk-manager-the-easier-way-to-manage-disks-in-gnome-with-palimpsest/">gnome-disk-manager – the easier way to manage disks in Gnome with Palimpsest (amit-agarwal.co.in) <li class="zemanta-article-ul-li"><a href="http://spf13.com/feature/vim-plugins-snipmate">Vim Plugins: snipMate (spf13.com) <li class="zemanta-article-ul-li"><a href="http://blog.amit-agarwal.co.in/2010/01/21/cli-color-and-bash-prompt-some-colored-fun-with-prompts-in-bash/">CLI Color and bash prompt.. some colored fun with prompts in bash (amit-agarwal.co.in) <li class="zemanta-article-ul-li"><a href="http://maketecheasier.com/hide-confidential-data-in-text-files/2010/01/31">How to Hide Confidential Data In Text Files (maketecheasier.com) <div class="zemanta-pixie"><a class="zemanta-pixie-a" title="Reblog this post [with Zemanta]" href="http://reblog.zemanta.com/zemified/9c4d03eb-144b-408c-860b-caa519e5008c/"><img class="zemanta-pixie-img" src="http://blog.amit-agarwal.co.in/wp-content/uploads/2010/08/reblog_b59.png" alt="Reblog this post [with Zemanta]" /><span class="zem-script more-related more-info pretty-attribution paragraph-reblog">


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