Created
June 6, 2018 10:12
-
-
Save akshygupt/3f203b6052148a3b059a9da75bca9dd2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
alias gp#!/usr/bin/env bash | |
#Functions for the alias | |
subl(){ | |
if [ $# -eq 0 ]; then | |
open -a 'Sublime Text' | |
else | |
str="$*" | |
open -a 'Sublime Text' "$str" | |
fi | |
} | |
git_commit(){ | |
# the $# list the number of parameters passed | |
# the [ $# -eq 0 ] checks if the length of the arguments is 0 | |
# here the arugments is the commit message so the user doesnt have to put double quots while giving messages | |
# example :- gcm commit message here | |
if [ $# -eq 0 ]; then | |
echo "No commit message provided" | |
else | |
str="$*" | |
# the "$*" takes the arguments and puts it in a string | |
#echo $str | |
git commit -m "$str" | |
fi | |
} | |
#this function is the aggregate of 2 commands "git add ." and "git commit" so the user can use one command to "add" and commit | |
#example :- ga-cm commit message here | |
#the above example is equvalent to : | |
# git add . | |
# git commit -m "commit message here" | |
git_add_commit(){ | |
git add . | |
git_commit "$@" | |
} | |
#This function automatically takes the branch name and adds that to the "git push" command, so no need to specify branch name | |
git_push(){ | |
branch_name=$(git rev-parse --symbolic-full-name --abbrev-ref HEAD) | |
git push origin "${branch_name}" | |
} | |
#This function automatically takes the branch name and adds that to the "git pull" command, so no need to specify branch name | |
git_pull(){ | |
branch_name=$(git rev-parse --symbolic-full-name --abbrev-ref HEAD) | |
git pull origin "${branch_name}" | |
} | |
#This function is the aggregate of 2 functions "git commit" and "git push" | |
git_commit_push(){ | |
git_add_commit "$@" | |
git_push | |
} | |
git_stash_save(){ | |
if [ $# -eq 0 ]; then | |
echo "No stash save message provided" | |
else | |
str="$*" | |
git stash save "$str" | |
chmod -R 777 . | |
fi | |
} | |
git_stash(){ | |
git stash | |
chmod -R 777 . | |
} | |
git_diff(){ | |
if [ $# -eq 0 ]; then | |
echo "Provide a number from the uncommited changes file list" | |
else | |
str="$*" | |
files=`git diff --name-only` #files=`git diff --name-only | grep -E '.php$' ` | |
INDEX=0 | |
for file in $files; do | |
if [ $str -eq $INDEX ]; then | |
git diff "$file" | |
break | |
fi | |
let INDEX=${INDEX}+1 | |
done | |
fi | |
} | |
emulator(){ | |
/Users/riayzahmed/Library/Android/sdk/tools/emulator "$@" | |
} | |
goto_project_directory(){ | |
if [ $# -eq 0 ]; then | |
cd ~/Projects | |
else | |
str="$*" | |
cd ~/Projects/"$str"* #star auto completes path | |
fi | |
} | |
goto_server_directory(){ | |
if [ $# -eq 0 ]; then | |
cd /Applications/MAMP/htdocs | |
else | |
str="$*" | |
cd "/Applications/MAMP/htdocs/$str"* #star auto completes path | |
fi | |
} | |
#-------------------------------------------------------Aliases ----------------------------------------------------- | |
#alias edit-bash=“open ~/.bash_profile” | |
#Git related alias | |
alias gl="git log --pretty=format:'%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]' --decorate --numstat" #git log with pretty log messages | |
#find your log type: http://durdn.com/blog/2012/11/22/must-have-git-aliases-advanced-examples/ | |
alias ga="git add ." #simple git add . //to add all files | |
alias gcm="git_commit" #simple git commit // example :- gcm commit message here without double quotes | |
alias gb="git branch" #simple git branch //example :-gb | |
alias gc="git checkout $@" #simple git checkout // example :- gc branch_name | |
alias gc-b="git checkout -b $@" #simple git checkout with -b (to create new branch) // example:- gc-b new_branch_name | |
alias gm="git merge $1" #simple git merge // example:- gm merge_branch_name | |
alias gsh="git_stash" #simple git stash | |
alias gsh-l="git stash list" #simple git stash list | |
alias gpl="git_pull" #simple git pull which pulls from origin of the current branch | |
alias gsh-s="git_stash_save $@" #saves stash with message //example:- gsh stash message without quotes | |
alias gp="git_push" #It pushes to origin on current branch automatically no need to specify branch name | |
alias ga-cm="git_add_commit $@" #adds files then commits | |
alias gcm-p="git_commit_push $@" #adds files then commits then pushes | |
alias g-save-c="git config credential.helper store" # saves user credentials so you dont have to type your password every time while pushing or pulling from origin | |
alias g-conflicts="git ls-files -u" | |
alias gd="git_diff $@" | |
alias g-delete="git branch -d $@" | |
alias g-delete-f="git branch -D $@" | |
alias g-delete-origin="git push origin --delete $@" | |
#non-Git related alias | |
alias cd-p="goto_project_directory $@" | |
alias cd-s="goto_server_directory $@" | |
alias edit-bash="subl ~/.aliases" | |
alias generate-apk="./gradlew assembleRelease" | |
alias rn-ios="react-native run-ios" | |
alias rn-android="react-native run-android" | |
alias rn-s="react-native start" | |
alias rn-s-c="react-native start --reset-cache" | |
alias clear-p="chmod -R 777 ." | |
alias adb-time="adb shell su root date $(date +%m%d%H%M%Y.%S)" | |
alias emulator="emulator $@" | |
alias emulator-start="emulator -avd $@" | |
alias emulator-list="emulator -list-avds" | |
# Print each PATH entry on a separate line | |
alias path='echo -e ${PATH//:/\\n}' | |
alias ..='cd ..' | |
alias subl="subl $@" | |
alias ls='ls -GFh' | |
# View the current working tree status using the short format | |
alias gs="git status -s" #git branch -v | |
alias adb-menu="adb shell input keyevent KEYCODE_MENU" | |
alias adb-reverse="adb reverse tcp:8081 tcp:8081" | |
# Show the diff between the latest commit and the current state | |
#alias gd="git diff-index --quiet HEAD -- || clear; git --no-pager diff --patch-with-stat" | |
# Find branches containing commit | |
alias gfb="!f() { git branch -a --contains $1; }; f" | |
alias g-remove-cache="git rm -r --cached . " | |
alias webpack-watch="webpack --progress --color --watch" | |
alias show-build="cd build & http-server" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment