Skip to content

Commit

Permalink
rebase 2 ./esh
Browse files Browse the repository at this point in the history
  • Loading branch information
steve02081504 committed Nov 25, 2023
1 parent 4c1fa03 commit 684e012
Show file tree
Hide file tree
Showing 42 changed files with 31 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CI.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
. $PSScriptRoot/../../esh/main.ps1
. $PSScriptRoot/../../main.ps1

try{
$EshellUI.Init($MyInvocation)
Expand Down
6 changes: 2 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@

/Modules/*
/Scripts/*
/esh/data/SAO-lib.txt
/esh/data/vars/MSYSRootPath.txt
/data/SAO-lib.txt
/data/vars/MSYSRootPath.txt
46 changes: 23 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
# My powershell profile
# esh

只是个人配置文件。
原本只是个人配置文件来着 写着写着面向对象了 再写着写着成了一个方便安装的配置包
究竟是为什么呢

## 使用方法

- clone后放置于`~/Documents/powershell`
- 在windows terminal中将字体设置为[`FriaCode Nerd Font`](https://github.com/ryanoasis/nerd-fonts/releases/latest/download/FiraCode.zip)
- 你或许想追加`-NoProfileLoadTime -nologo`到powershell启动参数中
- 修改`$EshellUI.MSYS.RootPath`为你的msys2安装路径并`$EshellUI.SaveVariables()`
- 视需要修改其他文件内容
- 使用`add2profile.ps1`将esh添加到你的powershell配置文件中
- 使用`run.ps1`启动esh

## 快速开始

将以下命令复制粘贴到powershell中以快速开始

```powershell
$PwshProFiles = Split-Path $PROFILE
$ParentPath = Split-Path $PwshProFiles
New-Item -ItemType Directory -Force -Path $PwshProFiles | Out-Null
Remove-Item $PwshProFiles/esh -Confirm -ErrorAction Ignore -Recurse
Remove-Item $ParentPath/my-powershell-profile-master -Force -ErrorAction SilentlyContinue -Confirm:$false -Recurse
Invoke-WebRequest https://github.com/steve02081504/my-powershell-profile/archive/refs/heads/master.zip -OutFile Eshell.zip
Expand-Archive Eshell.zip $ParentPath -Force
Remove-Item $PwshProFiles/esh-master -Force -ErrorAction Ignore -Confirm:$false -Recurse
Invoke-WebRequest https://github.com/steve02081504/esh/archive/refs/heads/master.zip -OutFile Eshell.zip
Expand-Archive Eshell.zip $PwshProFiles -Force
Remove-Item Eshell.zip -Force
New-Item -ItemType Directory -Force -Path $PwshProFiles | Out-Null
Move-Item $ParentPath/my-powershell-profile-master/esh $PwshProFiles/esh -Force
Remove-Item $ParentPath/my-powershell-profile-master -Force -ErrorAction SilentlyContinue -Confirm:$false -Recurse
Move-Item $PwshProFiles/esh-master $PwshProFiles/esh -Force
& $PwshProFiles/esh/add2profile.ps1
. $PwshProFiles/esh/run.ps1
Remove-Variable @('PwshProFiles','ParentPath')
Remove-Variable PwshProFiles
```
![loading preview](https://github.com/steve02081504/my-powershell-profile/assets/31927825/c7ba3f3f-cdb2-4b93-8fdc-2f5901e0ce12)
![loading preview](https://github.com/steve02081504/esh/assets/31927825/c7ba3f3f-cdb2-4b93-8fdc-2f5901e0ce12)


如果你正在使用它,你可以这样更新:
Expand All @@ -45,42 +45,42 @@ Update-Eshell
## 功能预览

最低兼容PS7.2.15和Windows 6.1.7601(自动纠正编码设置)
![图片](https://github.com/steve02081504/my-powershell-profile/assets/31927825/e87b0407-f874-4d33-9a04-bda6f8c1658c)
![图片](https://github.com/steve02081504/esh/assets/31927825/e87b0407-f874-4d33-9a04-bda6f8c1658c)

支持VSCode的powershell扩展
![图片](https://github.com/steve02081504/my-powershell-profile/assets/31927825/f32cdef8-a1fc-42f0-ad1b-64ad87f70a05)
![图片](https://github.com/steve02081504/esh/assets/31927825/f32cdef8-a1fc-42f0-ad1b-64ad87f70a05)

### 提示符

git提示符支持
![图片](https://github.com/steve02081504/my-powershell-profile/assets/31927825/24808f4d-c1a1-48b0-94a6-da45b6cc4510)
![图片](https://github.com/steve02081504/esh/assets/31927825/24808f4d-c1a1-48b0-94a6-da45b6cc4510)

npm提示符支持
![图片](https://github.com/steve02081504/my-powershell-profile/assets/31927825/66c1732c-da1b-4d62-ad00-93852dc65529)
![图片](https://github.com/steve02081504/esh/assets/31927825/66c1732c-da1b-4d62-ad00-93852dc65529)

ukagaka提示符支持
![图片](https://github.com/steve02081504/my-powershell-profile/assets/31927825/9c3620ca-f15d-4a7d-8e5a-b0d321e58aab)
![图片](https://github.com/steve02081504/esh/assets/31927825/9c3620ca-f15d-4a7d-8e5a-b0d321e58aab)

可以通过修改`esh/src/system/UI/prompt/builders`来便捷自定义提示符

### 命令

rm、ls、cd、mv等常见文件操作命令支持linux和powershell两种风格调用(需要将msys2的bin添加到path)
![图片](https://github.com/steve02081504/my-powershell-profile/assets/31927825/fdf5e98a-5532-4318-9a81-c5337c6d323a)
![图片](https://github.com/steve02081504/esh/assets/31927825/fdf5e98a-5532-4318-9a81-c5337c6d323a)

linux路径支持(包括补全和索引command)
![图片](https://github.com/steve02081504/my-powershell-profile/assets/31927825/da57f8b3-59cc-461c-89c7-801951038245)
![图片](https://github.com/steve02081504/esh/assets/31927825/da57f8b3-59cc-461c-89c7-801951038245)

自动检索AppData
![图片](https://github.com/steve02081504/my-powershell-profile/assets/31927825/08eeaea8-5050-4378-91a2-45713b4b6915)
![图片](https://github.com/steve02081504/esh/assets/31927825/08eeaea8-5050-4378-91a2-45713b4b6915)

### 便捷指令

`poweroff``power off`关机(`shutdown`也可以不带参数被调用)
![图片](https://github.com/steve02081504/my-powershell-profile/assets/31927825/a164e5df-661f-47fa-a0fb-364349443410)
![图片](https://github.com/steve02081504/esh/assets/31927825/a164e5df-661f-47fa-a0fb-364349443410)

不用打开cmd,`mklink`也可以直接被使用(并且支持linux路径)
![图片](https://github.com/steve02081504/my-powershell-profile/assets/31927825/d8160647-ce17-4d1a-aca6-eafd48819d8d)
![图片](https://github.com/steve02081504/esh/assets/31927825/d8160647-ce17-4d1a-aca6-eafd48819d8d)

你说得对,但是`sudo`是由前面我忘了 后面我也忘了

Expand All @@ -91,6 +91,6 @@ icacls superhavyrock /inheritance:r
rm -rf superhavyrock
```

![图片](https://github.com/steve02081504/my-powershell-profile/assets/31927825/b0b3a4ed-f6fd-446e-a65b-602399bd0abe)
![图片](https://github.com/steve02081504/esh/assets/31927825/b0b3a4ed-f6fd-446e-a65b-602399bd0abe)

由于我懒,`dirsync`等其他命令不做介绍,请自行查看`$EshellUI.ProvidedFunctions()`
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion profile.ps1

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
11 changes: 5 additions & 6 deletions esh/src/commands/update.ps1 → src/commands/update.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,17 @@ function global:Update-gcc-Kawaii {
function global:Update-EShell {
Update-SAO-lib
$espath = $EshellUI.Sources.Path
$praentpath = Split-Path $espath
$datapath = "$espath/data"
try {
#下载最新的EShell
Invoke-WebRequest 'https://github.com/steve02081504/my-powershell-profile/archive/refs/heads/master.zip' -OutFile "$datapath/master.zip"
#解压缩my-powershell-profile-master中的src文件夹到$dataPath
Expand-Archive "$datapath/master.zip" "$datapath" -Force
Invoke-WebRequest 'https://github.com/steve02081504/esh/archive/refs/heads/master.zip' -OutFile "$datapath/master.zip"
#删除旧的src以确保干净
Remove-Item "$espath/src" -Recurse -Force
#更新文件
Copy-Item "$datapath/my-powershell-profile-master/esh" "$espath/.." -Recurse -Force
#删除my-powershell-profile-master
Remove-Item "$datapath/my-powershell-profile-master" -Recurse -Force
Rename-Item "$espath" "$praentpath/esh-master"
Expand-Archive "$praentpath/esh-master/data/master.zip" "$praentpath" -Force
Rename-Item "$praentpath/esh-master" "$espath"
#删除压缩包
Remove-Item "$datapath/master.zip" -Force
#重载EShell
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 684e012

Please sign in to comment.