Skip to content

Instantly share code, notes, and snippets.

@shinmiy
Last active May 17, 2022 08:10
Show Gist options
  • Save shinmiy/5fa42c9132a49d9dd909dfe9746d723a to your computer and use it in GitHub Desktop.
Save shinmiy/5fa42c9132a49d9dd909dfe9746d723a to your computer and use it in GitHub Desktop.
git aliases.
echo "setting aliases..."
alias la='ls -alG'
##############peco################
alias cdp='cd "$( ls -1d */ | peco )"'
alias pecopy='peco|tr -d "\n"|pbcopy'
####################git####################
# source /usr/local/etc/bash_completion.d/git-prompt.sh
# source /usr/local/etc/bash_completion.d/git-completion.bash
##git status
alias gits='git status'
##git log
alias gitl='git log --graph --date=iso --format="%C(yellow)%h%C(reset) %C(magenta)[%ad](%ar)%C(reset)%C(green)%d%C(reset) %s %C(cyan)@%an%C(reset)"'
alias gitlh='gitl -n10'
##git diff
alias gitd='git diff --histogram'
alias gitdc='git diff --histogram --cached'
alias gitdw='git diff --histogram -w'
alias gitdcw='gitdc -w'
##git fetch
alias gitf='git fetch'
##git branch
alias gitb='git branch'
alias gitbr='git branch -r'
##git add
alias gitai='git add -i'
alias gitap='git add -p'
##git commit
alias gitc='git commit -m'
alias gitca='git commit --amend'
alias gitcp='git cherry-pick'
##git push
alias gitpom='read -p "Push to origin/master?[Yy] " -n 1 -r;echo;if [[ $REPLY =~ ^[Yy]$ ]];then git push origin master;fi'
alias gitpoc='read -p "Have you tried running the app?[Yy] " -n 1 -r;echo;if [[ $REPLY =~ ^[Yy]$ ]];then read -p "Push current branch to origin?[Yy] " -n 1 -r;echo;if [[ $REPLY =~ ^[Yy]$ ]];then git rev-parse --abbrev-ref HEAD|xargs git push origin;fi;fi'
## git reset
alias gitrh='git reset HEAD'
##git checkout
alias gitco='git checkout'
# __git_complete gitco _git_checkout
alias gitcob='git checkout -b'
alias gitcol='echo $(git describe --tags --abbrev=0);gitco $(git describe --tags --abbrev=0)' # 最新のtagをcheckout
##open github
# alias gitopen="git config --get remote.origin.url|sed -e 's/\:/\//g'|sed -e 's/\git@/http\:\/\//g'|sed -e 's/\.git$//g'|xargs open"
alias gitopen="git config --get remote.origin.url|sed -e 's/\.git$//g'|xargs open"
#######################adb###########################
# alias adbd='adb devices'
alias adbd='for i in `adb devices|sed -n "1d;p"|sed "$ d"|cut -f1`;do printf "$i : ";adb -s $i shell getprop ro.product.model;done'
alias adbi='adb shell input text'
alias adb-listpackages='adb shell pm list packages|sed s/package://g|peco'
alias adb-version='for i in `adb-listpackages`;do printf "%-28s : " $i;printf $(adb shell dumpsys package $i|grep versionName|sed "s/ *versionName=//g");printf " ($(adb shell dumpsys package $i|grep -oE "versionCode=[0-9]+"|sed "s/versionCode=//g"))\n";done'
alias adb-uninstall='for i in `adb-listpackages`;do echo "adb uninstall $i";adb uninstall $i;done'
alias adb-forcekill='for i in `adb-listpackages`;do echo "adb shell am force-stop $i";adb shell am force-stop $i;done'
alias adb-installr='adb install -r'
alias adb-clearStorage='for i in `adb-listpackages`;do echo "adb shell am force-stop $i";adb shell pm clear $i;done'
alias adb-home='adb shell input keyevent 3'
echo "bashrc done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment