[misc] refine windows 10 scripts
This commit is contained in:
parent
266f6aff8f
commit
c7a50e65bf
27
win/bin/bdiso-to-mkv.ps1
Normal file
27
win/bin/bdiso-to-mkv.ps1
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
param (
|
||||||
|
[parameter(Mandatory=$false)] [switch] $Delete,
|
||||||
|
[parameter(Mandatory=$false)] [string] $OutFormat=".mkv",
|
||||||
|
[parameter(Mandatory=$true, Position=0)] [string] $InPath,
|
||||||
|
[parameter(Mandatory=$true, Position=1)] [string] $OutPath
|
||||||
|
)
|
||||||
|
|
||||||
|
if (-not (Test-Path -LiteralPath $InPath -Type Leaf)) {
|
||||||
|
Write-Error "Invalid Input File Path $($InPath)"
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-not (Test-Path -LiteralPath $OutPath)) {
|
||||||
|
Write-Error "Invalid Output Path $($OutPath)"
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
if (Test-Path -LiteralPath $OutPath -PathType Container) {
|
||||||
|
$OutPath = Join-Path $OutPath ((Split-Path -Leaf $InPath) + $OutFormat)
|
||||||
|
}
|
||||||
|
|
||||||
|
$ConvertedInPath = Convert-Path -LiteralPath $InPath
|
||||||
|
$InDrive = "bluray:$((Mount-DiskImage $ConvertedInPath | Get-Volume).DriveLetter):\\"
|
||||||
|
ffmpeg.exe -i $InDrive -c:v copy $OutPath
|
||||||
|
Dismount-DiskImage $ConvertedInPath
|
||||||
|
if ($Delete) {
|
||||||
|
Remove-Item -LiteralPath $InPath
|
||||||
|
}
|
1
win/bin/clear-recently-opened.ps1
Normal file
1
win/bin/clear-recently-opened.ps1
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Remove-Item $env:AppData\Microsoft\Windows\Recent\* -Recurse
|
2
win/bin/list-fonts.ps1
Normal file
2
win/bin/list-fonts.ps1
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
|
||||||
|
(New-Object System.Drawing.Text.InstalledFontCollection).Families
|
4
win/mpv.ps1
Normal file
4
win/mpv.ps1
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
|
||||||
|
$dotfiles=(Get-Item $PSScriptRoot).Parent.FullName
|
||||||
|
New-Item -ItemType SymbolicLink -Target $dotfiles\config\mpv\mpv.conf -Path $Env:APPDATA\mpv\mpv.conf -Force
|
||||||
|
New-Item -ItemType SymbolicLink -Target $dotfiles\config\mpv\scripts -Path $Env:APPDATA\mpv\scripts -Force
|
6
win/oh-my-posh.ps1
Normal file
6
win/oh-my-posh.ps1
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
# Install-Module -Name PowerShellGet -Force -AllowPrerelease
|
||||||
|
# Install-Module -Name posh-git
|
||||||
|
# Install-Module -Name oh-my-posh
|
||||||
|
|
||||||
|
$dotfiles=(Get-Item $PSScriptRoot).Parent.FullName
|
||||||
|
New-Item -ItemType SymbolicLink -Target $dotfiles\win\profile.ps1 -Path $profile -Force
|
|
@ -1,32 +0,0 @@
|
||||||
# execute this first: Set-ExecutionPolicy RemoteSigned
|
|
||||||
|
|
||||||
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
|
|
||||||
Start-Process PowerShell -Verb RunAs "-NoProfile -ExecutionPolicy Bypass -Command `"cd '$pwd'; & '$PSCommandPath';`"";
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
# link config files
|
|
||||||
$dotfiles=(Get-Item $PSScriptRoot).Parent.FullName
|
|
||||||
New-Item -ItemType SymbolicLink -Target $dotfiles\win\profile.ps1 -Path $profile -Force
|
|
||||||
New-Item -ItemType SymbolicLink -Target $dotfiles\config\mpv\mpv.conf -Path $Env:APPDATA\mpv\mpv.conf -Force
|
|
||||||
New-Item -ItemType SymbolicLink -Target $dotfiles\config\mpv\scripts -Path $Env:APPDATA\mpv\scripts -Force
|
|
||||||
New-Item -ItemType SymbolicLink -Target $dotfiles\config\nvim -Path $Env:LOCALAPPDATA\nvim -Force
|
|
||||||
Remove-Item -Force -Recurse $Env:APPDATA\pip
|
|
||||||
New-Item -ItemType Directory -Path $Env:APPDATA\pip
|
|
||||||
New-Item -ItemType SymbolicLink -Target $dotfiles\pip\pip.conf -Path $Env:APPDATA\pip\pip.ini -Force
|
|
||||||
|
|
||||||
# fix Shift key toggling Cn/En fro MS wubi
|
|
||||||
#if (-not (Get-ScheduledTask -TaskName "Wubi No Shift")) {
|
|
||||||
#$wubiAction = New-ScheduledTaskAction -Execute 'Powershell.exe' `
|
|
||||||
#-Argument "-NoProfile -WindowStyle Hidden -File $PSScriptRoot\wubi-no-shift.ps1"
|
|
||||||
#$wubiTrigger = New-ScheduledTaskTrigger -AtLogOn
|
|
||||||
#Register-ScheduledTask -Action $wubiAction -Trigger $wubiTrigger -TaskName "Wubi No Shift" -Description "Disable Shift key toggling CN/EN" -RunLevel Highest
|
|
||||||
#}
|
|
||||||
|
|
||||||
Install-Module -Name PowerShellGet -Force -AllowPrerelease
|
|
||||||
Install-Module -Name posh-git
|
|
||||||
Install-Module -Name oh-my-posh
|
|
||||||
|
|
||||||
# replace notepad with nvim-qt
|
|
||||||
reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe" /v "Debugger" /t REG_SZ /d "${dotfiles}\win\npd.vbs" /f
|
|
||||||
|
|
7
win/vim.ps1
Normal file
7
win/vim.ps1
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
|
||||||
|
$dotfiles=(Get-Item $PSScriptRoot).Parent.FullName
|
||||||
|
if ( ! (Test-Path $Env:LOCALAPPDATA\nvim) ) {
|
||||||
|
New-Item -ItemType Directory -Path $Env:LOCALAPPDATA\nvim
|
||||||
|
}
|
||||||
|
New-Item -Force -ItemType SymbolicLink -Target $dotfiles\cli\vim\init.vim -Path $Env:LOCALAPPDATA\nvim\init.vim
|
||||||
|
New-Item -Force -ItemType SymbolicLink -Target $dotfiles\cli\vim\coc-settings.json -Path $Env:LOCALAPPDATA\nvim\coc-settings.json
|
|
@ -1,95 +0,0 @@
|
||||||
// This file was initially generated by Windows Terminal 1.0.1811.0
|
|
||||||
// It should still be usable in newer versions, but newer versions might have additional
|
|
||||||
// settings, help text, or changes that you will not see unless you clear this file
|
|
||||||
// and let us generate a new one for you.
|
|
||||||
|
|
||||||
// To view the default settings, hold "alt" while clicking on the "Settings" button.
|
|
||||||
// For documentation on these settings, see: https://aka.ms/terminal-documentation
|
|
||||||
{
|
|
||||||
"$schema": "https://aka.ms/terminal-profiles-schema",
|
|
||||||
|
|
||||||
"defaultProfile": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
|
|
||||||
|
|
||||||
// You can add more global application settings here.
|
|
||||||
// To learn more about global settings, visit https://aka.ms/terminal-global-settings
|
|
||||||
|
|
||||||
// If enabled, selections are automatically copied to your clipboard.
|
|
||||||
"copyOnSelect": true,
|
|
||||||
|
|
||||||
// If enabled, formatted data is also copied to your clipboard
|
|
||||||
"copyFormatting": false,
|
|
||||||
|
|
||||||
// A profile specifies a command to execute paired with information about how it should look and feel.
|
|
||||||
// Each one of them will appear in the 'New Tab' dropdown,
|
|
||||||
// and can be invoked from the commandline with `wt.exe -p xxx`
|
|
||||||
// To learn more about profiles, visit https://aka.ms/terminal-profile-settings
|
|
||||||
"profiles":
|
|
||||||
{
|
|
||||||
"defaults":
|
|
||||||
{
|
|
||||||
// Put settings here that you want to apply to all profiles.
|
|
||||||
"acrylicOpacity" : 0.90,
|
|
||||||
"colorScheme": "One Half Dark",
|
|
||||||
"fontFace" : "Hurmit NF",
|
|
||||||
"useAcrylic" : true
|
|
||||||
},
|
|
||||||
"list":
|
|
||||||
[
|
|
||||||
{
|
|
||||||
// Make changes here to the powershell.exe profile.
|
|
||||||
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
|
|
||||||
"name": "Windows PowerShell",
|
|
||||||
"commandline": "powershell.exe",
|
|
||||||
"hidden": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
// Make changes here to the cmd.exe profile.
|
|
||||||
"guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
|
|
||||||
"name": "命令提示符",
|
|
||||||
"commandline": "cmd.exe",
|
|
||||||
"hidden": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
|
|
||||||
"hidden": false,
|
|
||||||
"name": "Azure Cloud Shell",
|
|
||||||
"source": "Windows.Terminal.Azure"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
|
|
||||||
"hidden": false,
|
|
||||||
"name": "PowerShell",
|
|
||||||
"source": "Windows.Terminal.PowershellCore"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
|
|
||||||
// Add custom color schemes to this array.
|
|
||||||
// To learn more about color schemes, visit https://aka.ms/terminal-color-schemes
|
|
||||||
"schemes": [],
|
|
||||||
|
|
||||||
// Add custom keybindings to this array.
|
|
||||||
// To unbind a key combination from your defaults.json, set the command to "unbound".
|
|
||||||
// To learn more about keybindings, visit https://aka.ms/terminal-keybindings
|
|
||||||
"keybindings":
|
|
||||||
[
|
|
||||||
// Copy and paste are bound to Ctrl+Shift+C and Ctrl+Shift+V in your defaults.json.
|
|
||||||
// These two lines additionally bind them to Ctrl+C and Ctrl+V.
|
|
||||||
// To learn more about selection, visit https://aka.ms/terminal-selection
|
|
||||||
{ "command": {"action": "copy", "singleLine": false }, "keys": "ctrl+c" },
|
|
||||||
{ "command": "paste", "keys": "ctrl+v" },
|
|
||||||
|
|
||||||
// Press Ctrl+Shift+F to open the search box
|
|
||||||
{ "command": "find", "keys": "ctrl+shift+f" },
|
|
||||||
|
|
||||||
// Press Alt+Shift+D to open a new pane.
|
|
||||||
// - "split": "auto" makes this pane open in the direction that provides the most surface area.
|
|
||||||
// - "splitMode": "duplicate" makes the new pane use the focused pane's profile.
|
|
||||||
// To learn more about panes, visit https://aka.ms/terminal-panes
|
|
||||||
{ "command": { "action": "splitPane", "split": "auto", "splitMode": "duplicate" }, "keys": "alt+shift+d" },
|
|
||||||
{ "command": "scrollUp", "keys": "pgup" },
|
|
||||||
{ "command": "scrollDown", "keys": "pgdn" },
|
|
||||||
{ "command": "prevTab", "keys": "ctrl+pgup" },
|
|
||||||
{ "command": "nextTab", "keys": "ctrl+pgdn" }
|
|
||||||
]
|
|
||||||
}
|
|
|
@ -1,4 +0,0 @@
|
||||||
|
|
||||||
if [ -t 1 ]; then
|
|
||||||
exec /usr/bin/fish
|
|
||||||
fi
|
|
|
@ -1,62 +0,0 @@
|
||||||
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
|
|
||||||
Start-Process PowerShell -Verb RunAs "-NoProfile -ExecutionPolicy Bypass -Command `"cd '$pwd'; & '$PSCommandPath';`"";
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
Function ExitOnError ([string]$message) {
|
|
||||||
Write-Error $message
|
|
||||||
Read-Host -Prompt "Press Enter to continue"
|
|
||||||
exit -1
|
|
||||||
}
|
|
||||||
|
|
||||||
$Supported = @{
|
|
||||||
"B3448BF077665F2E1CA67094BCF2A7C5" = 0x14DE1;
|
|
||||||
"DE5FA392A825332AB3E348EF0316B514" = 0x16A61;
|
|
||||||
"F653C99D4A0C61D4B2C64358B8213BD8" = 0x15C11;
|
|
||||||
"C8BC76C87563E78C9BC85EE9F4F96760" = 0x15C11;
|
|
||||||
}
|
|
||||||
$ChsIME = "ChsIME"
|
|
||||||
$ChsIMEExe = "${ChsIME}.exe"
|
|
||||||
|
|
||||||
# make sure CheIme.exe is the right version
|
|
||||||
$ChsImeExePath = "$env:windir\System32\InputMethod\CHS\$ChsIMEExe"
|
|
||||||
$ChsIMEHash = (Get-FileHash $ChsImeExePath -Algorithm MD5).Hash
|
|
||||||
$offsetAddr = $Supported[$ChsIMEHash]
|
|
||||||
if (-not $offsetAddr) {
|
|
||||||
ExitOnError 'Unsupported ChsIme.exe'
|
|
||||||
}
|
|
||||||
|
|
||||||
Add-Type -MemberDefinition @'
|
|
||||||
[DllImport("kernel32.dll", SetLastError = true)]
|
|
||||||
public static extern bool WriteProcessMemory(
|
|
||||||
IntPtr hProcess,
|
|
||||||
IntPtr lpBaseAddress,
|
|
||||||
byte[] lpBuffer,
|
|
||||||
Int32 nSize,
|
|
||||||
out IntPtr lpNumberOfBytesWritten);
|
|
||||||
'@ -Name Kernel32 -Namespace Pinvoke
|
|
||||||
|
|
||||||
|
|
||||||
$i = 0
|
|
||||||
while ($i++ -lt 30) {
|
|
||||||
$ps = Get-Process -Name $ChsIME
|
|
||||||
foreach ($p in $ps) {
|
|
||||||
$hModule = $p.Modules | Where-Object {$_.ModuleName -eq $ChsIMEExe}
|
|
||||||
if (!$hModule) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
$hModule = $hModule[0]
|
|
||||||
$addr = [IntPtr]::Add($hModule.BaseAddress, $offsetAddr)
|
|
||||||
[Int32]$n = 0
|
|
||||||
$pidd = $p.id
|
|
||||||
if ([Pinvoke.Kernel32]::WriteProcessMemory($p.Handle[0], $addr, @(0x31, 0xc0), 2, [ref]$n)) {
|
|
||||||
Write-Output "$pidd is patched"
|
|
||||||
} else {
|
|
||||||
ExitOnError "Failed to patch $pidd"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($ps) {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
Start-Sleep -Milliseconds 100
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user