rktjmp / lush.nvim

Create Neovim themes with real-time feedback, export anywhere.
MIT License
1.4k stars 46 forks source link

Changing boilerplate `sed` code results in error in Mac #119

Closed aasutossh closed 1 year ago

aasutossh commented 1 year ago
  sh << "EOF"
  LUSH_NAME=$(basename $(pwd))
  GIT_NAME=$(git config user.name)
  YEAR=$(date +"%Y")
  mv colors/lush_template.lua colors/$LUSH_NAME.lua
  mv lua/lush_theme/lush_template.lua lua/lush_theme/$LUSH_NAME.lua
  if command -v sed &> /dev/null; then
    sed -i "s/lush_template/$LUSH_NAME/g" colors/$LUSH_NAME.lua
    sed -i "s/COPYRIGHT_NAME/$GIT_NAME/g" LICENSE
    sed -i "s/COPYRIGHT_YEAR/$YEAR/g" LICENSE
    git add .
  else
    echo "Could not find sed, please manually replace 'lush_template' with '$LUSH_NAME' in colors/$LUSH_NAME.vim, and update the LICENCE file."
  fi
EOF

results in

sed: 1: "colors/Awesome.lua": command c expects \ followed by text
sed: 1: "LICENSE": invalid command code L
sed: 1: "LICENSE": invalid command code L
aasutossh commented 1 year ago

Here https://github.com/rktjmp/lush.nvim/blob/main/CREATE.md

rktjmp commented 1 year ago

I am unable to test on macOS so any command suggestions are welcome.

aasutossh commented 1 year ago
sh << "EOF"
  LUSH_NAME=$(basename $(pwd))
  GIT_NAME=$(git config user.name)
  YEAR=$(date +"%Y")
  mv colors/lush_template.lua colors/$LUSH_NAME.lua
  mv lua/lush_theme/lush_template.lua lua/lush_theme/$LUSH_NAME.lua
  if command -v gsed &> /dev/null; then
    gsed -i "s/lush_template/$LUSH_NAME/g" colors/$LUSH_NAME.lua
    gsed -i "s/COPYRIGHT_NAME/$GIT_NAME/g" LICENSE
    gsed -i "s/COPYRIGHT_YEAR/$YEAR/g" LICENSE
    git add .
  else
    echo "Could not find sed, please manually replace 'lush_template' with '$LUSH_NAME' in colors/$LUSH_NAME.vim, and update the LICENCE file."
  fi
EOF

Using gnu-sed instead of sed the command is pretty much usable. gnu-sed can be installed using brew as

brew install gnu-sed

Source: https://stackoverflow.com/a/10304970/11690968

rktjmp commented 1 year ago

Updated CREATE.md to link here with a note, but the commands remain the same (have to pick one system to support, (GNU) Linux or BSD and I use Linux so ...)