Windows powershell添加自定义快捷指令(Linux下也有)

您所在的位置:网站首页 结构设计选题的目的和意义 Windows powershell添加自定义快捷指令(Linux下也有)

Windows powershell添加自定义快捷指令(Linux下也有)

2023-06-13 12:34| 来源: 网络整理| 查看: 265

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 123456 | sudo -S; sshpass -p passworld 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 passworld scp -r hongyang.jia@ip:/home/hongyang.jia/" $front="$front$file $to" Write-Host $file wsl -d Ubuntu-20.04 sh -c $($front) } function srun() { cd D:\Out\libxrengine_gtest wsl sh -c "sshpass -p passworld ssh hongyang.jia@ip cd /home/hongyang.jia/code/framework \&\&source build/envsetup.sh \&\& lunch 30 \&\& make xr_renderengine -j64" 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 scopyso{ cd D:\Out\libxrengine_gtest scopy code/framework/out/target/product/monaco_go/symbols/system/lib/libxrengine.so . } function sdebug{ 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 my_passworld scp -r hongyang.jia@ipaddr:$fileName . } function smount() { mount -t cifs -o username="hongyang.jia",password="my_passworld " //ipaddr/hongyang.jia /mnt/star } function sremote() { sshpass -p my_passworld ssh hongyang.jia@ipaddr ;clear } echo be ready vi ~/.bashrc

最后面添加一行

source ~/Desktop/init/note.sh

然后

source ~/.bashrc


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3