最近切换电脑, 调试问题输入命令,各个平台上输的手疼,想着有别名来代替简输的方式; 后续我就可以输入一些简短缩写来执行命令了,省去了不少调试和手工输入时间;
1. 执行如下命令:
PS C:\Users\xxx> $profile
C:\Users\xxx\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
2. 在C:\Users\xxx\Documents\WindowsPowerShell\ 目录下,新建Microsoft.PowerShell_profile.ps1 文件
输入如下命令:
FUNCTION local { git config --local --list }
FUNCTION global { git config --global --list }
FUNCTION gk { gitk --all --date-order }
FUNCTION pull { git pull origin }
FUNCTION push { git push origin }
FUNCTION prune { git remote prune origin }
FUNCTION hf { gitk HEAD..FETCH_HEAD }
FUNCTION dhf { gitk HEAD...FETCH_HEAD }
FUNCTION tag { git tag --list }
Function pypath { python -c "import sys, json;print(json.dumps(sys.path, indent=4))" }
重启 PowerShell 终端, 即可;
#
# 1. open file: /User/xxx/.bash_profile
# 2. $ source /User/xxx/.bash_profile
#
# alias list
# git region
alias gitk="sed -i .bak 's/zoomed/normal/g' ~/.config/git/gitk && /usr/local/bin/gitk"
alias local="git config --local --list"
alias global="git config --global --list"
alias gk="gitk --all --date-order&"
alias pull="git pull origin"
alias push="git push origin"
alias prune="git remote prune origin"
alias hf="gitk HEAD..FETCH_HEAD"
alias dhf="gitk HEAD...FETCH_HEAD"
alias tag="git tag --list"
alias gitc="git clone"
#
# mac region
#
alias hidden="defaults write com.apple.finder AppleShowAllFiles NO"
alias show="defaults write com.apple.finder AppleShowAllFiles YES"
alias csr_off="csrutil disable"
alias csr_on="csrutil enable"
alias du="du -sh * | sort -hr"
#
# python region
#
alias pypath="python -c 'import sys, json;print(json.dumps(sys.path, indent=4))'"
#
# adb region
#
alias ss="~/.tools/screenshot.sh"
alias SS=ss
alias sr="~/.tools/screenrecord.sh"
alias SR=sr
#
screenshot.sh
#!/bin/bash
dd=`date +%Y%m%d_%H%M%S`
day=`date +%Y%m%d`
media_prefix_directory="/Users/xxx/.tools/Screenshot"
dest_direcotry="${media_prefix_directory}/${day}"
if [ ! -d "${media_prefix_directory}" ]; then
mkdir $media_prefix_directory
fi
if [ ! -d "${dest_direcotry}" ]; then
mkdir $dest_direcotry
fi
# adb shell screencap -h
adb shell screencap -p /sdcard/screenshot.png
adb pull /sdcard/screenshot.png $dest_direcotry/$dd.png
adb shell rm /sdcard/screenshot.png
echo "the screenshot was saved to "$dest_direcotry/$dd.png
# open $dest_direcotry --reveal
open -a Preview $dest_direcotry/$dd.png
screenrecord.sh
#!/bin/bash
dd=`date +%Y%m%d_%H%M%S`
day=`date +%Y%m%d`
media_prefix_directory="/Users/xxx/.tools/Screenrecord"
dest_direcotry="${media_prefix_directory}/${day}"
if [ ! -d "${media_prefix_directory}" ]; then
mkdir $media_prefix_directory
fi
if [ ! -d "${dest_direcotry}" ]; then
mkdir $dest_direcotry
fi
# adb shell screenrecord --help
# adb shell screenrecord --size 1920x1080 --bit-rate 4000000 --verbose /sdcard/screenrecord.mp4
# adb shell screenrecord --time-limit 3 --size 1280x720 --bit-rate 6000000 --verbose /sdcard/screenrecord.mp4
# adb shell screenrecord --time-limit 6 --size 1280x720 --bit-rate 4000000 --verbose /sdcard/screenrecord.mp4
# adb shell screenrecord --time-limit 6 --size 1280x720 --bit-rate 6000000 --verbose /sdcard/screenrecord.mp4
adb shell screenrecord --time-limit 6 --size 1920x1080 --bit-rate 6000000 --verbose /sdcard/screenrecord.mp4
# adb shell screenrecord --time-limit 10 --size 1280x720 --bit-rate 6000000 --verbose /sdcard/screenrecord.mp4
# adb shell screenrecord --time-limit 60 --size 1280x720 --bit-rate 6000000 --verbose /sdcard/screenrecord.mp4
# adb shell screenrecord --time-limit 120 --size 1280x720 --bit-rate 6000000 --verbose /sdcard/screenrecord.mp4
# adb shell screenrecord --time-limit 180 --size 1280x720 --bit-rate 6000000 --verbose /sdcard/screenrecord.mp4
adb pull /sdcard/screenrecord.mp4 $dest_direcotry/$dd.mp4
adb shell rm /sdcard/screenrecord.mp4
echo "the screenrecord was saved to "$dest_direcotry/$dd.mp4
# open $dest_direcotry --reveal
open -a Finder $dest_direcotry/$dd.mp4
执行如下命令, 使得别名设置生效:
# xxx 替换为你的机器上用户名
$ source /User/xxx/.bash_profile