Windows powershell添加自定义快捷指令(Linux下对比)

Windows Powershell

1.创建并修改Windows Powershell 启动执行文件
echo $PROFILE

在这里插入图片描述
编辑C:\Users\hongyang.jia\Documents\PowerShell\Microsoft.PowerShell_profile.ps1

2.按照以下格式输入命令

function 别名 { 需要替代的命令 }

例如我的Git简写命令

function gs {git status}

function中多行脚本执行报:因为在此系统上禁止运行脚本。有关详细信息,问题解决:

管理员运行powershell,执行:

set-executionpolicy remotesigned

示例

function sremote {wsl -d Ubuntu-20.04 sh -c "echo password| sudo -S; sshpass -p password ssh hongyang.jia@IP"}
function slocal {wsl -d Ubuntu-20.04 sh -c "echo 123456 | sudo -S; sshpass -p 123456 ssh root@IP "}
function scopy($file,$to) {
    Write-Output $args[1]
    $front="echo 123456 | sudo -S; sshpass -p password scp -r hongyang.jia@IP:/home/hongyang.jia/"
    $front="$front$file $to"
    Write-Host $file
    wsl -d Ubuntu-20.04 sh -c $($front)
}
function sinstall() {
    cd  D:\Out\libxrengine_gtest
    scopy code/framework/out/target/product/monaco_go/symbols/system/lib/libxrengine.so  .
    adb root ; adb remount
    adb push libxrengine.so  /system/lib/
    adb  reboot 
    adb wait-for-device
    adb root ; adb remount
    adb wait-for-device
    adb shell  "setenforce 0; stop; sleep 1s; start"
    adb wait-for-device
}
function smake($mod) {
    $cmd="sshpass -p password ssh  hongyang.jia@IP cd /home/hongyang.jia/code/framework \&\&source build/envsetup.sh \&\& lunch 30 \&\& make $mod -j64"
    wsl -d Ubuntu-20.04 sh -c $($cmd)
}
function sinstallmod($mod) {
    cd  D:\Out\libxrengine_gtest
    scopy code/framework/out/target/product/monaco_go/symbols/system/lib/lib$mod.so  .
    adb root ; adb remount
    adb push lib$mod.so  /system/lib/
}
function srun() {
    $start = Get-Date
    wsl sh -c "sshpass -p password ssh  hongyang.jia@IP cd /home/hongyang.jia/code/framework \&\&source build/envsetup.sh \&\& lunch 30 \&\& make xr_renderengine -j64"
    sinstall
    $end = Get-Date
    Write-Host -ForegroundColor Red ('Total Runtime: ' + ($end - $start).TotalSeconds)
}
function scrcpy {	#传递任意参数
    & D:\software\scrcpy-win64-v2.1\scrcpy.exe $args
}
function scopyso{
    cd  D:\Out\libxrengine_gtest
    scopy code/framework/out/target/product/monaco_go/symbols/system/lib/libxrengine.so  .
}
function sdebug{
    D:\Pro\adbDebug\debug.bat
    adb  logcat -v threadtime | D:\Android\Sdk\ndk\21.4.7075529\prebuilt\windows-x86_64\bin\ndk-stack -sym D:\Out\libxrengine_gtest
}
function shelp() {
    "    1.sremote"
    "    2.slocal"
    "    3.srun  :重新编译xrengine,安装调试"
    "    4.scopy [source] [target] :copy from IP:/home/hongyang.jia/"
    "    5.scopyso  :copy so动态库"
    "    6.sdebug   :抓取crash"
}
function splay{
    shelp
    $choice = Read-Host "请选择:"
    if([string]::IsNullOrWhiteSpace($choice)) {
        return
    }
}
function sshow{
"    #开启引擎
    adb root 
    adb shell setprop persist.xrrender.supported 1
    adb shell reboot

    #开启3dof
    adb root
    adb shell  'setenforce 0; stop; sleep 1s; start'
    exit"
}



Ubuntu shell

vi ~/Desktop/init/note.sh

添加如下:

function scopy()
{
	local fileName
    if [ "$1" ] ; then
        fileName=$1
	fi
	sshpass -p password scp -r hongyang.jia@ip:$fileName .
}

function smount()
{
	mount -t cifs -o username="hongyang.jia",password="password" //ip/hongyang.jia   /mnt/star
}

function sremote()
{
	sshpass -p password ssh hongyang.jia@ip;clear
}

function sandroid()
{
	export PATH=$PATH:/root/Android/Sdk/cmake/3.22.1/bin
	export ANDROID_NDK=/root/Android/Sdk/ndk/21.4.7075529
	export ANDROID_SDK=/root/Android/Sdk
	export PATH=$PATH:$ANDROID_NDK:/root/Android/Sdk/platform-tools/
	export ANDROID_HOME=$ANDROID_SDK
}

function spush()
{
	local fileN
    if [ "$1" ] ; then
        fileN=$1
	fi
	sandroid
	adb shell "mkdir -p /sdcard/AiCoding/"
	adb push $fileN /sdcard/AiCoding/
}

echo be ready
vi ~/.bashrc

最后面添加一行

source ~/Desktop/init/note.sh

然后

source ~/.bashrc
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值