Skip to content

Instantly share code, notes, and snippets.

@sarangnx
Last active October 7, 2020 08:34
Show Gist options
  • Select an option

  • Save sarangnx/1aa3d5637347d8da42e94f57fbf6196b to your computer and use it in GitHub Desktop.

Select an option

Save sarangnx/1aa3d5637347d8da42e94f57fbf6196b to your computer and use it in GitHub Desktop.

Revisions

  1. sarangnx revised this gist Oct 7, 2020. 1 changed file with 31 additions and 1 deletion.
    32 changes: 31 additions & 1 deletion .bashrc
    Original file line number Diff line number Diff line change
    @@ -2,4 +2,34 @@ git_branch() {
    git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/[ \1 ] /'
    }

    PS1="\[\033[02;37m\]\$(git_branch)\[\033[00m\]\[\033[01;32m\]\u\[\033[00m\]:\[\033[01;34m\]\W \[\033[00m\]\$ "
    PS1="\[\033[02;37m\]\$(git_branch)\[\033[00m\]\[\033[01;32m\]\u\[\033[00m\]:\[\033[01;34m\]\W \[\033[00m\]\$ "

    # Git commit using emoji
    cm() {

    # Menu
    echo "[ 0 ] 🌟 feat"
    echo "[ 1 ] πŸ”¨ fix"
    echo "[ 2 ] πŸ“” docs"
    echo "[ 3 ] 🌈 style"
    echo "[ 4 ] ✨ refactor"
    echo "[ 5 ] πŸ” test"
    echo "[ 6 ] πŸ’» chore"
    echo "[ 7 ] πŸ“¦ deps"

    # take user input
    # -n 1 takes 1 character input
    # -s does not echo user input
    read -n 1 -s option

    # array of prefixes
    prefixes=( "🌟 feat" "πŸ”¨ fix" "πŸ“” docs" "🌈 style" "✨ refactor" "πŸ” test" "πŸ’» chore" "πŸ“¦ deps" )

    if ! [[ $option =~ ^[0-7]$ ]]; then
    echo "Invalid Selection πŸ’"
    return
    fi

    git commit -m "${prefixes[$option]}: $@"

    }
  2. sarangnx created this gist Aug 1, 2019.
    5 changes: 5 additions & 0 deletions .bashrc
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    git_branch() {
    git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/[ \1 ] /'
    }

    PS1="\[\033[02;37m\]\$(git_branch)\[\033[00m\]\[\033[01;32m\]\u\[\033[00m\]:\[\033[01;34m\]\W \[\033[00m\]\$ "