Skip to content

Instantly share code, notes, and snippets.

@trueheart78
Last active January 26, 2021 15:44
Show Gist options
  • Save trueheart78/2ffabced0e0cdc91144b12b528de378f to your computer and use it in GitHub Desktop.
Save trueheart78/2ffabced0e0cdc91144b12b528de378f to your computer and use it in GitHub Desktop.

Revisions

  1. trueheart78 revised this gist Jan 26, 2021. 1 changed file with 12 additions and 1 deletion.
    13 changes: 12 additions & 1 deletion git-functions.sh
    Original file line number Diff line number Diff line change
    @@ -23,7 +23,18 @@ g () {
    done
    elif [[ $1 = "push" ]]; then
    branch=`command git rev-parse --abbrev-ref HEAD`
    if [[ $branch = 'master' ]]
    if [[ $branch = 'main' ]]
    then
    while true; do
    echo -n "Push to 🔥 Main 🔥 ? (y/n) "
    read yn
    case $yn in
    [Yy]* ) command git "$@"; break;;
    [Nn]* ) echo "❤️ Push-to-Main crisis averted ❤️"; break;;
    * ) echo "Please answer yes or no.";;
    esac
    done
    elif [[ $branch = 'master' ]]
    then
    while true; do
    echo -n "Push to 🔥 Master 🔥 ? (y/n) "
  2. trueheart78 revised this gist Mar 28, 2018. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions git-functions.sh
    Original file line number Diff line number Diff line change
    @@ -34,6 +34,8 @@ g () {
    * ) echo "Please answer yes or no.";;
    esac
    done
    else
    command git "$@"
    fi
    else
    command git "$@"
  3. trueheart78 revised this gist Mar 26, 2018. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions git-functions.sh
    Original file line number Diff line number Diff line change
    @@ -35,6 +35,8 @@ g () {
    esac
    done
    fi
    else
    command git "$@"
    fi
    else
    command git status
  4. trueheart78 revised this gist Mar 26, 2018. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions git-functions.sh
    Original file line number Diff line number Diff line change
    @@ -8,9 +8,9 @@ git () {
    # as it will override this command
    g () {
    if [[ $# -gt 0 ]]
    then
    command git "$@"
    then
    if [[ `uname` = 'Darwin' && $1 = "init" ]]; then
    command git "$@"
    # prompt for the username and email to use
    while true; do
    echo -n "Will this be a ⚠️ work-related ⚠️ repo? (y/n) "
  5. trueheart78 revised this gist Mar 26, 2018. 1 changed file with 11 additions and 11 deletions.
    22 changes: 11 additions & 11 deletions git-functions.sh
    Original file line number Diff line number Diff line change
    @@ -25,15 +25,15 @@ g () {
    branch=`command git rev-parse --abbrev-ref HEAD`
    if [[ $branch = 'master' ]]
    then
    while true; do
    echo -n "Push to 🔥 Master 🔥 ? (y/n) "
    while true; do
    echo -n "Push to 🔥 Master 🔥 ? (y/n) "
    read yn
    case $yn in
    [Yy]* ) command git "$@"; break;;
    [Nn]* ) echo "❤️ Push-to-Master crisis averted ❤️"; break;;
    * ) echo "Please answer yes or no.";;
    esac
    done
    case $yn in
    [Yy]* ) command git "$@"; break;;
    [Nn]* ) echo "❤️ Push-to-Master crisis averted ❤️"; break;;
    * ) echo "Please answer yes or no.";;
    esac
    done
    fi
    fi
    else
    @@ -44,11 +44,11 @@ g () {
    # git local repo user
    git_personal () {
    command git config user.name "Your Name"
    command git config user.email "[email protected]"
    command git config user.email "you@personal-domain.com"
    }

    # git work repo user
    git_work () {
    command git config user.name "Your Name"
    command git config user.email "[email protected]"
    command git config user.name "Your Professional Name"
    command git config user.email "you@work-domain.com"
    }
  6. trueheart78 revised this gist Mar 26, 2018. 1 changed file with 25 additions and 10 deletions.
    35 changes: 25 additions & 10 deletions git-functions.sh
    Original file line number Diff line number Diff line change
    @@ -10,16 +10,31 @@ g () {
    if [[ $# -gt 0 ]]
    then
    command git "$@"
    if [[ `uname` = 'Darwin' && $1 = "init" ]]
    then
    if [[ `uname` = 'Darwin' && $1 = "init" ]]; then
    # prompt for the username and email to use
    echo "Will this be a work-related repo?"
    select yn in "Yes" "No"; do
    while true; do
    echo -n "Will this be a ⚠️ work-related ⚠️ repo? (y/n) "
    read yn
    case $yn in
    Yes ) git_work; break;;
    No ) git_personal; break;;
    [Yy]* ) git_work; break;;
    [Nn]* ) git_personal; break;;
    * ) echo "Please answer yes or no.";;
    esac
    done
    elif [[ $1 = "push" ]]; then
    branch=`command git rev-parse --abbrev-ref HEAD`
    if [[ $branch = 'master' ]]
    then
    while true; do
    echo -n "Push to 🔥 Master 🔥 ? (y/n) "
    read yn
    case $yn in
    [Yy]* ) command git "$@"; break;;
    [Nn]* ) echo "❤️ Push-to-Master crisis averted ❤️"; break;;
    * ) echo "Please answer yes or no.";;
    esac
    done
    fi
    fi
    else
    command git status
    @@ -28,12 +43,12 @@ g () {

    # git local repo user
    git_personal () {
    git config user.name "Your Name"
    git config user.email "you@yourdomain.com"
    command git config user.name "Your Name"
    command git config user.email "you@personal.com"
    }

    # git work repo user
    git_work () {
    git config user.name "Your Name"
    git config user.email "you@workdomain.com"
    command git config user.name "Your Name"
    command git config user.email "you@work.com"
    }
  7. trueheart78 revised this gist Mar 26, 2018. 1 changed file with 7 additions and 2 deletions.
    9 changes: 7 additions & 2 deletions git-functions.sh
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,15 @@
    # remap git to point to g()
    git () {
    g "$@"
    }

    # git super command
    # make sure with zsh that the git plugin is not used
    # as it will override this command
    g () {
    if [[ $# -gt 0 ]]
    then
    git "$@"
    command git "$@"
    if [[ `uname` = 'Darwin' && $1 = "init" ]]
    then
    # prompt for the username and email to use
    @@ -17,7 +22,7 @@ g () {
    done
    fi
    else
    git status
    command git status
    fi
    }

  8. trueheart78 revised this gist Mar 26, 2018. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions git-functions.sh
    Original file line number Diff line number Diff line change
    @@ -8,10 +8,10 @@ g () {
    if [[ `uname` = 'Darwin' && $1 = "init" ]]
    then
    # prompt for the username and email to use
    echo "Will this be a CMM repo?"
    echo "Will this be a work-related repo?"
    select yn in "Yes" "No"; do
    case $yn in
    Yes ) git_cmm; break;;
    Yes ) git_work; break;;
    No ) git_personal; break;;
    esac
    done
  9. trueheart78 revised this gist Mar 26, 2018. 1 changed file with 7 additions and 9 deletions.
    16 changes: 7 additions & 9 deletions git-functions.sh
    Original file line number Diff line number Diff line change
    @@ -23,14 +23,12 @@ g () {

    # git local repo user
    git_personal () {
    git config user.name "Josh Mills"
    git config user.email "josh@trueheart78.com"
    git config user.name "Your Name"
    git config user.email "you@yourdomain.com"
    }
    alias git_th78="git_personal"

    # git cmm repo
    git_cmm () {
    git config user.name "Josh Mills"
    git config user.email "[email protected]"
    }
    alias git_th78="git_work"
    # git work repo user
    git_work () {
    git config user.name "Your Name"
    git config user.email "[email protected]"
    }
  10. trueheart78 created this gist Mar 26, 2018.
    36 changes: 36 additions & 0 deletions git-functions.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,36 @@
    # git super command
    # make sure with zsh that the git plugin is not used
    # as it will override this command
    g () {
    if [[ $# -gt 0 ]]
    then
    git "$@"
    if [[ `uname` = 'Darwin' && $1 = "init" ]]
    then
    # prompt for the username and email to use
    echo "Will this be a CMM repo?"
    select yn in "Yes" "No"; do
    case $yn in
    Yes ) git_cmm; break;;
    No ) git_personal; break;;
    esac
    done
    fi
    else
    git status
    fi
    }

    # git local repo user
    git_personal () {
    git config user.name "Josh Mills"
    git config user.email "[email protected]"
    }
    alias git_th78="git_personal"

    # git cmm repo
    git_cmm () {
    git config user.name "Josh Mills"
    git config user.email "[email protected]"
    }
    alias git_th78="git_work"