#!/bin/zsh # Patch Neovim binaries to remove Uganda donation ads # Should work on any version (and regular Vim if you modify the script) without needing to compile anything # To update Neovim, use your package manager like usual and run this script again # If run without root, creates a patched binary but doesn't replace the system install # Strings to hide a='type :help register for information ' b='type :help sponsor for information ' c='type :help iccf for information ' d='Become a registered Vim user!' e='Sponsor Vim development!' f='Help poor children in Uganda!' g='type :help Kuwasha for information' # no i do not kno da wae if [ "$(id -u)" != 0 ]; then <<< "Root is required to patch the system install of nvim" printf "Generate patched binary anyway? [y/N]: " read -k nonroot <<< "" if [ "$nonroot" != "y" ]; then <<< "Cancelled" exit 1 fi fi # Converts a string to spaces of the same length function spaces { <<< $1 sed "s/./ /g" } # Replaces specified strings with spaces in nvim <<< "Replacing ads..." < $(which nvim) sed " s/$a/$(spaces $a)/g s/$b/$(spaces $b)/g s/$c/$(spaces $c)/g s/$d/$(spaces $d)/g s/$e/$(spaces $e)/g s/$f/$(spaces $f)/g s/$g/$(spaces $g)/g " > nvim-patched # Mark as executable chmod 755 nvim-patched # Only replace original binary if root if [ "$(id -u)" != 0 ]; then <<< "Created \"nvim-patched\"" exit fi chown root:root nvim-patched # Get nvim install path original=$(which nvim) backup="${original}-unpatched" # Make a backup of the original if one doesn't exist # Should be able to restore it with your package manager but just in case ! [ -e "$backup" ] && mv "$original" "$backup" # Replace the original with the patched version mv nvim-patched "$original" <<< "Patched system install"