bash script to change the vim colorscheme from the list of locally available schemes
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 ”${i%.vim}”
doneread -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
fised ’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/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">
Related Articles:
- 2010/04/11 bash script to change vim colorscheme based on the available themes
- 2010/02/03 Built-in lists in vim
- 2010/04/11 In (any) vi, add a keystroke to format the current paragraph.
- 2010/03/29 vim scripts and tips
- 2010/03/08 eclim for Fedora – Leonidas – installation.