在 ~/.bash_profile 文件中增加以下内容
# adb cmd
alias a='adb shell'
alias akill='adb kill-server'
alias astart='adb start-server'
alias apush='adb push '
alias apull='adb pull '
alias areboot='adb reboot'
alias atop='adb shell dumpsys activity top'
alias arecovery='adb reboot recovery'
alias abootloader='adb reboot bootloader'
alias alog='adb logcat'
# other cmd
alias rmdir='rm -r'
alias sourceb="source ~/.bash_profile"
alias antbuild='ant clean build'
alias obash='o ~/.bash_profile'
alias nstart='npm start'
# alias ninstall='npm install'
# alias npmtb='npm config set registry http://registry.npm.taobao.org/'
# alias npmofficial='npm config set registry https://registry.npmjs.org/'
alias javaloc='/usr/libexec/java_home -V'
alias pspy='ps -eaf|grep python'
alias kill9='kill -9 '
alias lastweek="git log --pretty=format:\"%an: %s\" --since=1.weeks "
alias clone="git clone "
alias st="git status "
# 获取 ip 地址并拷贝到粘贴板(针对 mac os)
ipcp(){
ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|tr -d "addr:"| pbcopy
}
# 执行脚本并在脚本执行完成后给予提示(针对 mac os)
ish(){
sh $*
say "脚本执行完成"
osascript -e 'display notification "脚本执行完成" with title "ish"'
}
# 获取 ip 地址
ip(){
ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|tr -d "addr:"
}
# 通过 wifi 的形式连接 android 设备
acon(){
line="------------------------------------------\r\n"
echo "now we fetch the ip of android device"
aip=`adb shell ifconfig |grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|tr -d "addr:"`
echo "ip is ${aip}"
echo ${line}
echo "now we connect"
adb connect ${aip}
echo ${line}
adb devices -l
}
adis(){
adb disconnect
}
# 安装 apk ,并在结束时给予声音和通知栏提示(针对 mac os)
apk(){
adb install $*
# 以下两行针对 mac os
say 安装完成
osascript -e 'display notification "安装完成" with title "apk"'
}
# 使用 SublimeText 打开内容
o(){
Open -a /Applications/SublimeText.app $1
}
# 查看 apk 包信息
apkdump(){
aapt dump badging $1
}
# 查看已连接设备
list(){
adb devices -l
}
arecord() {
if [ $# -eq 0 ]
then
name="record"
else
name="record$1"
fi
adb shell screenrecord /sdcard/demo${name}.mp4
say "录制完成"
}
# 对当前设备截图保存到命令执行所在目录且将其打开
asp() {
target_dir=`pwd`
if [ $# -eq 0 ]
then
name="screenshot.png"
else
name="$1.png"
if [ $# -eq 2 ]
then
target_dir=$2
fi
fi
adb shell screencap -p /sdcard/${name}
adb pull /sdcard/${name} ${target_dir}/${name}
adb shell rm /sdcard/${name}
echo "save to $target_dir/${name}"
# for mac os
open $name
}