rafi / awesome-vim-colorschemes

Collection of awesome color schemes for Neo/vim, merged for quick use.
2.69k stars 174 forks source link

Add script for quick overview #11

Closed yugr closed 3 years ago

yugr commented 4 years ago

Hi, thanks for collecting all this stuff together. Selecting a colorscheme normally involves going over all contents of the colors directory and checking how schemes look on particular system. It would be nice to have this automated via script e.g. like the one below.

#!/bin/sh

set -euo pipefail
#set -x

if [ $(basename $PWD) != 'awesome-vim-colorschemes' ]; then
  echo >&2 'You must run me inside awesome-vim-colorschemes repo'
  exit 1
fi

example=$(mktemp).cpp
trap "rm -f $example" EXIT

schemes=$(find colors -name \*.vim | xargs -n1 basename | sed 's/\.vim//g')

for s in $schemes; do
  cat > $example <<EOF
// Colorscheme "$s".
// To stop iteration, add ABORT anywhere below and save file.

#include <stdio.h>

namespace XYZ {

static int x = 1;

struct A {
  int x;
  int y;
  void a() const { return x + y; }
};

int main() {
  A var;
  printf("Hello world!\n");
  return 0;
}

}  // XYZ
EOF
  vim +':syntax on' +":set runtimepath+=$PWD" +":colo $s" $example
  if [ $(grep ABORT $example | grep -v 'add ABORT anywhere' | wc -l) -gt 0 ]; then
    echo 'Aborting per user request...'
    break
  fi
done

Feel free to close if not relevant.

rafi commented 3 years ago

Added. Very awesome, thanks!