Last active
August 29, 2015 13:57
-
-
Save kaushikgopal/9671296 to your computer and use it in GitHub Desktop.
A ruby script that makes it easier to quickly add to git the last files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
=begin | |
# sample output for git status -s | |
M pkk/src/main/java/com/micromobs/pkk/fragments/GuestProfileQuestionnaireStep1Fragment.java | |
M pkk/src/main/java/com/micromobs/pkk/fragments/GuestProfileQuestionnaireStep2Fragment.java | |
M pkk/src/main/java/com/micromobs/pkk/ui/viewmodels/MembershipViewModel.java | |
M pkk/src/main/res/layout/fragment_guest_profile_questionnaire_step_2.xml | |
M pkk/src/main/res/layout/fragment_guest_profile_questionnaire_step_4.xml | |
=end | |
# Get line number for file that needs to be added | |
argument = ARGV.pop | |
# do a git status and get the second argument | |
# filename = %x[git status -s | sed -n '#{argument}p'].split(" ", 2)[1] | |
# but i like awk! | |
filename = %x[git status -s | awk 'NR==#{argument}'].split(" ", 2)[1] | |
git status -s | awk 'NR { print }' | |
%x[git add #{filename}] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment