简化常用命令(修改 .bash_profile 文件)

在 ~/.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
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

杨筱毅

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值