bash script to change vim colorscheme based on the available themes
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 <a class="zem_slink freebase/en/vim" title="Vim (text editor)" rel="homepage" href="http://www.vim.org/">vim.
#!/bin/bash –
#===============================================================================# FILE: change_vim_colorscheme.sh
# USAGE: ./change_vim_colorscheme.sh
# DESCRIPTION: Change the vim colorscheme from <a class="zem_slink freebase/en/cmd_exe" title="Command Prompt" rel="wikipedia" href="http://en.wikipedia.org/wiki/Command_Prompt">command prompt
# OPTIONS: —
# REQUIREMENTS: —
# BUGS: —
# NOTES: —
# AUTHOR: Amit Agarwal (AKA), amit.agarwal@amit-agarwal.co.in
# 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
do
echo ”${i%.vim}”
done
#Read the choice of the userread -p ”Enter one of the colorschemes :: ” choice
file=~/.vim/colors/$choice.vim
if [ ! -f $file ]
then
echo ”Colorscheme file ”$file” does not exist”
exit -1
fi#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” ]
then
echo {/tmp/,~/.}vimrc
cp {/tmp/,~/.}vimrc
else
echo ”Modified changes are available in /tmp/vimrc”
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/04/06/vim-understanding-the-various-modes-and-using-the-yanking-more-efficiently/">vim understanding the various modes and using the yanking more efficiently. (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://spf13.com/post/vim-crash-course">VIM Crash Course (spf13.com) <div class="zemanta-pixie"><a class="zemanta-pixie-a" title="Reblog this post [with Zemanta]" href="http://reblog.zemanta.com/zemified/7c4d9424-8d98-4372-b234-6902125e58b6/"><img class="zemanta-pixie-img" src="http://blog.amit-agarwal.co.in/wp-content/uploads/2010/08/reblog_b73.png" alt="Reblog this post [with Zemanta]" /><span class="zem-script more-related more-info pretty-attribution paragraph-reblog">
Related Articles:
- 2010/03/29 vim scripts and tips
- 2009/11/19 Multiple search in vim
- 2010/03/08 eclim for Fedora – Leonidas – installation.
- 2010/02/03 Built-in lists in vim
- 2009/12/20 Know when you will type :q in your term instead of vi(m), the alias will chewed you out.