提交powershell文档
This commit is contained in:
parent
7b89b526dd
commit
0539704a31
@ -159,7 +159,19 @@ ssh-keygen -c -C "new_comment" -f ssh_key_path
|
||||
git checkout -- <filename or directory>
|
||||
```
|
||||
|
||||
## git 如何关闭commit时的语法检测 ---husky
|
||||
|
||||
1 报错提示
|
||||
git commit提交时报错如下:
|
||||
|
||||
husky+>+pre-commit+(node+v14.18.2)
|
||||
|
||||
2 解决方案
|
||||
1:卸载husky。只要把项目的package.json文件中devDependencies节点下的husky库删掉,然后重新npm i 一次即可。或者直接在项目根目录下执行npm uninstall husky --save也可以,再次提交,自动化测试功能就屏蔽掉
|
||||
|
||||
2:进入项目的.git文件夹(文件夹默认隐藏,可先设置显示或者命令ls查找),再进入hooks文件夹,删除pre-commit文件,重新git commit -m ‘xxx’ git push即可
|
||||
|
||||
3:将git commit -m “XXX” 改为 git commit --no-verify -m “xxx”
|
||||
|
||||
# github
|
||||
|
||||
|
||||
@ -140,6 +140,10 @@ tar -zxvf:解压(最常用)
|
||||
tar -zxvf wwwroot.tar.gz
|
||||
```
|
||||
|
||||
tar.gz 和 tgz 的区别
|
||||
|
||||
tar.gz 和 tgz 是两种常见的压缩文件格式,它们在本质上是相同的,只是文件扩展名不同。两者都是通过 tar 命令将多个文件打包成一个文件,然后再使用 gzip 压缩工具进行压缩。
|
||||
|
||||
### 系统服务:
|
||||
|
||||
systemstl:操作系统服务。
|
||||
@ -1310,7 +1314,7 @@ systemctl daemon-reload
|
||||
|
||||
## 挂载远程卷
|
||||
|
||||
### Windows
|
||||
### Windows 网络共享位置
|
||||
|
||||
首先创建本地的挂载目录,一般在`/mnt`下
|
||||
|
||||
@ -1332,6 +1336,16 @@ dnf install -y cifs-utils
|
||||
mount -t cifs -o username=user,password=backup //192.168.0.1/备份 /mnt/wdshare/
|
||||
```
|
||||
|
||||
以上为暂时挂载,还需要永久挂载,避免系统重启后挂载丢失
|
||||
|
||||
编辑`/etc/fstab`配置文件,在最后一行添加以下配置
|
||||
|
||||
```shell
|
||||
//192.168.0.1/备份 /mnt/wdshare/ cifs username=user,password=backup 0 0
|
||||
```
|
||||
|
||||
|
||||
|
||||
## 分配Swap
|
||||
|
||||
查看分区大小
|
||||
|
||||
@ -60,3 +60,152 @@ set-alias -name sudo -value _sudo
|
||||
```text
|
||||
set-ExecutionPolicy RemoteSigned
|
||||
```
|
||||
|
||||
# 实用脚本
|
||||
|
||||
## 自动延长VS社区版过期时间
|
||||
|
||||
> 该脚本作用为 自动检查VS社区版是否在一天内过期,如是则自动延长30天
|
||||
>
|
||||
> 需事先从Github上Clone开源项目[beatcracker/VSCELicense: PowerShell module to get and set Visual Studio Community Edition license expiration date in registry (github.com)](https://github.com/beatcracker/VSCELicense)
|
||||
>
|
||||
> 然后放置在指定目录,并解除脚本执行限制,以管理员身份执行如下命令:
|
||||
>
|
||||
> ```powershell
|
||||
> Set-ExecutionPolicy RemoteSigned
|
||||
> ```
|
||||
>
|
||||
> 输入 A 即可
|
||||
|
||||
```powershell
|
||||
# 加载 VSCELicense 模块
|
||||
try {
|
||||
Import-Module -Name 'C:\VSCELicense\VSCELicense.psd1' -ErrorAction Stop
|
||||
} catch {
|
||||
Write-Error "无法加载模块 'C:\VSCELicense\VSCELicense.psd1',请确认路径是否正确。错误信息: $_"
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
||||
# 获取许可证信息
|
||||
try {
|
||||
$output = Get-VSCELicenseExpirationDate -ErrorAction Stop | Out-String
|
||||
} catch {
|
||||
Write-Error "执行 Get-VSCELicenseExpirationDate 时出错: $_"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# 使用正则表达式提取版本号和过期日期
|
||||
$version = $null
|
||||
$expDateStr = $null
|
||||
|
||||
if ($output -match '(?m)^\s*(\d{4})\s+(\d{2}/\d{2}/\d{4}\s+\d{2}:\d{2}:\d{2})') {
|
||||
$version = $matches[1].Trim()
|
||||
$expDateStr = $matches[2].Trim()
|
||||
Write-Host "找到版本: $version"
|
||||
Write-Host "过期日期: $expDateStr"
|
||||
} else {
|
||||
Write-Error "无法从输出中找到版本和过期日期"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# 将过期日期字符串解析为 DateTime 对象
|
||||
try {
|
||||
$expirationDate = [datetime]::ParseExact($expDateStr, 'dd/MM/yyyy HH:mm:ss', $null)
|
||||
} catch {
|
||||
Write-Error "日期格式解析失败: $expDateStr. 错误: $_"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# 获取当前时间并设置阈值
|
||||
$currentTime = Get-Date
|
||||
$threshold = $currentTime.AddDays(1)
|
||||
|
||||
Write-Host "当前时间: $currentTime"
|
||||
Write-Host "过期时间: $expirationDate"
|
||||
Write-Host "阈值时间(当前时间 + 1天): $threshold"
|
||||
|
||||
# 判断是否在1天内过期 -le 表示小于等于 想起了 Mybatis-Plus 条件构造器中的 le
|
||||
if ($expirationDate -le $threshold) {
|
||||
Write-Host "许可证即将过期,正在执行 Set-VSCELicenseExpirationDate 命令..."
|
||||
try {
|
||||
Set-VSCELicenseExpirationDate -Version $version -ErrorAction Stop
|
||||
Write-Host "Set-VSCELicenseExpirationDate 命令执行成功。"
|
||||
} catch {
|
||||
Write-Error "执行 Set-VSCELicenseExpirationDate 时出错: $_"
|
||||
exit 1
|
||||
}
|
||||
} else {
|
||||
Write-Host "许可证未在一天内过期,无需操作。"
|
||||
}
|
||||
```
|
||||
|
||||
输出如下:
|
||||
|
||||

|
||||
|
||||
可结合任务计划程序进行使用,免去手动执行的烦恼
|
||||
|
||||

|
||||
|
||||
### 🧩 步骤 1:打开任务计划程序
|
||||
|
||||
1. 按下 `Win + R`,输入 `taskschd.msc`,回车。
|
||||
2. 在左侧的“任务计划程序库”中,右键选择“创建任务”。
|
||||
|
||||
### 🧩 步骤 2:设置任务基本信息
|
||||
|
||||
- 常规
|
||||
|
||||
选项卡:
|
||||
|
||||
- 名称:例如 `Check-VS-LicenseExpiration`
|
||||
- 描述(可选):每天早上 7 点检查许可证过期状态
|
||||
- 勾选“不管用户是否登录都要运行”
|
||||
- 勾选“使用最高权限”
|
||||
|
||||

|
||||
|
||||
### 🧩 步骤 3:设置触发器
|
||||
|
||||
1. 切换到 **触发器** 选项卡。
|
||||
2. 点击 **新建** 。
|
||||
3. 设置:
|
||||
- 开始时间:`07:00:00`
|
||||
- 每天
|
||||
- 勾选“启用此触发器”
|
||||
4. 点击 **确定** 。
|
||||
|
||||

|
||||
|
||||
### 🧩 步骤 4:设置操作
|
||||
|
||||
1. 切换到 **操作** 选项卡。
|
||||
2. 点击 **新建** 。
|
||||
3. 设置:
|
||||
- 操作:`启动程序`
|
||||
- 程序/脚本:`powershell.exe`
|
||||
- 参数(可选):`-ExecutionPolicy RemoteSigned -File "C:\VSCELicense\Check-VS-LicenseExpiration.ps1`
|
||||
- 起始于(可选):`C:\VSCELicense`(确保路径正确)
|
||||
|
||||
> ✅ **说明** :
|
||||
>
|
||||
> - `-ExecutionPolicy RemoteSigned`:允许本地脚本运行,避免执行策略限制。
|
||||
> - `"C:\VSCELicense\Check-VS-LicenseExpiration.ps1"`:替换为你实际的脚本路径。
|
||||
> - 如果脚本路径包含空格,请用双引号包裹。
|
||||
|
||||
### 🧩 步骤 5:设置条件(可选)
|
||||
|
||||
1. 切换到 **条件** 选项卡。
|
||||
2. 可以取消勾选“只有在计算机使用交流电源时才启动此任务”,确保任务在任何电源模式下都能运行。
|
||||
|
||||
### 🧩 步骤 6:设置设置(可选)
|
||||
|
||||
1. 切换到 **设置** 选项卡。
|
||||
2. 勾选“如果任务失败,按以下频率重新启动”并设置时间间隔(如每 1 分钟)。
|
||||
3. 勾选“如果任务运行时间超过以下时间,则停止任务”并设置合理时间(如 1 小时)。
|
||||
|
||||
### 🧩 步骤 7:保存任务
|
||||
|
||||
1. 点击 **确定** 。
|
||||
2. 如果弹出用户账户控制(UAC)提示,输入管理员凭据确认。
|
||||
|
||||
BIN
source/_posts/PowerShell/image-20250718112238088.png
Normal file
BIN
source/_posts/PowerShell/image-20250718112238088.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
BIN
source/_posts/PowerShell/image-20250718142545538.png
Normal file
BIN
source/_posts/PowerShell/image-20250718142545538.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 30 KiB |
BIN
source/_posts/PowerShell/image-20250718142556458.png
Normal file
BIN
source/_posts/PowerShell/image-20250718142556458.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
BIN
source/_posts/PowerShell/image-20250718142611106.png
Normal file
BIN
source/_posts/PowerShell/image-20250718142611106.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 40 KiB |
@ -192,3 +192,17 @@ picgo upload /path/to/your/image.png
|
||||
### Typora设置
|
||||
|
||||

|
||||
|
||||
## 主题
|
||||
|
||||
### typora-gitbook-theme
|
||||
|
||||
https://github.com/h16nning/typora-gitbook-theme
|
||||
|
||||
### typora-ladder-theme
|
||||
|
||||
https://github.com/guangzhengli/typora-ladder-theme
|
||||
|
||||
### Mdmdt
|
||||
|
||||
[cayxc/Mdmdt: Typora极简文档主题Mdmdt,包含亮色和暗色两种主题,是深度定制的个性化Typora主题;Typora minimalist document theme Mdmdt. Featuring both light and dark themes, it is a deeply customized personalized Typora theme.](https://github.com/cayxc/Mdmdt)
|
||||
|
||||
@ -1865,6 +1865,25 @@ yarn
|
||||
| npm install [package]@[version] | yarn add [package]@[version] | 安装指定版本的包 |
|
||||
| npm rebuild | yarn install --force | 重新下载所有包 |
|
||||
|
||||
##
|
||||
|
||||
## pnpm包管理器
|
||||
|
||||
```shell
|
||||
# 查看缓存存储位置
|
||||
pnpm store path
|
||||
# 设置缓存存储位置
|
||||
pnpm config set store-dir <new path>
|
||||
# 修改全局源
|
||||
pnpm config set registry https://registry.npmmirror.com
|
||||
# 修改项目源
|
||||
pnpm config set registry https://registry.npmmirror.com --save
|
||||
# 查看当前设置的源
|
||||
pnpm config get registry
|
||||
```
|
||||
|
||||
|
||||
|
||||
## 快速删除 node_modules
|
||||
|
||||
利用 npm 包 rimraf 快速删除 `node_modules` 文件夹
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user