Skip to content

Instantly share code, notes, and snippets.

@A-312
Last active January 5, 2019 01:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save A-312/1e3d5bc6de5f3bc15909113e6258ac70 to your computer and use it in GitHub Desktop.
Save A-312/1e3d5bc6de5f3bc15909113e6258ac70 to your computer and use it in GitHub Desktop.
Mes alias pour le zds-site
alias zdsenv="cd ~/zds/zds-site && source zdsenv/bin/activate"
alias zdsenvquit="deactivate"
alias zdsenvstart="cd ~/zds/zds-site && make run-back"
alias zdsenvzmd="make zmd-start" #"cd ~/zds/zmarkdown/packages/zmarkdown/ && npm run server"
alias zdsenvwatch="npm run gulp watch --"
function zds_newbranch {
if [ -z $1 ]; then
echo "Argument attendu : Nom de la nouvelle branche."
else
git fetch upstream
git checkout -b $1 upstream/dev
fi
}
function zds_discard {
git checkout -- .
}
function parse_git_branch {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'
}
function zds_rebase {
git fetch upstream
git rebase upstream/dev
echo "Appuyer sur \`y\` pour confirmer et PUSH la modification..."
read -n 1
echo ""
if [ "$REPLY" = "y" ]; then
git push origin $(parse_git_branch) -f
else
echo "Annulé."
fi
}
function zds_edit {
if [ -z $1 ]; then
echo "Argument attendu : Nombre de commit à rebase."
else
git rebase -i HEAD~$1
fi
}
function zds_push {
git push origin $(parse_git_branch) $@
}
function zds_commit {
git commit -av
}
function zds_qa {
if [ -z $1 ]; then
echo "Argument attendu : Numéro de la PR."
else
git pr $@
fi
}
git config --global alias.pr '!f() { git fetch -fu ${2:-$(git remote |grep ^upstream || echo origin)} refs/pull/$1/head:pr/$1 && git checkout pr/$1; }; f'
git config --global alias.pr-clean '!git for-each-ref refs/heads/pr/* --format="%(refname)" | while read ref ; do branch=${ref#refs/heads/} ; git branch -D $branch ; done'
function zdshelp {
echo -e "\e[93mzdsenv \e[39m Active l'environnement."
echo -e "\e[93mzdsenvquit \e[39m Quitte l'environnement (deactivate)."
echo -e "\e[93mzdsenvstart \e[39m Lance la machine !"
echo -e "\e[93mzdsenvzmd \e[39m Démarre le serveur zmd."
echo -e "\e[93mzdsenvwatch \e[39m Watch le front."
echo -e "\e[93mzds_newbranch \e[92m[name]\e[39m Crée une nouvelle branche."
echo -e "\e[93mzds_discard \e[39m Annule les changements non envoyés."
echo -e "\e[93mzds_rebase \e[39m Rebase la branche courante avec l'upstream."
echo -e "\e[93mzds_edit 5 \e[39m Rebase les 5 derniers commits."
echo -e "\e[93mzds_push \e[39m Alias de \`git push origin {branch}\`."
echo -e "\e[93mzds_commit \e[39m Alias de \`git commit -av\`."
echo -e "\e[93mzds_qa 312 \e[39m Alias de \`git pr {num}\`."
echo -e " - \e[93mgit pr 312 \e[39m Crée une branche locale pr/312 à partir de l'upstream."
echo -e " - \e[93mgit pr 1234 \e[92m[user]\e[39m Crée une branche locale pr/1234 à partir de [user]."
echo -e "\e[93mgit pr-clean \e[39m Supprime toutes les branches locales pr/*."
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment