Added a new script that can be used to update the repo if bash is
available. Updated the README. Improved the theme by adding a bunch
of syntax highlighting definitions (mostly rooted in html, though
a bunch of other languages base their colours on it), as well as
tweaking visual selection to longer invert on the block with the cursor,
and parenthesis matching to look the same at both ends. Added a plugin
that improves the theme and adds some keyboard shortcuts to markdown,
which is what the README.md files in Github are written in. I realized
that the h,j,k,l shortcuts equivalent to the ones with arrow keys I'd
added were overwriting other shortcuts with the shift combinations, so
I removed those and the ctrl-ones for consistency. The diff shortcuts
weren't intuitive or easy on the hands, so I tried something else and
I think it works much better now (check vim/keyboard.vim). An update
script has also been added to simplify updating submodules; I'm not
completely clear as to whether following this method will properly
update the submodules in certain conditions like when one is removed,
but this should add new ones and update the existing ones after pulling
from the repo.
2014-04-01 00:03:52 -04:00
#!/usr/bin/env bash
2014-06-17 01:49:46 -04:00
##############################################################
# #
# Darkcloud Vim Config: update script #
# #
# By: Kevin MacMartin (prurigro@gmail.com) #
# Website: https://github.com/prurigro/darkcloud-vimconfig #
# #
# License: MIT #
# #
##############################################################
2014-07-14 10:30:02 -04:00
cd $(dirname "$0")
2014-06-17 08:19:40 -04:00
### BEGIN: VARIABLES ###
# user variables (these can be edited)
ERRORLOG="update-errors.log" # set the error log filename
Tons of changes all in one commit because I'd broken a commit a while
back and opted to simply reverse them all- Lots of colour changes, the
update script now removes decommissioned bundles, gentags script can now
have additional paths added to it when generating a tags file, README is
much improved, fixed a few issues that required remapping some toggles,
fixed a bunch of issues with the colourscheme between the terminal and
gvim. You can now setup a custom config file to have loaded after the
darkcloud-vimconfig ones, and there's a custom location for pathogen
modules too, to make things tidier without necessarily needing to use
an additional runtimepath. You can also create a file in your home
directory to assign filetypes to programs, for use with the file
manager. A file can be placed in ~/.vim/ with file associations and
prorams to launch them with. The file manager will also open a file with
vim by hitting shift+enter, since e isn't all that comfortablly placed.
The vimrc can now also point to the darkcloud-vimconfig folder, rather
than relying on the vim folder being in a specific location, and the
after folder is now configured to work in the project too.
2014-04-04 19:49:02 -04:00
2014-06-17 08:19:40 -04:00
# script variables (these should not be touched)
VERSION=$(printf "%s.r%s" "$(git show -s --format=%ci master | sed 's/\ .*//g;s/-//g')" "$(git rev-list --count HEAD)")
2014-07-13 17:49:35 -04:00
SCRIPT_NAME=$(grep -o -e "[^\/]*$" <<< "$0")
2014-07-14 10:30:02 -04:00
SCRIPT_HOME=$(pwd)
2014-06-17 08:19:40 -04:00
### END: VARIABLES ###
2014-06-17 01:49:46 -04:00
2014-06-17 08:19:40 -04:00
### BEGIN: FUNCTIONS ###
# command_parse "$@": configures environment using arguments
2014-06-17 01:49:46 -04:00
function command_parse {
for param in $@; do
case "$param" in
-n|--no-color|--no-colour)
NO_COLOUR=true
;;
-h|--help)
SHOW_HELP=true
;;
-v|--version)
SHOW_VERSION=true
;;
*)
ERROR="\"${param}\" is not a valid argument"
;;
esac
done
}
2014-06-16 05:37:52 -04:00
2014-06-17 08:19:40 -04:00
# error "file/command" "error output" "note": output and log error
2014-06-16 05:37:52 -04:00
function error() {
2014-06-17 01:49:46 -04:00
echo -e "${HEADINGCOLOUR} ${RESETCOLOUR}${ERRORCOLOUR} ! ERROR: ${RESETCOLOUR}${FAILCOLOUR} ${2} "
2014-06-17 08:19:40 -04:00
echo -e "${HEADINGCOLOUR} ${RESETCOLOUR}${ERRORCOLOUR} ! COMMAND: ${RESETCOLOUR} ${NOACTIONCOLOUR}=> ${1}${RESETCOLOUR}"
[[ -n "$3" ]] && echo -e "${HEADINGCOLOUR} ${RESETCOLOUR}${ERRORCOLOUR} ! OUTPUT: ${RESETCOLOUR}${NOACTIONCOLOUR} ${3}"
2014-06-16 05:37:52 -04:00
2014-06-17 08:19:40 -04:00
echo "DATE: @ $(date)" >> "${SCRIPT_HOME}/${ERRORLOG}"
echo "ERROR: ${2}" >> "${SCRIPT_HOME}/${ERRORLOG}"
echo "COMMAND: ${1}" >> "${SCRIPT_HOME}/${ERRORLOG}"
[[ -n "$3" ]] && echo "OUTPUT: ${3}" >> "${SCRIPT_HOME}/${ERRORLOG}"
echo >> "${SCRIPT_HOME}/${ERRORLOG}"
2014-06-16 05:37:52 -04:00
}
2014-06-17 08:19:40 -04:00
# show_version: displays version information
2014-06-17 01:49:46 -04:00
function show_version() {
echo -e "Update tool for darkcloud-vimconfig (${SCRIPT_NAME}) v${VERSION}\n"
}
2014-06-17 08:19:40 -04:00
# show_help: this function displays help output
2014-06-17 01:49:46 -04:00
function show_help() {
echo -e "Usage: ${SCRIPT_NAME} [OPTION]\n"
echo " Options:"
2014-06-17 08:19:40 -04:00
echo -e "\t-n, --no-colour (or --no-color)\n\t\tdisable colour output\n"
echo -e "\t-v, --version\n\t\toutput version information and exit\n"
echo -e "\t-h, --help\n\t\tdisplay this help and exit\n"
2014-06-17 01:49:46 -04:00
echo -e "\tRun with no arguments to update darkcloud-vimconfig\n"
}
2014-06-17 08:19:40 -04:00
### END: FUNCTIONS ###
### BEGIN: SETUP ###
# change to the base darkcloud-vimconfig folder
cd "$SCRIPT_HOME"
2014-06-17 01:49:46 -04:00
2014-06-17 08:19:40 -04:00
# delete old error log if it exists
[[ -f "$ERRORLOG" ]] && rm "${SCRIPT_HOME}/${ERRORLOG}"
# parse for arguments (then handle them below)
2014-06-17 01:49:46 -04:00
[[ ! -z "$@" ]] && command_parse "$@"
2014-06-17 08:19:40 -04:00
# set colour for output unless an argument was given to disable it
2014-06-17 01:49:46 -04:00
if [ ! "$NO_COLOUR" = "true" ]; then
TITLECOLOUR="\e[40m"
HEADINGCOLOUR="\e[44m"
SUBHEADINGCOLOUR="\e[43m"
SUCCESSCOLOUR="\e[1;32m"
FAILCOLOUR="\e[1;31m"
NOACTIONCOLOUR="\e[1;37m"
ERRORCOLOUR="\e[1;41m"
RESETCOLOUR="\e[0m"
else
HEADINGCOLOUR="#"
fi
2014-06-17 08:19:40 -04:00
# display an error, help then exit when invalid argument(s) are given
2014-06-17 01:49:46 -04:00
[[ -n "$ERROR" ]] && error "$ERROR" "Invalid option supplied at runtime" && echo && show_help && exit 1
2014-06-17 08:19:40 -04:00
# show the help and exit when an argument has been given to do so
2014-06-17 01:49:46 -04:00
[[ "$SHOW_HELP" = "true" ]] && show_version && show_help && exit 0
2014-06-17 08:19:40 -04:00
# show version information and exit when an argument has been given to do so
2014-06-17 01:49:46 -04:00
[[ "$SHOW_VERSION" = "true" ]] && show_version && exit 0
2014-06-16 05:37:52 -04:00
2014-06-17 08:19:40 -04:00
echo -e "\n${TITLECOLOUR} ~~~ DarkCloud Vimconfig Update Tool ~~~ ${RESETCOLOUR}"
# create vim/bundle.user and vim/vimrc.user if either don't exist
if [ ! -d vim/bundle.user ]; then
echo -n -e "\n${HEADINGCOLOUR} >> Creating User Plugin Directory:${RESETCOLOUR}"
PROCESS_STATUS=$(install -d vim/bundle.user 2>&1)
if [ $? = 0 ]; then
echo -e "${SUCCESSCOLOUR} SUCCESS! ${RESETCOLOUR}"
else
echo -e "${FAILCOLOUR} FAIL! ${RESETCOLOUR}"
error "install -d vim/bundle.user" "User plugin directory couldn't be created" "$PROCESS_STATUS"
fi
fi
2014-04-08 03:39:10 -04:00
if [ ! -e vim/vimrc.user ]; then
2014-06-17 08:19:40 -04:00
echo -n -e "\n${HEADINGCOLOUR} >> Creating User Config File:${RESETCOLOUR}"
PROCESS_STATUS=$(touch vim/vimrc.user 2>&1)
if [ $? = 0 ]; then
2014-08-25 00:43:41 -04:00
echo -e '"Autostart Filer in empty buffers: (*1:filer loads in new empty buffers | 0:filer must be triggered)\n"let g:autostartfiler=1\n' >> vim/vimrc.user
echo -e '"Autocheck syntax checking: (1:start toggled on | *0:start toggled off)\n"let g:autostartchecker=0\n' >> vim/vimrc.user
echo -e '"Autoload Tagbar: (1:start open | *0:start closed)\n"let g:autostarttagbar=0\n' >> vim/vimrc.user
echo -e '"Disable automatic tag generation and highlighting: (1:force disabled tag generation and highlighting | *0:enable automatic tag generation and highlighting)\n"let g:disableautotags=0\n' >> vim/vimrc.user
echo -e '"Disable automatic linebreaking: (1:force disabled globally | *0:let the filetype decide)\n"let g:disablelinebreaks=0\n' >> vim/vimrc.user
echo -e '"Enable Powerline fonts: (1:expect powerline font | *0:expect regular font)\n"let g:powerlinefonts=0 "(set powerline font for gvim and terminal when enabled)\n' >> vim/vimrc.user
2014-07-14 10:30:02 -04:00
echo -e '"GVim font selection: (Escaping spaces and use powerline if appropriate)\nset guifont=Monospace\ 12' >> vim/vimrc.user
2014-06-17 01:49:46 -04:00
echo -e "${SUCCESSCOLOUR} SUCCESS! ${RESETCOLOUR}"
else
echo -e "${FAILCOLOUR} FAIL! ${RESETCOLOUR}"
2014-06-17 08:19:40 -04:00
error "touch vim/vimrc.user" "User config couldn't be created" "$PROCESS_STATUS"
2014-04-08 03:39:10 -04:00
fi
2014-06-16 05:37:52 -04:00
fi
2014-06-17 08:19:40 -04:00
### END: SETUP ###
2014-06-16 05:37:52 -04:00
2014-06-17 08:19:40 -04:00
### BEGIN: REPO UPDATE ###
echo -n -e "\n${HEADINGCOLOUR} >> Updating Repository:${RESETCOLOUR}"
PROCESS_STATUS=$(git pull origin master 2>&1)
2014-06-16 05:37:52 -04:00
if [ $? = 0 ]; then
2014-06-17 01:49:46 -04:00
echo -e "${SUCCESSCOLOUR} SUCCESS! ${RESETCOLOUR}"
2014-06-16 05:37:52 -04:00
else
2014-06-17 01:49:46 -04:00
echo -e "${FAILCOLOUR} FAIL! ${RESETCOLOUR}"
2014-06-17 08:19:40 -04:00
error "git pull origin master" "Git failed to sync the repo" "$PROCESS_STATUS"
2014-06-16 05:37:52 -04:00
exit 1
2014-04-08 03:39:10 -04:00
fi
2014-06-17 08:19:40 -04:00
### END: REPO UPDATE ###
### BEGIN: SUBMODULE UPDATE ###
# synchronize the repo urls for each submodule using the ones in .gitmodules
2014-06-17 01:49:46 -04:00
echo -e "\n${HEADINGCOLOUR} >> Updating Plugin Submodules >> ${RESETCOLOUR}"
2014-06-17 08:19:40 -04:00
echo -n -e "${HEADINGCOLOUR} ${RESETCOLOUR}${SUBHEADINGCOLOUR} + Updating Plugin URLs:${RESETCOLOUR}"
PROCESS_STATUS=$(git submodule sync 2>&1)
2014-06-16 05:37:52 -04:00
if [ $? = 0 ]; then
2014-06-17 01:49:46 -04:00
echo -e "${SUCCESSCOLOUR} SUCCESS! ${RESETCOLOUR}"
2014-06-16 05:37:52 -04:00
else
2014-06-17 01:49:46 -04:00
echo -e "${FAILCOLOUR} FAIL! ${RESETCOLOUR}"
2014-06-17 08:19:40 -04:00
error "git submodule sync" "Git failed to sync the submodules" "$PROCESS_STATUS"
2014-06-16 05:37:52 -04:00
fi
2014-06-17 08:19:40 -04:00
# update each submodule to the new head and run 'git fetch --all'
echo -n -e "${HEADINGCOLOUR} ${RESETCOLOUR}${SUBHEADINGCOLOUR} + Fetching Updates:${RESETCOLOUR}"
PROCESS_STATUS=$(git submodule foreach git fetch --all 2>&1)
2014-06-16 05:37:52 -04:00
if [ $? = 0 ]; then
2014-06-17 08:19:40 -04:00
PROCESS_STATUS=$(git submodule update --init --recursive 2>&1)
2014-06-16 05:37:52 -04:00
if [ $? = 0 ]; then
2014-06-17 01:49:46 -04:00
echo -e "${SUCCESSCOLOUR} SUCCESS! ${RESETCOLOUR}"
2014-06-16 05:37:52 -04:00
else
2014-06-17 01:49:46 -04:00
echo -e "${FAILCOLOUR} FAIL! ${RESETCOLOUR}"
2014-06-17 08:19:40 -04:00
error "git submodule update --init --recursive" "Git failed to update the submodules" "$PROCESS_STATUS"
2014-06-16 05:37:52 -04:00
fi
else
2014-06-17 01:49:46 -04:00
echo -e "${FAILCOLOUR} FAIL! ${RESETCOLOUR}"
2014-06-17 08:19:40 -04:00
error "git submodule foreach git fetch --all" "Git failed to fetch the submodules from their respective remotes" "$PROCESS_STATUS"
2014-06-16 05:37:52 -04:00
fi
2014-05-05 08:57:38 -04:00
2014-06-17 08:19:40 -04:00
# run 'git checkout origin/master' on each submodule
echo -n -e "${HEADINGCOLOUR} ${RESETCOLOUR}${SUBHEADINGCOLOUR} + Checking Out Updates:${RESETCOLOUR}"
PROCESS_STATUS=$(git submodule foreach git checkout -f origin/master 2>&1)
2014-06-16 05:37:52 -04:00
if [ $? = 0 ]; then
2014-06-17 01:49:46 -04:00
echo -e "${SUCCESSCOLOUR} SUCCESS! ${RESETCOLOUR}"
2014-06-16 05:37:52 -04:00
else
2014-06-17 01:49:46 -04:00
echo -e "${FAILCOLOUR} FAIL! ${RESETCOLOUR}"
2014-06-17 08:19:40 -04:00
error "git submodule foreach git checkout -f origin/master" "Git failed to checkout the submodules into origin/master" "$PROCESS_STATUS"
2014-06-16 05:37:52 -04:00
fi
Tons of changes all in one commit because I'd broken a commit a while
back and opted to simply reverse them all- Lots of colour changes, the
update script now removes decommissioned bundles, gentags script can now
have additional paths added to it when generating a tags file, README is
much improved, fixed a few issues that required remapping some toggles,
fixed a bunch of issues with the colourscheme between the terminal and
gvim. You can now setup a custom config file to have loaded after the
darkcloud-vimconfig ones, and there's a custom location for pathogen
modules too, to make things tidier without necessarily needing to use
an additional runtimepath. You can also create a file in your home
directory to assign filetypes to programs, for use with the file
manager. A file can be placed in ~/.vim/ with file associations and
prorams to launch them with. The file manager will also open a file with
vim by hitting shift+enter, since e isn't all that comfortablly placed.
The vimrc can now also point to the darkcloud-vimconfig folder, rather
than relying on the vim folder being in a specific location, and the
after folder is now configured to work in the project too.
2014-04-04 19:49:02 -04:00
2014-06-16 05:37:52 -04:00
# clean plugin directories and remove plugins no longer in the repo
2014-06-17 01:49:46 -04:00
echo -e "\n${HEADINGCOLOUR} >> Cleaning Plugin Directories >> ${RESETCOLOUR}"
2014-06-17 08:19:40 -04:00
echo -n -e "${HEADINGCOLOUR} ${RESETCOLOUR}${SUBHEADINGCOLOUR} + Removing Untracked Files:${RESETCOLOUR}"
2014-06-17 01:49:46 -04:00
git submodule foreach git clean -dxf > /dev/null 2>&1 && echo -e "${SUCCESSCOLOUR} SUCCESS! ${RESETCOLOUR}" || echo -e "${FAILCOLOUR} FAIL! ${RESETCOLOUR}"
Tons of changes all in one commit because I'd broken a commit a while
back and opted to simply reverse them all- Lots of colour changes, the
update script now removes decommissioned bundles, gentags script can now
have additional paths added to it when generating a tags file, README is
much improved, fixed a few issues that required remapping some toggles,
fixed a bunch of issues with the colourscheme between the terminal and
gvim. You can now setup a custom config file to have loaded after the
darkcloud-vimconfig ones, and there's a custom location for pathogen
modules too, to make things tidier without necessarily needing to use
an additional runtimepath. You can also create a file in your home
directory to assign filetypes to programs, for use with the file
manager. A file can be placed in ~/.vim/ with file associations and
prorams to launch them with. The file manager will also open a file with
vim by hitting shift+enter, since e isn't all that comfortablly placed.
The vimrc can now also point to the darkcloud-vimconfig folder, rather
than relying on the vim folder being in a specific location, and the
after folder is now configured to work in the project too.
2014-04-04 19:49:02 -04:00
[[ -f .gitmodules ]] && for each in vim/bundle/*; do
if [ -d "$each" ]; then
if [ -f "${each}/.git" ]; then
FILE=$(echo $each | grep -o -e "[^\/]*$")
2014-06-16 05:37:52 -04:00
if [ $(cat .gitmodules | grep "path = " | grep -o -e "[^\/]*$" | grep -c -e "${FILE}$") = 0 ]; then
2014-06-17 01:49:46 -04:00
[[ -z "$FIRST_OLD" ]] && export FIRST_OLD=1 && echo -n -e "${HEADINGCOLOUR} ${RESETCOLOUR}${SUBHEADINGCOLOUR} + Removing Old Plugins: ${RESETCOLOUR}\n"
2014-06-17 08:19:40 -04:00
PROCESS_STATUS=$(rm -rf "$each")
2014-06-16 05:37:52 -04:00
if [ $? = 0 ]; then
2014-06-17 01:49:46 -04:00
echo -e "${HEADINGCOLOUR} ${RESETCOLOUR}${SUBHEADINGCOLOUR} = ${RESETCOLOUR}$(echo ${each}\ | sed -re 's|^(.*)/([^/]*)$|\\e\[1;37m\1/\\e\[1;31m\2\\e\[0m|')"
2014-06-16 05:37:52 -04:00
else
2014-06-17 08:19:40 -04:00
error "rm -rf ${each}" "Folder couldn't be deleted" "$PROCESS_STATUS"
2014-06-16 05:37:52 -04:00
exit 1
fi
fi
Tons of changes all in one commit because I'd broken a commit a while
back and opted to simply reverse them all- Lots of colour changes, the
update script now removes decommissioned bundles, gentags script can now
have additional paths added to it when generating a tags file, README is
much improved, fixed a few issues that required remapping some toggles,
fixed a bunch of issues with the colourscheme between the terminal and
gvim. You can now setup a custom config file to have loaded after the
darkcloud-vimconfig ones, and there's a custom location for pathogen
modules too, to make things tidier without necessarily needing to use
an additional runtimepath. You can also create a file in your home
directory to assign filetypes to programs, for use with the file
manager. A file can be placed in ~/.vim/ with file associations and
prorams to launch them with. The file manager will also open a file with
vim by hitting shift+enter, since e isn't all that comfortablly placed.
The vimrc can now also point to the darkcloud-vimconfig folder, rather
than relying on the vim folder being in a specific location, and the
after folder is now configured to work in the project too.
2014-04-04 19:49:02 -04:00
fi
fi
2014-06-17 08:19:40 -04:00
done && echo
### END: SUBMODULE UPDATE ###
### BEGIN: USER PLUGIN UPDATE ###
if [ -d vim/bundle.user ]; then
if [ ! $(find vim/bundle.user | grep ".git/config" | wc -l) = 0 ]; then
echo -e "${HEADINGCOLOUR} >> Updating User Plugins >> ${RESETCOLOUR}"
pushd vim/bundle.user > /dev/null 2>&1
for each in *; do
if [ -d "$each" ]; then
pushd "$each" > /dev/null 2>&1
if [ -d .git ]; then
echo -n -e "${HEADINGCOLOUR} ${RESETCOLOUR}${SUBHEADINGCOLOUR} + Updating 'vim/bundle.user/${each}':${RESETCOLOUR}"
PROCESS_STATUS=$(git pull origin master 2>&1)
if [ $? = 0 ]; then
if [ $(echo $PROCESS_STATUS | grep -c "Already up-to-date") = 0 ]; then
echo -e "${SUCCESSCOLOUR} SUCCESS! ${RESETCOLOUR}"
else
echo -e "${NOACTIONCOLOUR} UP TO DATE ${RESETCOLOUR}"
fi
2014-06-16 05:37:52 -04:00
else
2014-06-17 08:19:40 -04:00
error "git pull origin master" "Failed pulling changes for ${each}" "$PROCESS_STATUS"
2014-06-16 05:37:52 -04:00
fi
fi
2014-06-17 08:19:40 -04:00
popd > /dev/null 2>&1
fi
done
popd > /dev/null 2>&1
echo
fi
2014-05-05 08:57:38 -04:00
fi
2014-06-17 08:19:40 -04:00
### END: USER PLUGIN UPDATE ###
### BEGIN: GENERATE PLUGIN HELPTAGS ###
if [ $(type -P vim) ]; then
echo -n -e "${HEADINGCOLOUR} >> Generating Plugin Help:${RESETCOLOUR}"
timeout --foreground 2m vim -c "Helptags|qa!" &> /dev/null
if [ $? = 0 ]; then
echo -e "${SUCCESSCOLOUR} SUCCESS! ${RESETCOLOUR}"
else
reset -I
echo -e "${FAILCOLOUR} FAIL! ${RESETCOLOUR}"
error "vim -c \"Helptags|qa!\"" "Generating helpdocs for the submodules failed"
fi
fi
### END: GENERATE PLUGIN HELPTAGS ###
2014-04-07 19:16:58 -04:00
2014-06-17 01:49:46 -04:00
echo -e "\n${TITLECOLOUR} ~~~ Update Complete ~~~ ${RESETCOLOUR}\n"
Tons of changes all in one commit because I'd broken a commit a while
back and opted to simply reverse them all- Lots of colour changes, the
update script now removes decommissioned bundles, gentags script can now
have additional paths added to it when generating a tags file, README is
much improved, fixed a few issues that required remapping some toggles,
fixed a bunch of issues with the colourscheme between the terminal and
gvim. You can now setup a custom config file to have loaded after the
darkcloud-vimconfig ones, and there's a custom location for pathogen
modules too, to make things tidier without necessarily needing to use
an additional runtimepath. You can also create a file in your home
directory to assign filetypes to programs, for use with the file
manager. A file can be placed in ~/.vim/ with file associations and
prorams to launch them with. The file manager will also open a file with
vim by hitting shift+enter, since e isn't all that comfortablly placed.
The vimrc can now also point to the darkcloud-vimconfig folder, rather
than relying on the vim folder being in a specific location, and the
after folder is now configured to work in the project too.
2014-04-04 19:49:02 -04:00
exit 0