Skip to content

Instantly share code, notes, and snippets.

@maximgrynykha
Created April 25, 2022 08:17
Show Gist options
  • Save maximgrynykha/57531423b6a3c11b4a936775eb02ac26 to your computer and use it in GitHub Desktop.
Save maximgrynykha/57531423b6a3c11b4a936775eb02ac26 to your computer and use it in GitHub Desktop.
#!/bin/bash
[ "$(type -t make:migration)" = "alias" ] && unalias make:migration
comment="# Add shortcut for generating CodeIgniter migrations."
alias="alias make:migration='php index.php migrate generate'"
if grep -R -zoP "\n$comment\n$alias" ~/.bashrc; then
sed "s/$comment//g" ~/.bashrc > tmp && sed "s/$alias//g" tmp > ~/.bashrc
sed -i -e :a -e '/^\n*$/{$d;N;}/\n$/ba' ~/.bashrc
else
echo "\n$comment\n$alias" >> ~/.bashrc
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment