Switch branches/tags
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 86 lines (63 sloc) 2.27 KB
#! /bin/bash
# Copyright 2015-2018, Hörmet Yiltiz <>
# Released under GNU GPL version 3 or later.
set -eu
# set -x
echo "Generating vim startup profile..."
if [ -f $logfile ]; then
# clear the log file first
rm $logfile
if [[ $# -eq 0 ]]; then
vim --startuptime $logfile -c q
vim --startuptime $logfile $1
echo 'Assuming your vimfiles folder as `~/.vim/`'
if [ -d "${vimfilesDir}plugged" ]; then
echo "vim-plug has been detected."
elif [ -d "${vimfilesDir}bundle" ]; then
echo "NeoBundle/Vundle/Pathogen has been detected."
echo "Cannot tell your plugin-manager. Adjust this bash script\n"
echo "to meet your own needs for now."
echo 'Cue: `plugDir` variable would be a good starting place.'
exit 1
echo "Parsing vim startup profile..."
# logfile=hi.log
# cat $logfile
grep $plugDir $logfile > tmp.log
awk -F\: '{print $1}' tmp.log > tmp1.log
awk -F\: '{print $2}' tmp.log | awk -F\: '{print $2}' tmp.log | sed "s/.*${plugDir}\///g"|sed 's/\/.*//g' > tmp2.log
paste -d ',' tmp1.log tmp2.log | tr -s ' ' ',' > profile.csv
rm tmp.log tmp1.log tmp2.log
rm $logfile
# Let's do the R magic!
echo "Crunching data and generating profile plot ..."
# Check if R is available
echo " "
type R > /dev/null 2>&1 || { echo >&2 "Package R is required but it's not installed. \nPlease install R using your package manager, \nor check out for instructions. \nAborting."; exit 1; }
# Still here? Great! Let's move on!
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
R --vanilla --quiet --slave --file="$DIR/vim-plugins-profile-plot.R"
#R --vanilla --file="vim-plugins-profile-plot.R" # or use this for debugging
# we use result.csv, which is saved from R
# delete profile.csv since it is used to feed into R
rm profile.csv
echo " "
echo 'Your plugins startup profile graph is saved '
echo 'as `result.png` under current directory.'
echo " "
echo "=========================================="
echo "Top 10 Plugins That Slows Down Vim Startup"
echo "=========================================="
cat -n result.csv |head -n 10 # change this 10 to see more in this `Top List`
echo "=========================================="
echo "Done!"
echo " "