mirror of
https://github.com/js0ny/dotfiles.git
synced 2025-12-21 00:33:00 +00:00
92 lines
2.7 KiB
PowerShell
92 lines
2.7 KiB
PowerShell
### Load Configs ###
|
|
$DOTFILES = "$HOME\.dotfiles"
|
|
Get-ChildItem -Path $DOTFILES\powershell -Filter *.ps1 | ForEach-Object {. $_}
|
|
Get-ChildItem -Path $DOTFILES\powershell_private -Filter *.ps1 | ForEach-Object {. $_}
|
|
|
|
### Aliases ###
|
|
|
|
# Shell Equivalents #
|
|
Set-Alias "grep" "Select-String"
|
|
${function:which} = { (Get-Command $args[0]) }
|
|
|
|
# Shell Configurations #
|
|
${function:shcfg} = { code $PROFILE }
|
|
${function:reload} = { & $PROFILE }
|
|
${function:pulldots} = { Set-Location -Path $DOTFILES && git pull }
|
|
Set-Alias "pwshcfg" "shcfg"
|
|
|
|
# WSL #
|
|
${function:wsl1} = {wsl.exe --distribution Arch}
|
|
${function:wsl2} = {wsl.exe --distribution Ubuntu-22.04}
|
|
|
|
# Search Software #
|
|
function Find-AppPackageListRemote {
|
|
param(
|
|
[string]$Name
|
|
)
|
|
if (-not $Name) {
|
|
Write-Host "Please provide a package name."
|
|
return
|
|
}
|
|
Write-Host "Searching for $Name..."
|
|
Write-Host "=== winget ==="
|
|
winget search $Name
|
|
Write-Host "=== choco ==="
|
|
choco search $Name
|
|
# Too slow!
|
|
# Write-Host "=== scoop ==="
|
|
# scoop search $Name
|
|
}
|
|
Set-Alias "pkgsearch" "Find-AppPackageListRemote"
|
|
function Get-AppPackageListLocal {
|
|
winget list
|
|
choco list
|
|
scoop list
|
|
}
|
|
|
|
# Toggle Theme #
|
|
Set-Alias "dark-mode" "$DOTFILES/win/cmd/dark-mode.bat" # Consistent with macOS (`dark-mode`)
|
|
|
|
# Miscs #
|
|
|
|
### Misc ###
|
|
${function:qwen} = "ollama run qwen2.5:14b"
|
|
|
|
## Conda ##
|
|
#region conda initialize
|
|
# !! Contents within this block are managed by 'conda init' !!
|
|
If (Test-Path "$HOME\miniconda3\Scripts\conda.exe") {
|
|
(& "$HOME\miniconda3\Scripts\conda.exe" "shell.powershell" "hook") | Out-String | Where-Object{$_} | Invoke-Expression
|
|
}
|
|
#endregion
|
|
|
|
## Check Start Up ##
|
|
#$SystemlogFilePath = "$env:USERPROFILE\.PowerShellStartup.log"
|
|
## 检查日志文件是否存在
|
|
#if (-not (Test-Path $SystemlogFilePath)) {
|
|
# New-Item -Path $SystemlogFilePath -ItemType File -Force | Out-Null
|
|
#}
|
|
## 读取日志文件的最后一行(即上次启动日期)
|
|
#$__lastStartup = Get-Content -Path $SystemlogFilePath -Tail 1 -ErrorAction SilentlyContinue
|
|
#$_currentDate = (Get-Date).ToString("yyyy-MM-dd")
|
|
#if (-not ($__lastStartup -eq $_currentDate)) {
|
|
# Get-Date
|
|
# Update-ForexData &
|
|
# Write-Host "今天是第一次启动 PowerShell。"
|
|
# # 记录当前日期到日志文件
|
|
# $_currentDate | Out-File -FilePath $SystemlogFilePath -Append
|
|
#}
|
|
#Remove-Variable SystemlogFilePath
|
|
#Remove-Variable __lastStartup
|
|
#Remove-Variable _currentDate
|
|
|
|
# Use some unix commands
|
|
${function:tree} = { wsl tree $args}
|
|
${function:ln} = { coreutils.exe ln $args}
|
|
${function:la} = { lsd.exe -la $args}
|
|
|
|
# Set default applications
|
|
$Env:PAGER = "less"
|
|
$Env:EDITOR = "code --wait"
|
|
$Env:VISUAL = "code --wait"
|
|
$Env:FILE_MANAGER = "dopus.exe"
|